Skip to content

Commit

Permalink
Ensure that compilation errors surface properly when building a proje…
Browse files Browse the repository at this point in the history
…ct with CSharpier.msbuild in debug (#959)
  • Loading branch information
belav authored Sep 25, 2023
1 parent 4347337 commit 8c6a3b1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ Src/CSharpier.VSCode/.idea/prettier.xml
.idea/.idea.CSharpier/.idea/riderMarkupCache.xml
/Src/CSharpier.Benchmarks/BenchmarkDotNet.Artifacts/
/Src/CSharpier.Tests/TestResults
/Src/CSharpier.MsBuild.Test/.idea
16 changes: 16 additions & 0 deletions Src/CSharpier.MsBuild.Test/CSharpier.MsBuild.Test.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpier.MsBuild.Test", "CSharpier.MsBuild.Test.csproj", "{68C08C66-BB6C-4961-9298-7936549C4F20}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{68C08C66-BB6C-4961-9298-7936549C4F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68C08C66-BB6C-4961-9298-7936549C4F20}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68C08C66-BB6C-4961-9298-7936549C4F20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68C08C66-BB6C-4961-9298-7936549C4F20}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
8 changes: 7 additions & 1 deletion Src/CSharpier.MsBuild/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
This can be tested by
One way to test the changes in the build/* files
- Load CSharpier.MsBuild.csproj in your IDE
- Restore the nuget packages
- 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 to test

- Making any changes you want
```powershell
Expand Down
8 changes: 7 additions & 1 deletion Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
<CSharpierArgs Condition="'$(CSharpier_LogLevel)' != ''">$(CSharpierArgs) --loglevel $(CSharpier_LogLevel)</CSharpierArgs>
<FirstTargetFramework Condition=" '$(TargetFrameworks)' == '' ">$(TargetFramework)</FirstTargetFramework>
<FirstTargetFramework Condition=" '$(FirstTargetFrameworks)' == '' ">$(TargetFrameworks.Split(';')[0])</FirstTargetFramework>
<NullOutput>NUL</NullOutput>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<NullOutput>/dev/null</NullOutput>
</PropertyGroup>

<Target Name="CSharpierFormatInner" Condition="'$(CSharpier_Bypass)' != 'true'">
<!-- &gt; NullOutput suppresses the output from this so that compilation errors will show up a single time -->
<Exec
ConsoleToMSBuild="true"
StdOutEncoding="utf-8"
StdErrEncoding="utf-8"
Command="dotnet &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check &quot;$(MSBuildProjectDirectory)&quot;" />
Command="dotnet &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check &quot;$(MSBuildProjectDirectory)&quot; &gt; $(NullOutput) " />
</Target>

<!-- getting this to run a single time for projects that target multiple frameworks requires all of this
Expand Down

0 comments on commit 8c6a3b1

Please sign in to comment.