Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ function Start-PSBuild {
[switch]$Publish,

[Parameter(ParameterSetName='CoreCLR')]
[switch]$CrossGen
[switch]$CrossGen,

[Parameter(ParameterSetName='CoreCLR')]
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag
)

function Stop-DevPowerShell {
Expand Down Expand Up @@ -157,8 +162,13 @@ function Start-PSBuild {
}
}

# save Git description to file for PowerShell to include in PSVersionTable
git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60 > "$psscriptroot/powershell.version"
# save git commit id to file for PowerShell to include in PSVersionTable
$gitCommitId = $ReleaseTag
if (-not $gitCommitId) {
# if ReleaseTag is not specified, use 'git describe' to get the commit id
$gitCommitId = git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60
}
$gitCommitId > "$psscriptroot/powershell.version"

# create the telemetry flag file
$null = new-item -force -type file "$psscriptroot/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY"
Expand Down Expand Up @@ -1206,8 +1216,14 @@ function Start-PSBootstrap {
function Start-PSPackage {
[CmdletBinding()]param(
# PowerShell packages use Semantic Versioning http://semver.org/
[Parameter(ParameterSetName = "Version")]
[string]$Version,

[Parameter(ParameterSetName = "ReleaseTag")]
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag,

# Package name
[ValidatePattern("^powershell")]
[string]$Name = "powershell",
Expand Down Expand Up @@ -1253,6 +1269,11 @@ function Start-PSPackage {
throw "Please ensure you have run 'Start-PSBuild -Clean -CrossGen -Runtime $Runtime -Configuration $Configuration'!"
}

# If ReleaseTag is specified, use the given tag to calculate Vesrion
if ($PSCmdlet.ParameterSetName -eq "ReleaseTag") {
$Version = $ReleaseTag -Replace '^v'
}

# Use Git tag if not given a version
if (-not $Version) {
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'
Expand Down