diff --git a/.gitignore b/.gitignore index befc0d7a24b..500239db4e9 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ dotnet-uninstall-debian-packages.sh *.zip *.rpm *.pkg +*.nupkg # ignore the version file as it is generated at build time powershell.version diff --git a/appveyor.yml b/appveyor.yml index 33bce74b1c9..90497e78fca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.0.0-beta.4-{build} +# version is set in tools\appveyor.psm1 - Invoke-AppVeyorInstall image: Visual Studio 2017 diff --git a/build.psm1 b/build.psm1 index 794894cee01..5e31ad8b1d6 100644 --- a/build.psm1 +++ b/build.psm1 @@ -5,6 +5,90 @@ $script:TestModulePathSeparator = [System.IO.Path]::PathSeparator $dotnetCLIChannel = "preview" $dotnetCLIRequiredVersion = "2.0.0-preview2-006502" +# Track if tags have been sync'ed +$tagsUpToDate = $false + +# Sync Tags +# When not using a branch in PowerShell/PowerShell, tags will not be fetched automatically +# Since code that uses Get-PSCommitID and Get-PSLatestTag assume that tags are fetched, +# This function can ensure that tags have been fetched. +# This function is used during the setup phase in tools/appveyor.psm1 and tools/travis.ps1 +function Sync-PSTags +{ + param( + [Switch] + $AddRemoteIfMissing + ) + + $PowerShellRemoteUrl = "https://github.com/powershell/powershell.git" + $upstreamRemoteDefaultName = 'upstream' + $remotes = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote} + $upstreamRemote = $null + foreach($remote in $remotes) + { + $url = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote get-url $remote} + if($url -eq $PowerShellRemoteUrl) + { + $upstreamRemote = $remote + break + } + } + + if(!$upstreamRemote -and $AddRemoteIfMissing.IsPresent -and $remotes -notcontains $upstreamRemoteDefaultName) + { + $null = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote add $upstreamRemoteDefaultName $PowerShellRemoteUrl} + $upstreamRemote = $upstreamRemoteDefaultName + } + elseif(!$upstreamRemote) + { + Write-Error "Please add a remote to PowerShell\PowerShell. Example: git remote add $upstreamRemoteDefaultName $PowerShellRemoteUrl" -ErrorAction Stop + } + + $null = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" fetch --tags --quiet $upstreamRemote} + $script:tagsUpToDate=$true +} + +# Gets the latest tag for the current branch +function Get-PSLatestTag +{ + # This function won't always return the correct value unless tags have been sync'ed + # So, Write a warning to run Sync-PSTags + if(!$tagsUpToDate) + { + Write-Warning "Run Sync-PSTags to update tags" + } + + return (Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" describe --abbrev=0}) +} + +function Get-PSVersion +{ + param( + [switch] + $OmitCommitId + ) + if($OmitCommitId.IsPresent) + { + return (Get-PSLatestTag) -replace '^v' + } + else + { + return (Get-PSCommitId) -replace '^v' + } +} + +function Get-PSCommitId +{ + # This function won't always return the correct value unless tags have been sync'ed + # So, Write a warning to run Sync-PSTags + if(!$tagsUpToDate) + { + Write-Warning "Run Sync-PSTags to update tags" + } + + return (Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60}) +} + function Get-EnvironmentInformation { $environment = @{} @@ -268,7 +352,7 @@ function Start-PSBuild { $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 = Get-PSCommitId } $gitCommitId > "$psscriptroot/powershell.version" @@ -1934,35 +2018,6 @@ function script:Start-NativeExecution([scriptblock]$sb, [switch]$IgnoreExitcode) } } -# Builds coming out of this project can have version number as 'a.b.c-stringf.d-e-f' OR 'a.b.c.d-e-f' -# This function converts the above version into semantic version major.minor[.build-quality[.revision]] format -function Get-PackageSemanticVersion -{ - [CmdletBinding()] - param ( - # Version of the Package - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] $Version - ) - - Write-Verbose "Extract the semantic version in the form of major.minor[.build-quality[.revision]] for $Version" - $packageVersionTokens = $Version.Split('.') - - if (3 -eq $packageVersionTokens.Count) { - # In case the input is of the form a.b.c, add a '0' at the end for revision field - $packageSemanticVersion = $Version,'0' -join '.' - } elseif (3 -lt $packageVersionTokens.Count) { - # We have all the four fields - $packageRevisionTokens = ($packageVersionTokens[3].Split('-'))[0] - $packageSemanticVersion = $packageVersionTokens[0],$packageVersionTokens[1],$packageVersionTokens[2],$packageRevisionTokens -join '.' - } else { - throw "Cannot create Semantic Version from the string $Version containing 4 or more tokens" - } - - $packageSemanticVersion -} - # Builds coming out of this project can have version number as 'a.b.c' OR 'a.b.c-d-f' # This function converts the above version into major.minor[.build[.revision]] format function Get-PackageVersionAsMajorMinorBuildRevision @@ -2035,8 +2090,10 @@ function New-MSIPackage [Parameter(Mandatory = $true)] [ValidateSet("x86", "x64")] [ValidateNotNullOrEmpty()] - [string] $ProductTargetArchitecture + [string] $ProductTargetArchitecture, + # Force overwrite of package + [Switch] $Force ) ## AppVeyor base image might update the version for Wix. Hence, we should @@ -2095,7 +2152,11 @@ function New-MSIPackage $packageName += "-$ProductNameSuffix" } $msiLocationPath = Join-Path $pwd "$packageName.msi" - Remove-Item -ErrorAction SilentlyContinue $msiLocationPath -Force + + if(!$Force.IsPresent -and (Test-Path -Path $msiLocationPath)) + { + Write-Error -Message "Package already exists, use -Force to overwrite, path: $msiLocationPath" -ErrorAction Stop + } & $wixHeatExePath dir $ProductSourcePath -dr $productVersionWithName -cg $productVersionWithName -gg -sfrag -srd -scom -sreg -out $wixFragmentPath -var env.ProductSourcePath -v | Write-Verbose & $wixCandleExePath "$ProductWxsPath" "$wixFragmentPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch x64 -v | Write-Verbose diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 19e968bcec9..a278922aeb2 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -189,6 +189,13 @@ function Invoke-AppVeyorBuild # Implements the AppVeyor 'install' step function Invoke-AppVeyorInstall { + # Make sure we have all the tags + Sync-PSTags -AddRemoteIfMissing + if($env:APPVEYOR_BUILD_NUMBER) + { + Update-AppveyorBuild -Version "$(Get-PSVersion -OmitCommitId)-$env:APPVEYOR_BUILD_NUMBER" + } + if(Test-DailyBuild){ $buildName = "[Daily]" @@ -434,8 +441,14 @@ function Get-PackageName function Invoke-AppveyorFinish { try { + $packageParams = @{} + if($env:APPVEYOR_BUILD_VERSION) + { + $packageParams += @{Version=$env:APPVEYOR_BUILD_VERSION} + } + # Build packages - $packages = Start-PSPackage + $packages = Start-PSPackage @packageParams $name = Get-PackageName @@ -503,6 +516,12 @@ function Invoke-AppveyorFinish $pushedAllArtifacts = $false Write-Warning "Artifact $_ does not exist." } + + if($env:NUGET_KEY -and $env:NUGET_URL -and [system.io.path]::GetExtension($_) -ieq '.nupkg') + { + log "pushing $_ to $env:NUGET_URL" + Start-NativeExecution -sb {dotnet nuget push $_ --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode + } } if(!$pushedAllArtifacts) { diff --git a/tools/packaging/.gitignore b/tools/packaging/.gitignore new file mode 100644 index 00000000000..df76e550aed --- /dev/null +++ b/tools/packaging/.gitignore @@ -0,0 +1,2 @@ +staging/ +nugetStaging/ diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 0d44a91cda2..bb6351079fe 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -19,13 +19,15 @@ function Start-PSPackage { [string]$Name = "powershell", # Ubuntu, CentOS, Fedora, OS X, and Windows packages are supported - [ValidateSet("deb", "osxpkg", "rpm", "msi", "appx", "zip", "AppImage")] + [ValidateSet("deb", "osxpkg", "rpm", "msi", "appx", "zip", "AppImage", "nupkg")] [string[]]$Type, # Generate windows downlevel package [ValidateSet("win81-x64", "win7-x86", "win7-x64")] [ValidateScript({$Environment.IsWindows})] - [string]$WindowsDownLevel + [string]$WindowsDownLevel, + + [Switch] $Force ) # Runtime and Configuration settings required by the package @@ -34,10 +36,10 @@ function Start-PSPackage { } else { New-PSOptions -Configuration "Release" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration } } - Write-Verbose "Packaging RID: '$Runtime'; Packaging Configuration: '$Configuration'" -Verbose + log "Packaging RID: '$Runtime'; Packaging Configuration: '$Configuration'" $Script:Options = Get-PSOptions - + # Make sure the most recent build satisfies the package requirement if (-not $Script:Options -or ## Start-PSBuild hasn't been executed yet -not $Script:Options.CrossGen -or ## Last build didn't specify -CrossGen @@ -72,26 +74,26 @@ function Start-PSPackage { } $Source = Split-Path -Path $Script:Options.Output -Parent - Write-Verbose "Packaging Source: '$Source'" -Verbose + log "Packaging Source: '$Source'" # Decide package output type if (-not $Type) { $Type = if ($Environment.IsLinux) { if ($Environment.LinuxInfo.ID -match "ubuntu") { - "deb" + "deb", "nupkg" } elseif ($Environment.IsRedHatFamily) { - "rpm" + "rpm", "nupkg" } else { throw "Building packages for $($Environment.LinuxInfo.PRETTY_NAME) is unsupported!" } } elseif ($Environment.IsOSX) { - "osxpkg" + "osxpkg", "nupkg" } elseif ($Environment.IsWindows) { - "msi", "appx" + "msi", "nupkg" } Write-Warning "-Type was not specified, continuing with $Type!" } - Write-Verbose "Packaging Type: $Type" -Verbose + log "Packaging Type: $Type" # Build the name suffix for win-plat packages if ($Environment.IsWindows) { @@ -110,6 +112,7 @@ function Start-PSPackage { PackageNameSuffix = $NameSuffix PackageSourcePath = $Source PackageVersion = $Version + Force = $Force } if($pscmdlet.ShouldProcess("Create Zip Package")) @@ -132,7 +135,8 @@ function Start-PSPackage { LicenseFilePath = "$PSScriptRoot\..\..\assets\license.rtf" # Product Guid needs to be unique for every PowerShell version to allow SxS install ProductGuid = New-Guid - ProductTargetArchitecture = $TargetArchitecture; + ProductTargetArchitecture = $TargetArchitecture + Force = $Force } if($pscmdlet.ShouldProcess("Create MSI Package")) @@ -146,6 +150,7 @@ function Start-PSPackage { PackageSourcePath = $Source PackageVersion = $Version AssetsPath = "$PSScriptRoot\..\..\assets" + Force = $Force } New-AppxPackage @Arguments } @@ -161,12 +166,28 @@ function Start-PSPackage { Write-Warning "Ignoring AppImage type for non Ubuntu Trusty platform" } } + 'nupkg' { + $Arguments = @{ + PackageNameSuffix = $NameSuffix + PackageSourcePath = $Source + PackageVersion = $Version + PackageRuntime = $Runtime + PackageConfiguration = $Configuration + Force = $Force + } + + if($pscmdlet.ShouldProcess("Create NuPkg Package")) + { + New-NugetPackage @Arguments + } + } default { $Arguments = @{ Type = $_ PackageSourcePath = $Source Name = $Name Version = $Version + Force = $Force } if($pscmdlet.ShouldProcess("Create $_ Package")) @@ -197,7 +218,10 @@ function New-UnixPackage { # Package iteration version (rarely changed) # This is a string because strings are appended to it - [string]$Iteration = "1" + [string]$Iteration = "1", + + [Switch] + $Force ) # Validate platform @@ -259,25 +283,8 @@ function New-UnixPackage { # Setup staging directory so we don't change the original source directory $Staging = "$PSScriptRoot/staging" - if($pscmdlet.ShouldProcess("Create staging folder")) - { - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $Staging - Copy-Item -Recurse $PackageSourcePath $Staging - - # Rename files to given name if not "powershell" - if ($Name -ne "powershell") { - $Files = @("powershell", - "powershell.dll", - "powershell.deps.json", - "powershell.pdb", - "powershell.runtimeconfig.json", - "powershell.xml") - - foreach ($File in $Files) { - $NewName = $File -replace "^powershell", $Name - Move-Item "$Staging/$File" "$Staging/$NewName" - } - } + if ($pscmdlet.ShouldProcess("Create staging folder")) { + New-StagingFolder -StagingPath $Staging -Name $Name } # Follow the Filesystem Hierarchy Standard for Linux and OS X @@ -497,13 +504,46 @@ function New-UnixPackage { $newPackageName = "{0}-{1}{2}" -f $packageNameWithoutExt, $script:Options.Runtime, $packageExt $newPackagePath = Join-Path $createdPackage.DirectoryName $newPackageName - $createdPackage = Rename-Item $createdPackage.FullName $newPackagePath -PassThru + $createdPackage = Rename-Item $createdPackage.FullName $newPackagePath -PassThru -Force:$Force } } return $createdPackage } +function New-StagingFolder +{ + param( + [Parameter(Mandatory)] + [string] + $StagingPath, + + # Must start with 'powershell' but may have any suffix + [Parameter(Mandatory)] + [ValidatePattern("^powershell")] + [string] + $Name + ) + + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $StagingPath + Copy-Item -Recurse $PackageSourcePath $StagingPath + + # Rename files to given name if not "powershell" + if ($Name -ne "powershell") { + $Files = @("powershell", + "powershell.dll", + "powershell.deps.json", + "powershell.pdb", + "powershell.runtimeconfig.json", + "powershell.xml") + + foreach ($File in $Files) { + $NewName = $File -replace "^powershell", $Name + Move-Item "$StagingPath/$File" "$StagingPath/$NewName" + } + } +} + # Function to create a zip file for Nano Server and xcopy deployment function New-ZipPackage { @@ -539,6 +579,14 @@ function New-ZipPackage $zipLocationPath = Join-Path $PWD "$zipPackageName.zip" + if($Force.IsPresent) + { + if(Test-Path $zipLocationPath) + { + Remove-Item $zipLocationPath + } + } + If(Get-Command Compress-Archive -ErrorAction Ignore) { if($pscmdlet.ShouldProcess("Create zip package")) @@ -546,7 +594,7 @@ function New-ZipPackage Compress-Archive -Path $PackageSourcePath\* -DestinationPath $zipLocationPath } - Write-Verbose "You can find the Zip @ $zipLocationPath" -Verbose + log "You can find the Zip @ $zipLocationPath" $zipLocationPath } @@ -556,3 +604,192 @@ function New-ZipPackage Write-Error -Message "Compress-Archive cmdlet is missing in this PowerShell version" } } + + +function New-NugetPackage +{ + [CmdletBinding(SupportsShouldProcess=$true)] + param ( + + # Name of the Product + [ValidateNotNullOrEmpty()] + [string] $PackageName = 'PowerShell', + + # Suffix of the Name + [string] $PackageNameSuffix, + + # Version of the Product + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $PackageVersion, + + # Runtime of the Product + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $PackageRuntime, + + # Configuration of the Product + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $PackageConfiguration, + + + # Source Path to the Product Files - required to package the contents into an Zip + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $PackageSourcePath, + + [Switch] + $Force + ) + + log "PackageVersion: $PackageVersion" + $nugetSemanticVersion = Get-NugetSemanticVersion -Version $PackageVersion + log "nugetSemanticVersion: $nugetSemanticVersion" + + $nugetFolder = New-SubFolder -Path $PSScriptRoot -ChildPath 'nugetOutput' -Clean + + + # Setup staging directory so we don't change the original source directory + $stagingRoot = New-SubFolder -Path $PSScriptRoot -ChildPath 'nugetStaging' -Clean + $contentFolder = Join-Path -path $stagingRoot -ChildPath 'content' + if ($pscmdlet.ShouldProcess("Create staging folder")) { + New-StagingFolder -StagingPath $contentFolder -Name $Name + } + + $projectFolder = Join-Path $PSScriptRoot -ChildPath 'project' + + $arguments = @('pack') + $arguments += @('--output',$nugetFolder) + $arguments += @('--configuration',$PackageConfiguration) + $arguments += @('--runtime',$PackageRuntime) + $arguments += "/p:StagingPath=$stagingRoot" + $arguments += "/p:RID=$PackageRuntime" + $arguments += "/p:SemVer=$nugetSemanticVersion" + $arguments += $projectFolder + + log "Running dotnet $arguments" + log "Use -verbose to see output..." + Start-NativeExecution -sb {dotnet $arguments} | Foreach-Object {Write-Verbose $_} + + Get-ChildItem $nugetFolder\* | Select-Object -ExpandProperty FullName +} + +function New-SubFolder +{ + [CmdletBinding(SupportsShouldProcess=$true)] + param( + [string] + $Path, + + [String] + $ChildPath, + + [switch] + $Clean + ) + + $subFolderPath = Join-Path -Path $Path -ChildPath $ChildPath + if($Clean.IsPresent -and (Test-Path $subFolderPath)) + { + Remove-Item -Path $subFolderPath -Recurse -Force -ErrorAction SilentlyContinue + } + + if(!(Test-Path $subFolderPath)) + { + $null = New-Item -Path $subFolderPath -ItemType Directory + } + return $subFolderPath +} + +# Builds coming out of this project can have version number as 'a.b.c-stringf.d-e-f' OR 'a.b.c.d-e-f' +# This function converts the above version into semantic version major.minor[.build-quality[.revision]] format +function Get-PackageSemanticVersion +{ + [CmdletBinding()] + param ( + # Version of the Package + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $Version, + [switch] $NuGet + ) + + Write-Verbose "Extract the semantic version in the form of major.minor[.build-quality[.revision]] for $Version" + $packageVersionTokens = $Version.Split('.') + + if (3 -eq $packageVersionTokens.Count) { + # In case the input is of the form a.b.c, add a '0' at the end for revision field + $packageSemanticVersion = $Version,'0' -join '.' + } elseif (3 -lt $packageVersionTokens.Count) { + # We have all the four fields + $packageRevisionTokens = ($packageVersionTokens[3].Split('-'))[0] + if($NuGet.IsPresent) + { + $packageRevisionTokens = $packageRevisionTokens.Replace('.','-') + } + $packageSemanticVersion = $packageVersionTokens[0],$packageVersionTokens[1],$packageVersionTokens[2],$packageRevisionTokens -join '.' + } else { + throw "Cannot create Semantic Version from the string $Version containing 4 or more tokens" + } + + $packageSemanticVersion +} + +# Builds coming out of this project can have version number as 'a.b.c-stringf.d-e-f' OR 'a.b.c.d-e-f' +# This function converts the above version into semantic version major.minor[.build-quality[-revision]] format needed for nuget +function Get-NugetSemanticVersion +{ + [CmdletBinding()] + param ( + # Version of the Package + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $Version + ) + + $packageVersionTokens = $Version.Split('.') + + Write-Verbose "Extract the semantic version in the form of major.minor[.build-quality[-revision]] for $Version" + $versionPartTokens = @() + $identifierPortionTokens = @() + $inIdentifier = $false + foreach($token in $packageVersionTokens) { + $tokenParts = $null + if($token -match '-') { + $tokenParts = $token.Split('-') + } + elseif($inIdentifier) { + $tokenParts = @($token) + } + + # If we don't have token parts, then it's a versionPart + if(!$tokenParts) { + $versionPartTokens += $token + } + else { + foreach($idToken in $tokenParts) { + # The first token after we detect the id Part is still + # a version part + if(!$inIdentifier) { + $versionPartTokens += $idToken + $inIdentifier = $true + } + else { + $identifierPortionTokens += $idToken + } + } + } + } + + if($versionPartTokens.Count -gt 3) { + throw "Cannot create Semantic Version from the string $Version containing 4 or more version tokens" + } + + $packageSemanticVersion = ($versionPartTokens -join '.') + if($identifierPortionTokens.Count -gt 0) { + $packageSemanticVersion += '-' + ($identifierPortionTokens -join '-') + } + + $packageSemanticVersion +} diff --git a/tools/packaging/project/package.csproj b/tools/packaging/project/package.csproj new file mode 100644 index 00000000000..ab6dc25f8af --- /dev/null +++ b/tools/packaging/project/package.csproj @@ -0,0 +1,16 @@ + + + + NotUsed + PowerShell Core nuget package with .NET CLI host including everything needed to run it. + powershell.nuspec + runtime=$(RID);version=$(SemVer) + $(StagingPath) + True + netcoreapp2.0 + + diff --git a/tools/packaging/project/powershell.nuspec b/tools/packaging/project/powershell.nuspec new file mode 100644 index 00000000000..1694f90bea5 --- /dev/null +++ b/tools/packaging/project/powershell.nuspec @@ -0,0 +1,21 @@ + + + + powershell-$runtime$ + $version$ + PowerShell Core for $runtime$ + PowerShell + PowerShell + false + https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt + https://github.com/powershell/powershell + https://github.com/PowerShell/PowerShell/blob/master/assets/Powershell_64.png + This package contains the PowerShell Core for $runtime$. + Copyright © Microsoft Corporation + PowerShell + + + + + + diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 5fbf65eb483..e9d02787850 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -1,7 +1,6 @@ param( [switch]$Bootstrap ) - Import-Module $PSScriptRoot/../build.psm1 -Force Import-Module $PSScriptRoot/packaging -Force @@ -117,10 +116,13 @@ $isFullBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq if($Bootstrap.IsPresent) { Write-Host -Foreground Green "Executing travis.ps1 -BootStrap `$isPR='$isPr' - $commitMessage" + # Make sure we have all the tags + Sync-PSTags -AddRemoteIfMissing Start-PSBootstrap -Package:(-not $isPr) } else { + $BaseVersion = (Get-PSVersion -OmitCommitId) + '-' Write-Host -Foreground Green "Executing travis.ps1 `$isPR='$isPr' `$isFullBuild='$isFullBuild' - $commitMessage" $output = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions)) @@ -167,9 +169,25 @@ else # Run 'CrossGen' for push commit, so that we can generate package. # It won't rebuild powershell, but only CrossGen the already built assemblies. if (-not $isFullBuild) { Start-PSBuild -CrossGen } + + $packageParams = @{} + if($env:TRAVIS_BUILD_NUMBER) + { + $version = $BaseVersion + $env:TRAVIS_BUILD_NUMBER + $packageParams += @{Version=$version} + } # Only build packages for branches, not pull requests - Start-PSPackage - Start-PSPackage -Type AppImage + $packages = @(Start-PSPackage @packageParams) + $packages += Start-PSPackage @packageParams -Type AppImage + foreach($package in $packages) + { + if($env:NUGET_KEY -and $env:NUGET_URL -and [system.io.path]::GetExtension($package) -ieq '.nupkg') + { + log "pushing $package to $env:NUGET_URL" + Start-NativeExecution -sb {dotnet nuget push $package --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode + } + } + try { # this throws if there was an error Test-PSPesterResults