|
| 1 | +From fed5a94a2b5a39d227b9337c22d5ac2f91288904 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Omair Majid < [email protected]> |
| 3 | +Date: Tue, 17 Nov 2020 19:14:37 -0500 |
| 4 | +Subject: [PATCH] Fix ./build.sh --pack to work on Linux |
| 5 | + |
| 6 | +There's no csi.exe in the .NET 5 (or .NET Core) SDK. So move away from |
| 7 | +a csx script to a full-blown tool written in C#. |
| 8 | + |
| 9 | +For ease of review, I have kept the original tool code unmodified (not |
| 10 | +even indentation has been fixed). To work around build warnings/errors, |
| 11 | +disable the warnings. |
| 12 | + |
| 13 | +Also fix the case of path to the dll in the local nuget cache. It |
| 14 | +doesn't matter on Windows, but most file systems on Linux are |
| 15 | +case-sensitive. |
| 16 | +--- |
| 17 | + eng/GenerateAnalyzerNuspec.targets | 23 +++++++++++-------- |
| 18 | + ...osoft.CodeQuality.Analyzers.Package.csproj | 4 ++-- |
| 19 | + .../GenerateAnalyzerNuspec.csproj | 7 ++++++ |
| 20 | + .../Tools/GenerateAnalyzerNuspec/Program.cs | 19 +++++++++++++-- |
| 21 | + 4 files changed, 39 insertions(+), 14 deletions(-) |
| 22 | + create mode 100644 src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj |
| 23 | + rename eng/GenerateAnalyzerNuspec.csx => src/Tools/GenerateAnalyzerNuspec/Program.cs (96%) |
| 24 | + |
| 25 | +diff --git a/eng/GenerateAnalyzerNuspec.targets b/eng/GenerateAnalyzerNuspec.targets |
| 26 | +index 9b90519cf..74244690a 100644 |
| 27 | +--- a/eng/GenerateAnalyzerNuspec.targets |
| 28 | ++++ b/eng/GenerateAnalyzerNuspec.targets |
| 29 | +@@ -22,6 +22,12 @@ |
| 30 | + <PackageLicenseExpression Condition="'$(PackageLicenseExpression)' == ''">Apache-2.0</PackageLicenseExpression> |
| 31 | + </PropertyGroup> |
| 32 | + |
| 33 | ++ <PropertyGroup> |
| 34 | ++ <DotNetExecutable Condition="'$(OS)' == 'Windows_NT'">$(DotNetRoot)dotnet.exe</DotNetExecutable> |
| 35 | ++ <DotNetExecutable Condition="'$(DotNetExecutable)' == ''">$(DotNetRoot)dotnet</DotNetExecutable> |
| 36 | ++ <EscapeDirectorySuffix Condition="'$(OS)' == 'Windows_NT'">\</EscapeDirectorySuffix> |
| 37 | ++ </PropertyGroup> |
| 38 | ++ |
| 39 | + <Target Name="GenerateAnalyzerConfigAndDocumentationFiles" |
| 40 | + DependsOnTargets="InitializeSourceControlInformation" |
| 41 | + Condition="'@(AnalyzerNupkgAssembly)' != '' or '@(AnalyzerRulesetAssembly)' != ''"> |
| 42 | +@@ -88,13 +88,13 @@ |
| 43 | + <AnalyzerRulesetAssembly Condition="'@(AnalyzerNupkgAssembly)' != '' and '@(AnalyzerRulesetAssembly)' == ''" Include="@(AnalyzerNupkgAssembly)"/> |
| 44 | + <AnalyzerRulesetAssembly Update="@(AnalyzerRulesetAssembly)" Condition="'%(AnalyzerRulesetAssembly.TargetFramework)' == ''" TargetFramework="$(TargetFramework)" /> |
| 45 | + </ItemGroup> |
| 46 | +- <Exec Command='"$(DotNetRoot)dotnet.exe" "$(_GenerateDocumentationAndConfigFilesPath)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "$(ArtifactsBinDir)\" "$(Configuration)" "%(AnalyzerRulesetAssembly.TargetFramework)" "@(AnalyzerRulesetAssembly)" "$(PackagePropsFileDir)" "$(PackagePropsFileName)" "$(DisableNETAnalyzersPackagePropsFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(VersionPrefix)" $(NuspecPackageId) $(ContainsPortedFxCopRules) $(GenerateAnalyzerRulesMissingDocumentationFile)' /> |
| 47 | ++ <Exec Command='"$(DotNetExecutable)" "$(_GenerateDocumentationAndConfigFilesPath)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "$(ArtifactsBinDir)$(EscapeDirectorySuffix)" "$(Configuration)" "%(AnalyzerRulesetAssembly.TargetFramework)" "@(AnalyzerRulesetAssembly)" "$(PackagePropsFileDir)" "$(PackagePropsFileName)" "$(DisableNETAnalyzersPackagePropsFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(VersionPrefix)" $(NuspecPackageId) $(ContainsPortedFxCopRules) $(GenerateAnalyzerRulesMissingDocumentationFile)' /> |
| 48 | + |
| 49 | + <MSBuild Projects="$(RepoRoot)src\Tools\GenerateGlobalAnalyzerConfigs\GenerateGlobalAnalyzerConfigs.csproj" Targets="Build"> |
| 50 | + <Output TaskParameter="TargetOutputs" PropertyName="_GenerateGlobalAnalyzerConfigsPath"/> |
| 51 | + </MSBuild> |
| 52 | + |
| 53 | +- <Exec Command='"$(DotNetRoot)dotnet.exe" "$(_GenerateGlobalAnalyzerConfigsPath)" "$(_GeneratedGlobalAnalyzerConfigsDir)" "$(NuspecPackageId)" "$(PackageTargetsFileDir)" "$(PackageTargetsFileName)" "@(AnalyzerRulesetAssembly)" "$(ArtifactsBinDir)\" "$(Configuration)" "%(AnalyzerRulesetAssembly.TargetFramework)" "$(ReleaseTrackingOptOut)"' /> |
| 54 | ++ <Exec Command='"$(DotNetExecutable)" "$(_GenerateGlobalAnalyzerConfigsPath)" "$(_GeneratedGlobalAnalyzerConfigsDir)" "$(NuspecPackageId)" "$(PackageTargetsFileDir)" "$(PackageTargetsFileName)" "@(AnalyzerRulesetAssembly)" "$(ArtifactsBinDir)$(EscapeDirectorySuffix)" "$(Configuration)" "%(AnalyzerRulesetAssembly.TargetFramework)" "$(ReleaseTrackingOptOut)"' /> |
| 55 | + |
| 56 | + <ItemGroup Condition="Exists('$(PackageTargetsFileDir)\$(PackageTargetsFileName)')"> |
| 57 | + <AnalyzerNupkgFile Include="$(PackageTargetsFileDir)\$(PackageTargetsFileName)"/> |
| 58 | +@@ -131,13 +137,10 @@ |
| 59 | + <_NuspecMetadata Include="repositoryUrl=$(PrivateRepositoryUrl)" /> |
| 60 | + </ItemGroup> |
| 61 | + |
| 62 | +- <PropertyGroup> |
| 63 | +- <_CscToolPath>$(RoslynTargetsPath)</_CscToolPath> |
| 64 | +- <_CscToolPath Condition="'$(_CscToolPath)' == ''">$(CscToolPath)</_CscToolPath> |
| 65 | +- <_CscToolPath Condition="'$(_CscToolPath)' == ''">$(MSBuildBinPath)\Roslyn</_CscToolPath> |
| 66 | +- <_CscToolPath Condition="!HasTrailingSlash('$(_CscToolPath)')">$(_CscToolPath)\</_CscToolPath> |
| 67 | +- </PropertyGroup> |
| 68 | ++ <MSBuild Projects="$(RepoRoot)src\Tools\GenerateAnalyzerNuspec\GenerateAnalyzerNuspec.csproj" Targets="Restore;Build"> |
| 69 | ++ <Output TaskParameter="TargetOutputs" PropertyName="_GenerateAnalyzerNuspecPath"/> |
| 70 | ++ </MSBuild> |
| 71 | + |
| 72 | +- <Exec Command='"$(_CscToolPath)csi.exe" "$(RepoRoot)eng\GenerateAnalyzerNuspec.csx" "$(NuspecFile)" "$(AssetsDir)\" "$(MSBuildProjectDirectory)" "$(Configuration)" "$(TargetFrameworksForPackage)" "@(_NuspecMetadata)" "@(AnalyzerNupkgFile)" "@(AnalyzerNupkgFolder)" "@(AnalyzerNupkgAssembly)" "@(AnalyzerNupkgDependency)" "@(AnalyzerNupkgLibrary)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "@(AnalyzerLegacyRuleset)" "$(ArtifactsBinDir)\" "$(AnalyzerDocumentationFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(AnalyzerConfigurationFileDir)" "$(AnalyzerConfigurationFileName)" "$(_GeneratedGlobalAnalyzerConfigsDir)"' /> |
| 73 | ++ <Exec Command='"$(DotNetExecutable)" "$(_GenerateAnalyzerNuspecPath)" "$(NuspecFile)" "$(AssetsDir)$(EscapeDirectorySuffix)" "$(MSBuildProjectDirectory)" "$(Configuration)" "$(TargetFrameworksForPackage)" "@(_NuspecMetadata)" "@(AnalyzerNupkgFile)" "@(AnalyzerNupkgFolder)" "@(AnalyzerNupkgAssembly)" "@(AnalyzerNupkgDependency)" "@(AnalyzerNupkgLibrary)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "@(AnalyzerLegacyRuleset)" "$(ArtifactsBinDir)$(EscapeDirectorySuffix)" "$(AnalyzerDocumentationFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(AnalyzerConfigurationFileDir)" "$(AnalyzerConfigurationFileName)" "$(_GeneratedGlobalAnalyzerConfigsDir)"' /> |
| 74 | + </Target> |
| 75 | +-</Project> |
| 76 | +\ No newline at end of file |
| 77 | ++</Project> |
| 78 | +diff --git a/nuget/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.Package.csproj b/nuget/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.Package.csproj |
| 79 | +index 397f6484c..65728e66a 100644 |
| 80 | +--- a/nuget/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.Package.csproj |
| 81 | ++++ b/nuget/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.Package.csproj |
| 82 | +@@ -18,7 +18,7 @@ |
| 83 | + <AnalyzerNupkgAssembly Include="Microsoft.CodeQuality.Analyzers.dll" /> |
| 84 | + <AnalyzerNupkgAssembly Include="Microsoft.CodeQuality.CSharp.Analyzers.dll" /> |
| 85 | + <AnalyzerNupkgAssembly Include="Microsoft.CodeQuality.VisualBasic.Analyzers.dll" /> |
| 86 | +- <AnalyzerNupkgAssembly Include="$(NuGetPackageRoot)Humanizer.Core\$(HumanizerVersion)\lib\netstandard1.0\Humanizer.dll" /> |
| 87 | ++ <AnalyzerNupkgAssembly Include="$(NuGetPackageRoot)humanizer.core\$(HumanizerVersion)\lib\netstandard1.0\Humanizer.dll" /> |
| 88 | + </ItemGroup> |
| 89 | + |
| 90 | + <ItemGroup> |
| 91 | +@@ -26,4 +26,4 @@ |
| 92 | + <ProjectReference Include="..\..\src\NetAnalyzers\CSharp\Microsoft.CodeQuality.Analyzers\Microsoft.CodeQuality.CSharp.Analyzers.csproj" /> |
| 93 | + <ProjectReference Include="..\..\src\NetAnalyzers\VisualBasic\Microsoft.CodeQuality.Analyzers\Microsoft.CodeQuality.VisualBasic.Analyzers.vbproj" /> |
| 94 | + </ItemGroup> |
| 95 | +-</Project> |
| 96 | +\ No newline at end of file |
| 97 | ++</Project> |
| 98 | +diff --git a/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj b/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj |
| 99 | +new file mode 100644 |
| 100 | +index 000000000..42b47952b |
| 101 | +--- /dev/null |
| 102 | ++++ b/src/Tools/GenerateAnalyzerNuspec/GenerateAnalyzerNuspec.csproj |
| 103 | +@@ -0,0 +1,7 @@ |
| 104 | ++<Project Sdk="Microsoft.NET.Sdk"> |
| 105 | ++ <PropertyGroup> |
| 106 | ++ <OutputType>Exe</OutputType> |
| 107 | ++ <TargetFramework>netcoreapp3.1</TargetFramework> |
| 108 | ++ <NonShipping>true</NonShipping> |
| 109 | ++ </PropertyGroup> |
| 110 | ++</Project> |
| 111 | +diff --git a/eng/GenerateAnalyzerNuspec.csx b/src/Tools/GenerateAnalyzerNuspec/Program.cs |
| 112 | +similarity index 96% |
| 113 | +rename from eng/GenerateAnalyzerNuspec.csx |
| 114 | +rename to src/Tools/GenerateAnalyzerNuspec/Program.cs |
| 115 | +index 1d40d0096..5ca8fbfcc 100644 |
| 116 | +--- a/eng/GenerateAnalyzerNuspec.csx |
| 117 | ++++ b/src/Tools/GenerateAnalyzerNuspec/Program.cs |
| 118 | +@@ -1,5 +1,17 @@ |
| 119 | +-using System.Diagnostics; |
| 120 | ++#pragma warning disable CA1820, CS8600, IDE0055, IDE0057, IDE0062, IDE0078, IDE0073 |
| 121 | ++ |
| 122 | ++using System; |
| 123 | ++using System.Collections.Generic; |
| 124 | + using System.IO; |
| 125 | ++using System.Linq; |
| 126 | ++using System.Text; |
| 127 | ++ |
| 128 | ++namespace GenerateAnalyzerNuspec |
| 129 | ++{ |
| 130 | ++ public static class Program |
| 131 | ++ { |
| 132 | ++ public static void Main(string[] Args) |
| 133 | ++ { |
| 134 | + |
| 135 | + string nuspecFile = Args[0]; |
| 136 | + string assetsDir = Args[1]; |
| 137 | +@@ -280,4 +292,7 @@ |
| 138 | + |
| 139 | + result.AppendLine(@"</package>"); |
| 140 | + |
| 141 | +-File.WriteAllText(nuspecFile, result.ToString()); |
| 142 | +\ No newline at end of file |
| 143 | ++File.WriteAllText(nuspecFile, result.ToString()); |
| 144 | ++ } |
| 145 | ++ } |
| 146 | ++} |
| 147 | +-- |
| 148 | +2.26.2 |
| 149 | + |
0 commit comments