diff --git a/Src/CSharpier.MsBuild/README.md b/Src/CSharpier.MsBuild/README.md index 8b0903a35..2226efa94 100644 --- a/Src/CSharpier.MsBuild/README.md +++ b/Src/CSharpier.MsBuild/README.md @@ -4,7 +4,16 @@ One way to test the changes in the build/* files - Edit those files at `C:\Users\[Username]\.nuget\packages\csharpier.msbuild\[VersionNumber]\build` - Ensure you revert those files and make the same changes to the files here. -Another way -- the validate PR GH action does this, currently only uses the net8 sdk -- dotnet pack Src/CSharpier.MsBuild/CSharpier.MsBuild.csproj -o nupkg /p:Version=0.0.1 -- docker build -f ./Tests/CSharpier.MsBuild.Test/Dockerfile . +Some automated tests exist +- the validate PR GH action runs these, mostly around framework versions +- cd ./Tests/MsBuild +- ./Run.ps1 + +Other things that would be really really nice to automate +- exits properly in release when no files formatted + https://github.com/belav/csharpier/issues/1357 +- same as above if thing set +- formats files in debug +- formats files if told to in release +- a few scenarios in here I think, compilation errors etc + https://github.com/belav/csharpier/issues/1131 diff --git a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets index 10d4787a6..f94a6e67b 100644 --- a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets +++ b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets @@ -17,6 +17,8 @@ /dev/null + + diff --git a/Tests/MsBuild/Directory.Build.props b/Tests/MsBuild/Directory.Build.props new file mode 100644 index 000000000..c416fb784 --- /dev/null +++ b/Tests/MsBuild/Directory.Build.props @@ -0,0 +1,5 @@ + + + false + + \ No newline at end of file diff --git a/Tests/MsBuild/Run.ps1 b/Tests/MsBuild/Run.ps1 index adb76860b..e516b58de 100644 --- a/Tests/MsBuild/Run.ps1 +++ b/Tests/MsBuild/Run.ps1 @@ -22,6 +22,7 @@ foreach ($scenario in $scenarios) { Write-Host "::group::$($scenario.name)" $scenarioPath = Join-Path $basePath $scenario.name + Write-Host $scenarioPath New-Item $scenarioPath -ItemType Directory | Out-Null $dockerFile = Join-Path $scenarioPath "DockerFile" @@ -38,7 +39,7 @@ RUN dotnet build -c Release $csprojFile = Join-Path $scenarioPath "Project.csproj" $csharpierFrameworkVersion = "" - if ($null -ne $scenario.csharpier_frameworkVersion) { + if ([bool]($scenario.PSobject.Properties.name -match "csharpier_frameworkVersion")) { $csharpierFrameworkVersion = " $($scenario.csharpier_frameworkVersion) " diff --git a/Tests/MsBuild/Scenarios.json b/Tests/MsBuild/Scenarios.json index a960fdf48..cb1868f20 100644 --- a/Tests/MsBuild/Scenarios.json +++ b/Tests/MsBuild/Scenarios.json @@ -1,21 +1,21 @@ [ { - "name": "sdk:8.0_netstandard2.0", + "name": "sdk-8.0_netstandard2.0", "sdk": "mcr.microsoft.com/dotnet/sdk:8.0", "targetFrameworks": "netstandard2.0" }, { - "name": "sdk:8.0_net8.0-windows", + "name": "sdk-8.0_net8.0-windows", "sdk": "mcr.microsoft.com/dotnet/sdk:8.0", "targetFrameworks": "net8.0-windows" }, { - "name": "sdk:8.0_net6.0;net7.07", + "name": "sdk-8.0_net6.0;net7.07", "sdk": "mcr.microsoft.com/dotnet/sdk:8.0", "targetFrameworks": "net6.0;net7.0" }, { - "name": "sdk:8.0_csharpier-net8.0", + "name": "sdk-8.0_csharpier-net8.0", "sdk": "mcr.microsoft.com/dotnet/sdk:8.0", "targetFrameworks": "netstandard2.0", "csharpier_frameworkVersion": "net8.0" diff --git a/Tests/MsBuild/UnformattedFileCausesError/Project.csproj b/Tests/MsBuild/UnformattedFileCausesError/Project.csproj new file mode 100644 index 000000000..f719d5263 --- /dev/null +++ b/Tests/MsBuild/UnformattedFileCausesError/Project.csproj @@ -0,0 +1,12 @@ + + + net8.0 + false + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Tests/MsBuild/UnformattedFileCausesError/UnformattedFile.cs b/Tests/MsBuild/UnformattedFileCausesError/UnformattedFile.cs new file mode 100644 index 000000000..bb5ff02b8 --- /dev/null +++ b/Tests/MsBuild/UnformattedFileCausesError/UnformattedFile.cs @@ -0,0 +1,7 @@ +namespace Net8; + +public class Class1 +{ + + +} diff --git a/Tests/MsBuild/nuget.config b/Tests/MsBuild/nuget.config index 09743ecda..4fea3fab9 100644 --- a/Tests/MsBuild/nuget.config +++ b/Tests/MsBuild/nuget.config @@ -1,6 +1,16 @@ + + + + + + + + + + \ No newline at end of file