Skip to content

Commit 3d6f4c2

Browse files
committed
Disable loading code style analyzers when building from VS
1 parent e70ee96 commit 3d6f4c2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' AND '$(BuildArchitecture)' == 'loongarch64'">$(BuildArchitecture)</TargetArchitecture>
1111
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
1212
<Nullable>enable</Nullable>
13+
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
1314
</PropertyGroup>
1415

1516
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />

Directory.Build.targets

+17
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,21 @@
7878
</KnownFrameworkReference>
7979
</ItemGroup>
8080

81+
<PropertyGroup>
82+
<CoreCompileDependsOn>$(CoreCompileDependsOn);RemoveCodeStyleAnalyzers</CoreCompileDependsOn>
83+
</PropertyGroup>
84+
85+
<!--
86+
CodeStyle analyzers inserted in the SDK might not be compatible with the current public version of Visual Studio,
87+
which causes failures when building from the IDE.
88+
-->
89+
<Target Name="RemoveCodeStyleAnalyzers" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
90+
<ItemGroup>
91+
<Analyzer Remove="@(Analyzer)" Condition="
92+
'%(FileName)' == 'Microsoft.CodeAnalysis.CodeStyle' or
93+
'%(FileName)' == 'Microsoft.CodeAnalysis.CodeStyle.Fixes' or
94+
'%(FileName)' == 'Microsoft.CodeAnalysis.CSharp.CodeStyle' or
95+
'%(FileName)' == 'Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes'"/>
96+
</ItemGroup>
97+
</Target>
8198
</Project>

0 commit comments

Comments
 (0)