forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerShell.Common.props
151 lines (128 loc) · 7.41 KB
/
PowerShell.Common.props
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
The 'version' property is populated with the default value in 'Microsoft.NET.DefaultAssemblyInfo.targets'
*before* any targets get a chance to execute.
We need to *explicitly* re-assign the 'version' property and other version tags in this target.
In order for the versions assigned here to take effect, we need to execute this target at an early stage:
before 'Restore' target - '_GenerateRestoreProjectSpec'
before 'Pack' target - 'GenerateNuspec'
before 'Build' target - 'BeforeBuild'
-->
<Target Name="GetPSCoreVersionFromGit"
BeforeTargets="_GenerateRestoreProjectSpec;GenerateNuspec;BeforeBuild"
>
<Exec Command='git describe --abbrev=60 --long'
WorkingDirectory="$(MSBuildProjectDirectory)"
ConsoleToMSBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="PowerShellVersion" />
</Exec>
<PropertyGroup Condition = "'$(ReleaseTag)' != ''">
<PSCoreBuildVersion>$(ReleaseTag)</PSCoreBuildVersion>
</PropertyGroup>
<PropertyGroup>
<RegexGitVersion>^v(.+)-(\d+)-g(.+)</RegexGitVersion>
<PSCoreBuildVersion Condition = "'$(PSCoreBuildVersion)' == ''">$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[1].Value)</PSCoreBuildVersion>
<PSCoreAdditionalCommits>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value)</PSCoreAdditionalCommits>
<PSCoreCommitSHA>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value)</PSCoreCommitSHA>
<!--
Caution! 'PSVersion' and 'GitCommitId' from 'PSVersionInfo.cs' depend on the format of this version string.
-->
<PSCoreFormattedVersion Condition = "'$(ReleaseTag)' != '' or '$(PSCoreAdditionalCommits)' == '0'">$(PSCoreBuildVersion) SHA: $(PSCoreCommitSHA)</PSCoreFormattedVersion>
<PSCoreFormattedVersion Condition = "'$(PSCoreFormattedVersion)' == ''">$(PSCoreBuildVersion) Commits: $(PSCoreAdditionalCommits) SHA: $(PSCoreCommitSHA)</PSCoreFormattedVersion>
<!-- Extract the major, minor and patch version numbers, as well as the preview label.
They are currently not used anywhere, so we comment them out for now.
<RegexSymVer>^((\d+).(\d+).(\d+))(?:-(.+))?</RegexSymVer>
<PSCorePrefixVersion>$([System.Text.RegularExpressions.Regex]::Match($(PSCoreBuildVersion), $(RegexSymVer)).Groups[1].Value)</PSCorePrefixVersion>
<PSCoreMajorVersion>$([System.Text.RegularExpressions.Regex]::Match($(PSCoreBuildVersion), $(RegexSymVer)).Groups[2].Value)</PSCoreMajorVersion>
<PSCoreMinorVersion>$([System.Text.RegularExpressions.Regex]::Match($(PSCoreBuildVersion), $(RegexSymVer)).Groups[3].Value)</PSCoreMinorVersion>
<PSCorePatchVersion>$([System.Text.RegularExpressions.Regex]::Match($(PSCoreBuildVersion), $(RegexSymVer)).Groups[4].Value)</PSCorePatchVersion>
<PSCoreLabelVersion>$([System.Text.RegularExpressions.Regex]::Match($(PSCoreBuildVersion), $(RegexSymVer)).Groups[5].Value)</PSCoreLabelVersion>
-->
<!--
Here we define explicitly 'Version' to set 'FileVersion' and 'AssemblyVersion' by 'GetAssemblyVersion' target in 'Microsoft.NET.GenerateAssemblyInfo.targets'.
Here we define explicitly 'InformationalVersion' because by default it is defined as 'Version' by 'GetAssemblyVersion' target in 'Microsoft.NET.GenerateAssemblyInfo.targets'.
-->
<Version>$(PSCoreBuildVersion)</Version>
<InformationalVersion>$(PSCoreFormattedVersion)</InformationalVersion>
<ProductVersion>$(PSCoreFormattedVersion)</ProductVersion>
<!--
We have explicitly assign 'PackageVersion'
because there is a bug: 'PackageVersion' is correctly assigned as 'Version' in 'NuGet.targets'
but then immediately redefined as '1.0.0'.
Tracking Issue https://github.com/dotnet/sdk/issues/1557
-->
<PackageVersion>$(PSCoreBuildVersion)</PackageVersion>
</PropertyGroup>
<!-- Output For Debugging
<WriteLinesToFile File="targetfile1.txt"
Lines="ReleaseTag=$(ReleaseTag);
PowerShellVersion=$(PowerShellVersion);
PSCoreBuildVersion = $(PSCoreBuildVersion);
PSCoreAdditionalCommits = $(PSCoreAdditionalCommits);
PSCoreCommitSHA = $(PSCoreCommitSHA);
PSCoreMajorVersion = $(PSCoreMajorVersion);
PSCoreMinorVersion = $(PSCoreMinorVersion);
PSCorePatchVersion = $(PSCorePatchVersion);
PSCoreLabelVersion = $(PSCoreLabelVersion);
RegexGitVersion = $(RegexGitVersion);
PSCoreFormattedVersion = $(PSCoreFormattedVersion);
ProductVersion = $(ProductVersion);
Version = $(Version);
ProjectVersion = '!$(ProjectVersion)!'
InformationalVersion = $(InformationalVersion);
"
Overwrite="true" />
-->
</Target>
<PropertyGroup>
<Product>PowerShell Core</Product>
<Company>Microsoft Corporation</Company>
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.8</RuntimeFrameworkVersion>
<LangVersion>Latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NeutralLanguage>en-US</NeutralLanguage>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>../signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<HighEntropyVA>true</HighEntropyVA>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>
<!-- Define non-windows, all configuration properties -->
<PropertyGroup Condition=" '$(IsWindows)' != 'true' ">
<DefineConstants>$(DefineConstants);UNIX</DefineConstants>
</PropertyGroup>
<!-- Define all OS, debug configuration properties -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>portable</DebugType>
</PropertyGroup>
<!-- Define all OS, release configuration properties -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>true</Optimize>
</PropertyGroup>
<!-- Define windows, release configuration properties -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release' And '$(IsWindows)' == 'true' ">
<Optimize>true</Optimize>
<DebugType>full</DebugType>
</PropertyGroup>
<!-- Define non-windows, release configuration properties -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release' And '$(IsWindows)' != 'true' ">
<!-- Set-Date fails with optimize enabled in NonWindowsSetDate
Debugging the issues resolves the problem
-->
<Optimize>false</Optimize>
<DebugType>portable</DebugType>
</PropertyGroup>
<!-- Define all OS, CodeCoverage configuration properties -->
<PropertyGroup Condition=" '$(Configuration)' == 'CodeCoverage' ">
<DebugType>full</DebugType>
</PropertyGroup>
</Project>