Make Roslyn Analyzers opt-in at compile-time (resolves )

They are still run by the IDE at design-time. To opt-in, set the MSBuild
property MachineRunAnalyzersDuringBuild. From the command-line, you can do this
by adding `/p:MachineRunAnalyzersDuringBuild=true`.
This commit is contained in:
YoshiRulz 2020-01-26 10:32:18 +10:00
parent 551a7e2893
commit 215de3c0c0
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 5 additions and 4 deletions

View File

@ -8,8 +8,8 @@
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" PrivateAssets="All" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113"
Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
<Compile Include="$(SolutionDir)Version/svnrev.cs" />
<Compile Include="$(SolutionDir)Version/VersionInfo.cs" />
<Compile Remove="Extensions/BinaryReaderExtensions.cs" />

View File

@ -6,6 +6,8 @@
<LangVersion>8.0</LangVersion>
<OutputPath>$(SolutionDir)output/dll</OutputPath>
<PlatformTarget>x64</PlatformTarget>
<RunAnalyzersDuringBuild Condition=" '$(MachineRunAnalyzersDuringBuild)' == '' ">false</RunAnalyzersDuringBuild>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@ -21,6 +23,5 @@
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir).stylecop.json" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -14,7 +14,7 @@ for /f "usebackq tokens=*" %%A in (`vswhere -version "[16.0,17.0)" -requires Mic
IF "%MSBUILDPATH%"=="" GOTO MISSINGMSBUILD
nuget restore ..\BizHawk.sln
call "%MSBUILDPATH%" ..\BizHawk.sln /p:Configuration=Release /p:Platform="Any Cpu" /t:rebuild
call "%MSBUILDPATH%" ..\BizHawk.sln "/p:Configuration=Release;Platform=AnyCPU;MachineRunAnalyzersDuringBuild=true" /t:rebuild
@if errorlevel 1 goto MSBUILDFAILED