mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00
Don't enable ILLink analyzers for unsupported TFMs (#87071)
* Don't enable ILLink analyzers for unsupported TFMs This adds a condition to EnableSingleFileAnalyzer to prevent it from requiring the ILLink pack that is only supported on netcoreapp3.0 and above. Adding a condition on the TFM requires moving the setting into a targets file. Also consolidates more of the analyzer logic into this file. --------- Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
This commit is contained in:
parent
1d5ee1c9e2
commit
56c427bb4d
7 changed files with 17 additions and 11 deletions
|
@ -313,7 +313,6 @@
|
|||
<!-- RepositoryEngineeringDir isn't set when Installer tests import this file. -->
|
||||
<Import Project="$(RepositoryEngineeringDir)native\naming.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Subsets.props" />
|
||||
<Import Project="$(RepositoryEngineeringDir)Analyzers.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<CoreLibSharedDir>$([MSBuild]::NormalizeDirectory('$(LibrariesProjectRoot)', 'System.Private.CoreLib', 'src'))</CoreLibSharedDir>
|
||||
|
@ -383,11 +382,6 @@
|
|||
<IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsPublishedAppTestProject)' == 'true'">false</IsShipping>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
|
||||
<EditorConfigFiles Remove="$(RepositoryEngineeringDir)CodeAnalysis.src.globalconfig" />
|
||||
<EditorConfigFiles Include="$(RepositoryEngineeringDir)CodeAnalysis.test.globalconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Treat as a generator project if either the parent or the parent parent directory is named gen. -->
|
||||
<IsGeneratorProject Condition="$([System.IO.Path]::GetFileName('$(MSBuildProjectDirectory)')) == 'gen' or
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(RepositoryEngineeringDir)Analyzers.targets" />
|
||||
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
||||
<Import Project="$(RepositoryEngineeringDir)liveBuilds.targets" />
|
||||
<Import Project="$(RepositoryEngineeringDir)generators.targets" />
|
||||
|
@ -35,7 +36,6 @@
|
|||
unconditionally in Microsoft.NETCoreSdk.BundledVersions.props.
|
||||
-->
|
||||
<NETCoreAppMaximumVersion>$(MajorVersion).$(MinorVersion)</NETCoreAppMaximumVersion>
|
||||
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers)' == ''">$(RunAnalyzers)</EnableNETAnalyzers>
|
||||
<!-- SDK sets product to assembly but we want it to be our product name -->
|
||||
<Product>Microsoft%AE .NET</Product>
|
||||
<!-- Use the .NET product branding version for informational version description -->
|
||||
|
|
|
@ -4,7 +4,7 @@ This repo relies on [.NET Compiler Platform analyzers](https://learn.microsoft.c
|
|||
|
||||
To add an analyzer package to the build:
|
||||
1. Select a package you want to employ, for example https://www.nuget.org/packages/SonarAnalyzer.CSharp/. This analyzer package's name is `SonarAnalyzer.CSharp` and the latest version as of this edit is `8.50.0.58025`.
|
||||
2. Add a `PackageReference` entry to <https://github.com/dotnet/runtime/blob/main/eng/Analyzers.props>, e.g.
|
||||
2. Add a `PackageReference` entry to <https://github.com/dotnet/runtime/blob/main/eng/Analyzers.targets>, e.g.
|
||||
```XML
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025" PrivateAssets="all" />
|
||||
```
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
<PropertyGroup>
|
||||
<!-- Disable analyzers in sourcebuild -->
|
||||
<RunAnalyzers Condition="'$(DotNetBuildFromSource)' == 'true'">false</RunAnalyzers>
|
||||
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers)' == ''">$(RunAnalyzers)</EnableNETAnalyzers>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(RunAnalyzers)' != 'false'">
|
||||
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
|
||||
<EnableSingleFileAnalyzer Condition="
|
||||
'$(EnableSingleFileAnalyzer)' == '' And
|
||||
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">true</EnableSingleFileAnalyzer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(RunAnalyzers)' != 'false'">
|
||||
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)CodeAnalysis.src.globalconfig" />
|
||||
|
@ -13,4 +16,8 @@
|
|||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersVersion)" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
|
||||
<EditorConfigFiles Remove="$(RepositoryEngineeringDir)CodeAnalysis.src.globalconfig" />
|
||||
<EditorConfigFiles Include="$(RepositoryEngineeringDir)CodeAnalysis.test.globalconfig" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<IsTrimmable Condition="'$(IsTrimmable)' == ''">true</IsTrimmable>
|
||||
<!-- Don't use SDK's trimming functionality. -->
|
||||
<!-- Don't use SDK's trimming functionality.
|
||||
TODO: Remove this once we build using preview 6 SDK. -->
|
||||
<_IsTrimmingEnabled>false</_IsTrimmingEnabled>
|
||||
<!-- Same fix for preview 6 SDK. -->
|
||||
<_RequiresILLinkPack>false</_RequiresILLinkPack>
|
||||
<PrepareResourcesDependsOn>_EmbedILLinkXmls;$(PrepareResourcesDependsOn)</PrepareResourcesDependsOn>
|
||||
<TargetsTriggeredByCompilation Condition="'$(DesignTimeBuild)' != 'true'">$(TargetsTriggeredByCompilation);ILLinkTrimAssembly</TargetsTriggeredByCompilation>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<Project>
|
||||
<Import Project="..\..\Directory.Build.props" />
|
||||
<Import Project="..\..\Directory.Build.targets" />
|
||||
<ItemGroup>
|
||||
<EditorConfigFiles Remove="$(RepositoryEngineeringDir)CodeAnalysis.src.globalconfig" />
|
||||
<EditorConfigFiles Include="$(RepositoryEngineeringDir)CodeAnalysis.test.globalconfig" />
|
|
@ -22,6 +22,8 @@
|
|||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<IncludeMultiTargetRoslynComponentTargets>false</IncludeMultiTargetRoslynComponentTargets>
|
||||
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddBuildOutputToToolsPackage</TargetsForTfmSpecificContentInPackage>
|
||||
<!-- Disable analyzer to prevent a circular dependency due to PackageReference to the LKG Microsoft.NET.ILLink.Tasks. -->
|
||||
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue