generated from thnetii/repository-template-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectory.Build.targets
98 lines (89 loc) · 4.76 KB
/
Directory.Build.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
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Target Name="InitializePublishDirFromSourceControlManager"
DependsOnTargets="InitializeSourceControlInformation"
BeforeTargets="PrepareForPublish">
<ItemGroup>
<_SourceRootReverseOrder Include="@(SourceRoot->HasMetadata('SourceControl')->Reverse())" />
</ItemGroup>
<PropertyGroup>
<PublishDir Condition=" '$(TargetFramework)' == '' AND '$(RuntimeIdentifier)' == ''"
>%(_SourceRootReverseOrder.Identity)publish\$(MSBuildProjectName)\$(Configuration)\</PublishDir>
<PublishDir Condition=" '$(TargetFramework)' != '' AND '$(RuntimeIdentifier)' == ''"
>%(_SourceRootReverseOrder.Identity)publish\$(MSBuildProjectName)\$(Configuration)\$(TargetFramework)\</PublishDir>
<PublishDir Condition=" '$(TargetFramework)' != '' AND '$(RuntimeIdentifier)' != ''"
>%(_SourceRootReverseOrder.Identity)publish\$(MSBuildProjectName)\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
<PublishDir Condition=" '$(TargetFramework)' == '' AND '$(RuntimeIdentifier)' != ''"
>%(_SourceRootReverseOrder.Identity)publish\$(MSBuildProjectName)\$(Configuration)\$(RuntimeIdentifier)\</PublishDir>
</PropertyGroup>
</Target>
<Target Name="AddBuildIdToInformationalVersion"
Condition=" '$(BuildId)' != ''"
DependsOnTargets="GetAssemblyVersion"
BeforeTargets="AddSourceRevisionToInformationalVersion"
>
<PropertyGroup Condition="!(
'$(Configuration)' == 'Release' AND (
$(BuildSourceBranch.StartsWith('refs/heads/rel/')) OR
$(BuildSourceBranch.StartsWith('rel/'))
))">
<!-- Follow SemVer 2.0 rules -->
<_InformationalVersionContainsHyphen>false</_InformationalVersionContainsHyphen>
<_InformationalVersionContainsHyphen Condition="$(InformationalVersion.Contains('-'))">true</_InformationalVersionContainsHyphen>
<InformationalVersion Condition="!$(_InformationalVersionContainsHyphen)">$(InformationalVersion)-build$(BuildId)</InformationalVersion>
<InformationalVersion Condition="$(_InformationalVersionContainsHyphen)">$(InformationalVersion).build$(BuildId)</InformationalVersion>
</PropertyGroup>
</Target>
<Target Name="SetPackageVersionToInformationalVersion"
Condition=" '$(BuildId)' != ''"
DependsOnTargets="AddBuildIdToInformationalVersion"
BeforeTargets="AddSourceRevisionToInformationalVersion"
>
<PropertyGroup>
<PackageVersion>$(InformationalVersion)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="AddBuildIdPropertyToAssemblyVersionAndTruncateFileVersion"
Condition=" '$(BuildId)' != ''"
DependsOnTargets="GetAssemblyVersion"
BeforeTargets="GetAssemblyAttributes"
>
<PropertyGroup>
<FileVersion>$([System.Version]::Parse('$(AssemblyVersion)').ToString(3))</FileVersion>
<AssemblyVersion>$([System.Version]::Parse('$(AssemblyVersion)').ToString(3)).$(BuildId)</AssemblyVersion>
</PropertyGroup>
</Target>
<Target Name="AddSourceRootLicenseFileToNugetPackageOutput"
DependsOnTargets="InitializeSourceControlInformation"
BeforeTargets="_GetPackageFiles;GenerateNuspec"
>
<ItemGroup>
<_SourceRootReverseOrder Include="@(SourceRoot->HasMetadata('SourceControl')->Reverse())" />
</ItemGroup>
<PropertyGroup>
<_SourceRootLicenseFilePath>%(_SourceRootReverseOrder.Identity)LICENSE</_SourceRootLicenseFilePath>
</PropertyGroup>
<PropertyGroup Condition="Exists('$(_SourceRootLicenseFilePath)')">
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup Condition="Exists('$(_SourceRootLicenseFilePath)')">
<None Include="$(_SourceRootLicenseFilePath)" Pack="true">
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Target>
<PropertyGroup>
<GenerateNuspecDependsOn>InferProjectUrlFromGitHubRepositoryUrl;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
</PropertyGroup>
<Target Name="InferProjectUrlFromGitHubRepositoryUrl"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
<PropertyGroup Condition="
'$(RepositoryUrl)' == '' and
'$(PublishRepositoryUrl)' == 'true'
">
<PackageProjectUrl Condition=" $(PrivateRepositoryUrl.EndsWith('.git'))">$(PrivateRepositoryUrl.Substring(0, $(PrivateRepositoryUrl.LastIndexOf('.git'))))</PackageProjectUrl>
<PackageProjectUrl Condition="!$(PrivateRepositoryUrl.EndsWith('.git'))">$(PrivateRepositoryUrl)</PackageProjectUrl>
</PropertyGroup>
</Target>
</Project>