Move analyzers restore to a .depproj to follow arcade Tools.proj convention (dotnet...
authorSantiago Fernandez Madero <safern@microsoft.com>
Thu, 17 Oct 2019 19:58:29 +0000 (12:58 -0700)
committerGitHub <noreply@github.com>
Thu, 17 Oct 2019 19:58:29 +0000 (12:58 -0700)
* Move analyzers restore to a .depproj to follow arcade Tools.proj convention

* Fix build break

* PR Feedback

Commit migrated from https://github.com/dotnet/corefx/commit/0a3bfee6f2af0e1558b98cae1a5b81ffd084aa99

eng/CodeAnalysis.targets
eng/restore/analyzers/Configurations.props [new file with mode: 0644]
eng/restore/analyzers/analyzers.depproj [new file with mode: 0644]
eng/restore/dirs.proj
eng/restore/repoRestore.props

index 8a585a4..74f6163 100644 (file)
@@ -1,9 +1,4 @@
 <Project>
-  <PropertyGroup>
-    <!-- Need to keep in sync with Tools.props file. -->
-    <AnalyzerPropsFile>$(ToolSetCommonDirectory)Tools.Analyzers.props</AnalyzerPropsFile>
-  </PropertyGroup>
-
   <Import Condition="Exists($(AnalyzerPropsFile)) AND '$(EnableAnalyzers)' == 'true'" Project="$(AnalyzerPropsFile)" />
 
   <!-- This target is executed when building a project and EnableAnalyzers property is set to true. 
diff --git a/eng/restore/analyzers/Configurations.props b/eng/restore/analyzers/Configurations.props
new file mode 100644 (file)
index 0000000..a0590ba
--- /dev/null
@@ -0,0 +1,7 @@
+<Project>
+  <PropertyGroup>
+    <BuildConfigurations>
+      netstandard;
+    </BuildConfigurations>
+  </PropertyGroup>
+</Project>
diff --git a/eng/restore/analyzers/analyzers.depproj b/eng/restore/analyzers/analyzers.depproj
new file mode 100644 (file)
index 0000000..27dc13b
--- /dev/null
@@ -0,0 +1,20 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <EnableBinPlacing>false</EnableBinPlacing>
+    <Language>C#</Language>
+  </PropertyGroup>
+
+  <!-- Import PackageReferences containing analyzers -->
+  <Import Project="$(RepositoryEngineeringDir)Analyzers.props" />
+
+  <UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.SaveItems" AssemblyFile="$(ArcadeSdkBuildTasksAssembly)" />
+
+  <Target Name="GenerateAnalyzersPropsFile"
+          AfterTargets="ResolveLockFileAnalyzers">
+
+    <SaveItems Condition="'@(Analyzer)' != ''"
+               ItemName="ResolvedAnalyzer"
+               Items="@(Analyzer)"
+               File="$(AnalyzerPropsFile)" />
+  </Target>
+</Project>
index 3c87a32..d41140d 100644 (file)
@@ -5,8 +5,10 @@
     <AdditionalBuildConfigurations>$(AdditionalBuildConfigurations);netstandard-$(OSGroup)-$(ConfigurationGroup)-$(ArchGroup)</AdditionalBuildConfigurations>
   </PropertyGroup>
 
-  <!-- Build for all configurations -->
   <ItemGroup>
+    <Project Condition="'$(DotNetBuildFromSource)' != 'true'" Include="analyzers/analyzers.depproj" />
+
+    <!-- Build for all configurations -->
     <Project Condition="'$(BuildAllConfigurations)' == 'true'" Include="netcoreapp/netcoreapp.depproj" />
     <Project Include="netstandard/netstandard.depproj" />
     <Project Include="netfx/netfx.depproj" />
index c5700dd..204c23d 100644 (file)
@@ -18,6 +18,7 @@
 
   <!-- Enable the repo-restored analyzers -->
   <PropertyGroup>
+    <AnalyzerPropsFile>$(ToolSetCommonDirectory)Tools.Analyzers.props</AnalyzerPropsFile>
     <EnableAnalyzers Condition="'$(EnableAnalyzers)' == '' and '$(IsSourceProject)' == 'true'">true</EnableAnalyzers>
   </PropertyGroup>