-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Common.csproj.targets
60 lines (57 loc) · 3.58 KB
/
Common.csproj.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
<Project>
<!-- Determine package versions -->
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<DevVersion Condition="'$(DevVersion)' == ''">0</DevVersion>
<Version>0.0.0-dev$(DevVersion)</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<Version>$(CiBuildVersion)</Version>
</PropertyGroup>
<Target Name="EnsureCiBuildsHaveVersion" BeforeTargets="Build;Pack" Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(CiBuildVersion)' == ''">
<Error Text="ContinuousIntegrationBuild is enabled without specifying version number!" />
</Target>
<!-- Use the informational version (which includes the Git revision) for the package version -->
<Target Name="UseInformationalVersionForPackageVersion" BeforeTargets="GenerateNuspec;_GetOutputItemsFromPack" DependsOnTargets="AddSourceRevisionToInformationalVersion">
<Error Text="SourceRevisionId is missing." Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(SourceRevisionId)' == ''" />
<PropertyGroup>
<PackageVersion>$(InformationalVersion)</PackageVersion>
</PropertyGroup>
</Target>
<!--
These targets generate files which ensure consumers don't unintentionally mix and match package versions since we don't support that.
(None of these packages directly depend on eachother so we can't rely on NuGet to enforce things for us.)
GeneratePackageVersionFile lives here purely for the sake of keeping things in the same place.
-->
<Target Name="GeneratePackageVersionFile" BeforeTargets="GenerateNuspec;_GetPackageFiles;Pack;Build" Condition="'$(MSBuildProjectName)' == 'ClangSharp.Pathogen'">
<PropertyGroup>
<_MsBuildVersionFilePath>$(IntermediateOutputPath)$(PackageId).props</_MsBuildVersionFilePath>
<_MsBuildVersionFilePathContents>
<![CDATA[<Project>
<PropertyGroup>
<ClangSharpPathogenPackageVersion>$(Version)</ClangSharpPathogenPackageVersion>
</PropertyGroup>
</Project>]]>
</_MsBuildVersionFilePathContents>
</PropertyGroup>
<WriteLinesToFile File="$(_MsBuildVersionFilePath)" Overwrite="true" WriteOnlyWhenDifferent="true" Lines="$(_MsBuildVersionFilePathContents)" />
<ItemGroup>
<None Include="$(_MsBuildVersionFilePath)" Pack="true" Visible="false" PackagePath="build;buildTransitive" />
</ItemGroup>
</Target>
<Target Name="GeneratePackageVersionValidationFile" BeforeTargets="GenerateNuspec;_GetPackageFiles;Pack;Build" Condition="'$(MSBuildProjectName)' != 'ClangSharp.Pathogen'">
<PropertyGroup>
<_MsBuildVersionValidationFilePath>$(IntermediateOutputPath)$(PackageId).targets</_MsBuildVersionValidationFilePath>
<_MsBuildVersionValidationFilePathContents>
<![CDATA[<Project>
<Target Name="ValidateClangSharpPathogenVersionIsCompatibleWith$(PackageId.Replace('.', ''))" BeforeTargets="Pack%3BBuild" Condition="'%24(SuppressClangSharpPathogenVersionValidation)' != 'true' and '%24(ClangSharpPathogenPackageVersion)' != '' and '%24(ClangSharpPathogenPackageVersion)' != '$(Version)'">
<Error Text="$(PackageId) $(Version) is not compatible with ClangSharp.Pathogen %24(ClangSharpPathogenPackageVersion)!" />
</Target>
</Project>]]>
</_MsBuildVersionValidationFilePathContents>
</PropertyGroup>
<WriteLinesToFile File="$(_MsBuildVersionValidationFilePath)" Overwrite="true" WriteOnlyWhenDifferent="true" Lines="$(_MsBuildVersionValidationFilePathContents)" />
<ItemGroup>
<None Include="$(_MsBuildVersionValidationFilePath)" Pack="true" Visible="false" PackagePath="build;buildTransitive" />
</ItemGroup>
</Target>
</Project>