forked from dotnet/roslyn-analyzers
/
GenerateAnalyzerNuspec.targets
105 lines (91 loc) · 6.87 KB
/
GenerateAnalyzerNuspec.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup>
<NuspecFile>$(IntermediateOutputPath)$(NuspecPackageId).nuspec</NuspecFile>
<NuspecBasePath>$(ArtifactsBinDir)</NuspecBasePath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<!--
Projects in this directory do not produce useful binaries, they are only used to generate packages.
-->
<PropertyGroup>
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PackageLicenseExpression Condition="'$(PackageLicenseExpression)' == ''">Apache-2.0</PackageLicenseExpression>
</PropertyGroup>
<Target Name="GenerateAnalyzerRulesets"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'@(AnalyzerNupkgAssembly)' != '' or '@(AnalyzerRulesetAssembly)' != ''">
<PropertyGroup>
<_GeneratedRulesetsDir>$(IntermediateOutputPath)Rulesets</_GeneratedRulesetsDir>
<_GeneratedEditorconfigsDir>$(IntermediateOutputPath)Editorconfig</_GeneratedEditorconfigsDir>
<ContainsPortedFxCopRules Condition="'$(ContainsPortedFxCopRules)' == ''">false</ContainsPortedFxCopRules>
<GeneratePackagePropsFile Condition="'$(GeneratePackagePropsFile)' == ''">true</GeneratePackagePropsFile>
<DevelopmentDependency Condition="'@(AnalyzerNupkgAssembly)' != '' or '@(AnalyzerNupkgDependency)' != ''">true</DevelopmentDependency>
<GenerateAnalyzerMdFile Condition="'$(GenerateAnalyzerMdFile)' == ''">true</GenerateAnalyzerMdFile>
<GenerateAnalyzerSarifFile Condition="'$(GenerateAnalyzerSarifFile)' == ''">true</GenerateAnalyzerSarifFile>
<GenerateAnalyzerConfigurationFile Condition="'$(GenerateAnalyzerConfigurationFile)' == ''">true</GenerateAnalyzerConfigurationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(GeneratePackagePropsFile)' == 'true'">
<PackagePropsFileDir>$(IntermediateOutputPath)Build</PackagePropsFileDir>
<PackagePropsFileName>$(NuspecPackageId).props</PackagePropsFileName>
</PropertyGroup>
<ItemGroup Condition="'$(GeneratePackagePropsFile)' == 'true'" >
<AnalyzerNupkgFile Include="$(PackagePropsFileDir)\$(PackagePropsFileName)"/>
</ItemGroup>
<PropertyGroup Condition="'$(GenerateAnalyzerMdFile)' == 'true'">
<AnalyzerDocumentationFileDir Condition="'$(AnalyzerDocumentationFileDir)' == ''">$(RepoRoot)src\$(NuspecPackageId)</AnalyzerDocumentationFileDir>
<AnalyzerDocumentationFileName>$(NuspecPackageId).md</AnalyzerDocumentationFileName>
</PropertyGroup>
<PropertyGroup Condition="'$(GenerateAnalyzerSarifFile)' == 'true'">
<AnalyzerSarifFileDir Condition="'$(AnalyzerSarifFileDir)' == ''">$(RepoRoot)src\$(NuspecPackageId)</AnalyzerSarifFileDir>
<AnalyzerSarifFileName>$(NuspecPackageId).sarif</AnalyzerSarifFileName>
</PropertyGroup>
<PropertyGroup Condition="'$(GenerateAnalyzerConfigurationFile)' == 'true'">
<AnalyzerConfigurationFileDir>$(RepoRoot)docs</AnalyzerConfigurationFileDir>
<AnalyzerConfigurationFileName>Analyzer Configuration.md</AnalyzerConfigurationFileName>
</PropertyGroup>
<MSBuild Projects="$(RepoRoot)src\GenerateAnalyzerRulesets\GenerateAnalyzerRulesets.csproj" Targets="Build">
<Output TaskParameter="TargetOutputs" PropertyName="_GenerateAnalyzerRulesetsPath"/>
</MSBuild>
<ItemGroup>
<AnalyzerRulesetAssembly Condition="'@(AnalyzerNupkgAssembly)' != '' and '@(AnalyzerRulesetAssembly)' == ''" Include="@(AnalyzerNupkgAssembly)"/>
</ItemGroup>
<Exec Command='"$(DotNetRoot)dotnet.exe" "$(_GenerateAnalyzerRulesetsPath)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "$(ArtifactsBinDir)\" "$(Configuration)" "$(TargetFramework)" "@(AnalyzerRulesetAssembly)" "$(PackagePropsFileDir)" "$(PackagePropsFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(VersionPrefix)" $(NuspecPackageId) $(ContainsPortedFxCopRules)' />
</Target>
<Target Name="GenerateAnalyzerNuspecFile"
BeforeTargets="GenerateNuspec"
DependsOnTargets="InitializeSourceControlInformation;GenerateAnalyzerRulesets"
Condition="'@(AnalyzerNupkgFile)' != '' or '@(AnalyzerNupkgFolder)' != '' or '@(AnalyzerNupkgAssembly)' != '' or '@(AnalyzerNupkgDependency)' != '' or '@(AnalyzerNupkgLibrary)' != ''">
<ItemGroup>
<_NuspecMetadata Include="version=$(PackageVersion)" />
<_NuspecMetadata Include="id=$(NuspecPackageId)" />
<_NuspecMetadata Include="authors=$(Authors)" />
<_NuspecMetadata Include="owners=$(Authors)" />
<_NuspecMetadata Include="requireLicenseAcceptance=$(PackageRequireLicenseAcceptance)" />
<_NuspecMetadata Include="description=$(Description)" />
<_NuspecMetadata Include="copyright=$(Copyright)" />
<_NuspecMetadata Include="license=$(PackageLicenseExpression)" />
<_NuspecMetadata Include="projectUrl=$(PackageProjectUrl)" />
<_NuspecMetadata Include="iconUrl=$(PackageIconUrl)" />
<_NuspecMetadata Include="releaseNotes=$(PackageReleaseNotes)" />
<_NuspecMetadata Include="tags=$(PackageTags)" />
<_NuspecMetadata Include="serviceable=$(Serviceable)" />
<_NuspecMetadata Include="developmentDependency=$(DevelopmentDependency)" />
<_NuspecMetadata Include="repositoryType=$(RepositoryType)" />
<_NuspecMetadata Include="repositoryCommit=$(SourceRevisionId)" />
<_NuspecMetadata Include="repositoryUrl=$(PrivateRepositoryUrl)" />
</ItemGroup>
<PropertyGroup>
<_CscToolPath>$(RoslynTargetsPath)</_CscToolPath>
<_CscToolPath Condition="'$(_CscToolPath)' == ''">$(CscToolPath)</_CscToolPath>
<_CscToolPath Condition="'$(_CscToolPath)' == ''">$(MSBuildBinPath)\Roslyn</_CscToolPath>
<_CscToolPath Condition="!HasTrailingSlash('$(_CscToolPath)')">$(_CscToolPath)\</_CscToolPath>
</PropertyGroup>
<Exec Command='"$(_CscToolPath)csi.exe" "$(RepoRoot)eng\GenerateAnalyzerNuspec.csx" "$(NuspecFile)" "$(AssetsDir)\" "$(MSBuildProjectDirectory)" "$(Configuration)" "$(TargetFramework)" "@(_NuspecMetadata)" "@(AnalyzerNupkgFile)" "@(AnalyzerNupkgFolder)" "@(AnalyzerNupkgAssembly)" "@(AnalyzerNupkgDependency)" "@(AnalyzerNupkgLibrary)" "$(_GeneratedRulesetsDir)" "$(_GeneratedEditorconfigsDir)" "@(AnalyzerLegacyRuleset)" "$(ArtifactsBinDir)\" "$(AnalyzerDocumentationFileDir)" "$(AnalyzerDocumentationFileName)" "$(AnalyzerSarifFileDir)" "$(AnalyzerSarifFileName)" "$(AnalyzerConfigurationFileDir)" "$(AnalyzerConfigurationFileName)"' />
</Target>
</Project>