From 6afe96cc2e950379d13a87efa1fa5a651cbce9bd Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Sun, 1 Dec 2019 11:01:39 +0100 Subject: [PATCH] Converge common msbuild properties and targets (#338) * Converge common msbuild properties and targets Moving common msbuild properties and targets into the repo root. * Consolidate analyzers logic into the repo root Consolidating msbuild analyzers logic centrally in the repo root and adding a property switch `EnableAnalyzers` to enable analyzers. We still need to import the Analyzers.props file unconditionally as libraries currently doesn't use the PackageReference logic in ref and src projects and instead uses a depproj to create a props file dynamically. * More cleanup to fix CoreLib build --- Directory.Build.props | 52 +++++++- Directory.Build.targets | 16 +++ eng/{analyzers.props => Analyzers.props} | 5 +- eng/Build.props | 4 - {src/libraries => eng}/CodeAnalysis.ruleset | 0 eng/Subsets.props | 9 +- eng/Tools.props | 11 +- eng/Versions.props | 1 - eng/illink.targets | 5 +- eng/restore/illink.targets | 20 --- src/coreclr/src/Directory.Build.targets | 3 + .../CreateRuntimeRootILLinkDescriptorFile.targets | 3 +- .../src/System.Private.CoreLib/ILLink.targets | 146 --------------------- .../System.Private.CoreLib.csproj | 49 ++----- src/installer/Directory.Build.props | 23 ---- src/installer/Directory.Build.targets | 8 -- src/libraries/Directory.Build.props | 56 +------- src/libraries/Directory.Build.targets | 34 ++--- src/libraries/restore/analyzers/analyzers.depproj | 4 +- 19 files changed, 114 insertions(+), 335 deletions(-) rename eng/{analyzers.props => Analyzers.props} (68%) rename {src/libraries => eng}/CodeAnalysis.ruleset (100%) delete mode 100644 eng/restore/illink.targets delete mode 100644 src/coreclr/src/System.Private.CoreLib/ILLink.targets diff --git a/Directory.Build.props b/Directory.Build.props index 42b9df1..867d863 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,13 @@ + + + false + + + + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'installer.tasks')) $([MSBuild]::NormalizePath('$(InstallerTasksOutputPath)', 'Debug', 'netstandard2.0', 'installer.tasks.dll')) $([MSBuild]::NormalizePath('$(InstallerTasksOutputPath)', 'Debug', 'net46', 'installer.tasks.dll')) $(ArtifactsObjDir)HostMachineInfo.props - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'libraries')) - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'coreclr')) - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'installer')) - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'docs')) $([MSBuild]::NormalizeDirectory('$(DocsDir)', 'manpages')) $([MSBuild]::NormalizeDirectory('$(LibrariesProjectRoot)', 'System.Private.CoreLib', 'src')) @@ -49,6 +56,37 @@ git://github.com/dotnet/runtime https://github.com/dotnet/runtime https://github.com/dotnet/runtime/blob/master/LICENSE.TXT + $(RepoRoot)LICENSE.TXT + + + true + + + true + false + + + false + + + + + + latest + preview + true + + + false + + + true + + Properties + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets index 5180c31..7d40eb9 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,21 @@ + + + false + + + + + $(MajorVersion).$(MinorVersion) + + \ No newline at end of file diff --git a/eng/analyzers.props b/eng/Analyzers.props similarity index 68% rename from eng/analyzers.props rename to eng/Analyzers.props index 4aa6b32..24d83dc 100644 --- a/eng/analyzers.props +++ b/eng/Analyzers.props @@ -1,5 +1,8 @@ - + + $(MSBuildThisFileDirectory)CodeAnalysis.ruleset + + diff --git a/eng/Build.props b/eng/Build.props index 20dbe66..5e060ad 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -15,10 +15,6 @@ https://github.com/dotnet/arcade/issues/388 --> - - true - - - - + + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'libraries')) + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'coreclr')) + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'installer')) + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'tools-local')) + $([MSBuild]::NormalizeDirectory('$(RepoToolsLocalDir)', 'tasks')) + libraries-installer-coreclr diff --git a/eng/Tools.props b/eng/Tools.props index a763640..fa98043 100644 --- a/eng/Tools.props +++ b/eng/Tools.props @@ -1,11 +1,12 @@ false + true - + @@ -22,6 +23,9 @@ + + + @@ -41,7 +45,6 @@ - - - + + diff --git a/eng/Versions.props b/eng/Versions.props index b310637..dd076d4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -19,7 +19,6 @@ false true - $([MSBuild]::NormalizeDirectory('$(ArtifactsToolsetDir)', 'ILLink')) $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'ibc')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'docs')) diff --git a/eng/illink.targets b/eng/illink.targets index 44c6adb..924122b0 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -9,8 +9,9 @@ - $(ILLinkDir)netcoreapp2.0/ILLink.Tasks.dll - $(ILLinkDir)net472/ILLink.Tasks.dll + $([MSBuild]::NormalizeDirectory('$(PkgILLink_Tasks)', 'tools')) + $(ILLinkTasksDir)netcoreapp2.0/ILLink.Tasks.dll + $(ILLinkTasksDir)net472/ILLink.Tasks.dll $(IntermediateOutputPath)$(TargetName)$(TargetExt) $(IntermediateOutputPath)$(TargetName).pdb $(IntermediateOutputPath)PreTrim/ diff --git a/eng/restore/illink.targets b/eng/restore/illink.targets deleted file mode 100644 index aa40e2a..0000000 --- a/eng/restore/illink.targets +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - <_illinkSrcFiles Include="$(NuGetPackageRoot)illink.tasks\$(ILLinkTasksVersion)\tools\**\*" /> - - - - - - diff --git a/src/coreclr/src/Directory.Build.targets b/src/coreclr/src/Directory.Build.targets index 9758453..99a2375 100644 --- a/src/coreclr/src/Directory.Build.targets +++ b/src/coreclr/src/Directory.Build.targets @@ -17,4 +17,7 @@ + + + \ No newline at end of file diff --git a/src/coreclr/src/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets b/src/coreclr/src/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets index d5e49b3..9d362c9 100644 --- a/src/coreclr/src/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets +++ b/src/coreclr/src/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets @@ -5,8 +5,7 @@ - <_ILLinkRuntimeRootDescriptorFileName Condition=" '$(_ILLinkRuntimeRootDescriptorFileName)' == '' ">System.Private.CoreLib.xml - <_ILLinkRuntimeRootDescriptorFilePath Condition=" '$(_ILLinkRuntimeRootDescriptorFilePath)' == '' ">$(IntermediateOutputPath)$(_ILLinkRuntimeRootDescriptorFileName) + <_ILLinkRuntimeRootDescriptorFilePath>$(ILLinkTrimXml) <_NamespaceFilePath Condition=" '$(_NamespaceFilePath)' == '' ">$(MSBuildThisFileDirectory)..\vm\namespace.h <_MscorlibFilePath Condition=" '$(_MscorlibFilePath)' == '' ">$(MSBuildThisFileDirectory)..\vm\mscorlib.h <_CortypeFilePath Condition=" '$(_CortypeFilePath)' == '' ">$(MSBuildThisFileDirectory)..\inc\cortypeinfo.h diff --git a/src/coreclr/src/System.Private.CoreLib/ILLink.targets b/src/coreclr/src/System.Private.CoreLib/ILLink.targets deleted file mode 100644 index ccf2cbf..0000000 --- a/src/coreclr/src/System.Private.CoreLib/ILLink.targets +++ /dev/null @@ -1,146 +0,0 @@ - - - - - $(TargetsTriggeredByCompilation); - ILLinkTrimAssembly - - - - - - $(PkgILLink_Tasks)/tools - $(ILLinkTasksToolsDir)/net472/ - $(ILLinkTasksToolsDir)/netcoreapp2.0/ - $(ILLinkTasksDir)ILLink.Tasks.dll - true - $(IntermediateOutputPath)$(TargetName)$(TargetExt) - $(IntermediateOutputPath)$(TargetName).pdb - $(IntermediateOutputPath)PreTrim/ - $(ILLinkTrimInputPath)$(TargetName)$(TargetExt) - $(ILLinkTrimInputPath)$(TargetName).pdb - $(IntermediateOutputPath) - - - true - - - - - - $(BinDir)ILLinkTrimAssembly/$(BuildConfiguration)/trimmed - TrimmedItem - - - $(BinDir)ILLinkTrimAssembly/$(BuildConfiguration)/reports - TrimmingReport - - - $(BinDir)ILLinkTrimAssembly/$(BuildConfiguration)/pretrimmed - PreTrimmedItem - - - - - - - - $(ILLinkArgs)-r $(TargetName) - - $(ILLinkArgs) -c skip - - $(ILLinkArgs) -u skip - - $(ILLinkArgs) -p link $(TargetName) - $(ILLinkArgs) -b true - - $(ILLinkArgs) -v true - - $(ILLinkArgs) --strip-resources false - - $(ILLinkArgs) --disable-opt unusedinterfaces - - - - - - - - - - - - - <_DotNetHostDirectory>$(NetCoreRoot) - <_DotNetHostFileName>dotnet - <_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe - - - - - - - - - - $(AsmDiffArgs) $(ILLinkTrimInputAssembly) - $(AsmDiffArgs) $(ILLinkTrimAssemblyPath) - $(AsmDiffArgs) -includePrivateApis -includeInternalApis -alwaysDiffMembers -diffAttributes - - $(IntermediateOutputPath)$(TargetName).diff.html - $(AsmDiffArgs) -out:$(AsmDiffReport) - $(AsmDiffReportArgs) -unchanged -changed -added -removed - - $(IntermediateOutputPath)$(TargetName).diff.csv - $(AsmDiffArgs) -out:$(AsmDiffList) - $(AsmDiffListArgs) -unchanged -changed -added -removed - $(AsmDiffListArgs) -diffWriter:CSV - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 2915897..307f884 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -1,4 +1,4 @@ - + false @@ -6,8 +6,6 @@ true false false - - Library netcoreapp2.1 @@ -20,6 +18,10 @@ $(BinDir)IL/ Debug;Release;Checked x64;x86;arm;arm64 + + true + true + $(IntermediateOutputPath)System.Private.CoreLib.xml @@ -34,7 +36,6 @@ $(BuildType) $(BuildArch) arm - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9} true false @@ -62,6 +63,7 @@ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)/Documentation true $(OutputPath)$(MSBuildProjectName).xml + false @@ -96,10 +98,6 @@ - System.Private.CoreLib - 5.0.0.0 - true - false $(AssemblyName) @@ -422,54 +420,29 @@ - true - true Windows_NT true - - - $(MSBuildProjectName) - .dll - - - - - $(LibrariesProjectRoot)CodeAnalysis.ruleset - - - - - - - + - - - - - $(MSBuildProjectName).xml - - - - + diff --git a/src/installer/Directory.Build.props b/src/installer/Directory.Build.props index c26b179..d6cda92 100644 --- a/src/installer/Directory.Build.props +++ b/src/installer/Directory.Build.props @@ -3,12 +3,6 @@ - - - @@ -29,9 +23,7 @@ - $(MSBuildThisFileDirectory) $(InstallerProjectRoot)signing\ - $(RepoRoot)LICENSE.TXT @@ -39,19 +31,6 @@ - - core-setup - - - - - true - - - Microsoft.NETCore.App .NETCoreApp $(NETCoreAppFrameworkIdentifier),Version=v$(NETCoreAppFrameworkVersion) @@ -121,8 +100,6 @@ false false false - - https://github.com/dotnet/core-setup diff --git a/src/installer/Directory.Build.targets b/src/installer/Directory.Build.targets index ad077c9..724a3f5 100644 --- a/src/installer/Directory.Build.targets +++ b/src/installer/Directory.Build.targets @@ -19,14 +19,6 @@ - - - $(MajorVersion).$(MinorVersion) - - diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index dd2bcf6..6c3d9c1 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -1,25 +1,10 @@ - - - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), global.json)) - $([MSBuild]::EnsureTrailingSlash('$(RepoRoot)')) - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'eng')) - $(MSBuildThisFileDirectory) - git://github.com/dotnet/corefx - - true - - false - true @@ -80,11 +65,6 @@ package - - - true - - @@ -108,8 +88,6 @@ - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin')) - $([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'native', '$(BuildConfiguration)')) @@ -119,16 +97,14 @@ AnyCPU - Library Open + + + $(IsSourceProject) $(IsSourceProject) $(RepositoryEngineeringDir)DefaultGenApiDocIds.txt - - true - - Properties @@ -247,23 +223,13 @@ - - latest - preview strict;nullablePublicOnly 4 true - true - false - - - true true - - - false + true @@ -332,22 +298,10 @@ $(OutputPath)$(MSBuildProjectName).xml - $(LibrariesProjectRoot)CodeAnalysis.ruleset - false - true - - - true - false - - - false - - true @@ -409,6 +363,4 @@ false true - - diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index 0842649..6b65645 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -7,28 +7,6 @@ - - - - - - $(DefineConstants),INTERNAL_NULLABLE_ATTRIBUTES - - - - - - - - - - false - - 5.0 - + + + + $(DefineConstants),INTERNAL_NULLABLE_ATTRIBUTES + + + + + + + diff --git a/src/libraries/restore/analyzers/analyzers.depproj b/src/libraries/restore/analyzers/analyzers.depproj index ee614d5..75547d7 100644 --- a/src/libraries/restore/analyzers/analyzers.depproj +++ b/src/libraries/restore/analyzers/analyzers.depproj @@ -1,12 +1,10 @@ false + true C# - - -