diff --git a/docker/release/nanoserver/Dockerfile b/docker/release/nanoserver/Dockerfile index 39c5e321a7e..ed500cb3496 100755 --- a/docker/release/nanoserver/Dockerfile +++ b/docker/release/nanoserver/Dockerfile @@ -16,7 +16,7 @@ ENV PS_DOWNLOAD_URL https://github.com/PowerShell/PowerShell/releases/download/v SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -RUN if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+\.\d+)?$' )) {throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+\.\d+)?$"' -f $env:PS_VERSION)} +RUN if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) {throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION)} RUN Invoke-WebRequest $Env:PS_DOWNLOAD_URL -OutFile powershell.zip RUN Expand-Archive powershell.zip -DestinationPath \PowerShell diff --git a/docker/tests/container.tests.ps1 b/docker/tests/container.tests.ps1 index ea6a694bb74..591144b4a5f 100644 --- a/docker/tests/container.tests.ps1 +++ b/docker/tests/container.tests.ps1 @@ -14,7 +14,7 @@ Describe "Build Linux Containers" -Tags 'Build', 'Linux' { [Parameter(Mandatory=$true)] [string] $name, - + [Parameter(Mandatory=$true)] [string] $path @@ -33,7 +33,7 @@ Describe "Build Windows Containers" -Tags 'Build', 'Windows' { [Parameter(Mandatory=$true)] [string] $name, - + [Parameter(Mandatory=$true)] [string] $path @@ -62,19 +62,19 @@ Describe "Linux Containers run PowerShell" -Tags 'Behavior', 'Linux' { Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue } - + it "Get PSVersion table from $(Get-RepoName):" -TestCases $script:linuxContainerTests -Skip:$script:skipLinux { param( [Parameter(Mandatory=$true)] [string] $name, - + [Parameter(Mandatory=$true)] [string] $path ) - Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.0-beta' + Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.0-rc' } } @@ -87,18 +87,18 @@ Describe "Windows Containers run PowerShell" -Tags 'Behavior', 'Windows' { Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue } - + it "Get PSVersion table from $(Get-RepoName):" -TestCases $script:windowsContainerTests -skip:$script:skipWindows { param( [Parameter(Mandatory=$true)] [string] $name, - + [Parameter(Mandatory=$true)] [string] $path ) - Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.0-beta' + Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.0-rc' } } diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index b8669ad25d6..207187be2a6 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -65,7 +65,7 @@ function Invoke-Docker # Return a list of Linux Container Test Cases function Get-LinuxContainer { - foreach($os in 'amazonlinux','centos7','opensuse42.2','ubuntu14.04','ubuntu16.04') + foreach($os in 'centos7','ubuntu14.04','ubuntu16.04') { Write-Output @{ Name = $os diff --git a/src/System.Management.Automation/resources/ParameterBinderStrings.resx b/src/System.Management.Automation/resources/ParameterBinderStrings.resx index 1edbbba226e..8c49becc278 100644 --- a/src/System.Management.Automation/resources/ParameterBinderStrings.resx +++ b/src/System.Management.Automation/resources/ParameterBinderStrings.resx @@ -142,7 +142,7 @@ Cannot bind positional parameters because no names were given. - Parameter set cannot be resolved using the specified named parameters. + Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided. Cannot process command because of one or more missing mandatory parameters:{1}. diff --git a/src/libpsl-native/src/followsymlink.cpp b/src/libpsl-native/src/followsymlink.cpp index 6f32d697d77..033160fae67 100644 --- a/src/libpsl-native/src/followsymlink.cpp +++ b/src/libpsl-native/src/followsymlink.cpp @@ -39,7 +39,7 @@ char* FollowSymLink(const char* fileName) if (realPath) { - return strndup(realPath, strlen(realPath) + 1); + return strndup(realPath, strnlen(realPath, PATH_MAX)); } // if the path wasn't resolved, use readlink diff --git a/src/libpsl-native/src/getfullyqualifiedname.cpp b/src/libpsl-native/src/getfullyqualifiedname.cpp index 75e5af4b367..12a3483ed7c 100644 --- a/src/libpsl-native/src/getfullyqualifiedname.cpp +++ b/src/libpsl-native/src/getfullyqualifiedname.cpp @@ -43,7 +43,7 @@ char *GetFullyQualifiedName() } // return the first canonical name in the list - fullName = strndup(info->ai_canonname, strlen(info->ai_canonname)); + fullName = strndup(info->ai_canonname, strnlen(info->ai_canonname, NI_MAXHOST)); // only free info if getaddrinfo was successful freeaddrinfo(info); diff --git a/src/libpsl-native/test/test-createsymlink.cpp b/src/libpsl-native/test/test-createsymlink.cpp index 9bd96f346f3..42f186b2951 100644 --- a/src/libpsl-native/test/test-createsymlink.cpp +++ b/src/libpsl-native/test/test-createsymlink.cpp @@ -92,7 +92,7 @@ TEST_F(CreateSymLinkTest, SymLinkToFile) std::string target = FollowSymLink(fileSymLink.c_str()); char buffer[PATH_MAX]; std::string expected = realpath(file, buffer); - EXPECT_EQ(target, expected); + EXPECT_EQ(expected, target); } TEST_F(CreateSymLinkTest, SymLinkToDirectory) @@ -103,7 +103,7 @@ TEST_F(CreateSymLinkTest, SymLinkToDirectory) std::string target = FollowSymLink(dirSymLink.c_str()); char buffer[PATH_MAX]; std::string expected = realpath(dir, buffer); - EXPECT_EQ(target, expected); + EXPECT_EQ(expected, target); } TEST_F(CreateSymLinkTest, SymLinkAgain) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index dc3bdce61ed..656d0bec69f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -2740,22 +2740,22 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu Describe "Web cmdlets tests using the cmdlet's aliases" -Tags "CI" { BeforeAll { - $response = Start-HttpListener -Port 8082 + $response = Start-HttpListener -Port 8079 } AfterAll { - $null = Stop-HttpListener -Port 8082 + $null = Stop-HttpListener -Port 8079 $response.PowerShell.Dispose() } It "Execute Invoke-WebRequest" { - $result = iwr "http://localhost:8082/PowerShell?test=response&output=hello" -TimeoutSec 5 + $result = iwr "http://localhost:8079/PowerShell?test=response&output=hello" -TimeoutSec 5 $result.StatusCode | Should Be "200" $result.Content | Should Be "hello" } It "Execute Invoke-RestMethod" { - $result = irm "http://localhost:8082/PowerShell?test=response&output={%22hello%22:%22world%22}&contenttype=application/json" -TimeoutSec 5 + $result = irm "http://localhost:8079/PowerShell?test=response&output={%22hello%22:%22world%22}&contenttype=application/json" -TimeoutSec 5 $result.Hello | Should Be "world" } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 index c53bced0227..1ddc40d5c2f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 @@ -125,7 +125,7 @@ Context "Import-CliXML" { BeforeAll { - $gpsList = Get-Process powershell + $gpsList = Get-Process pwsh $gps = $gpsList | Select-Object -First 1 $filePath = Join-Path $subFilePath 'gps.xml' @@ -161,7 +161,9 @@ $fileContent | Should Not Be $null $importedProcess = Import-Clixml $filePath + $importedProcess.ProcessName | Should Not BeNullOrEmpty $gps.ProcessName | Should Be $importedProcess.ProcessName + $importedProcess.Id | Should Not BeNullOrEmpty $gps.Id | Should Be $importedProcess.Id } @@ -173,7 +175,9 @@ $fileContent | Should Not Be $null $importedProcess = Import-Clixml $filePath + $importedProcess.ProcessName | Should Not BeNullOrEmpty $gps.ProcessName | Should Be $importedProcess.ProcessName + $importedProcess.Id | Should Not BeNullOrEmpty $gps.Id | Should Be $importedProcess.Id } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 359f7c85079..a1401a1bb7e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -168,19 +168,20 @@ function Invoke-AppVeyorFull # Implements the AppVeyor 'build_script' step function Invoke-AppVeyorBuild { - # check to be sure our test tags are correct - $result = Get-PesterTag - if ( $result.Result -ne "Pass" ) { + $releaseTag = Get-ReleaseTag + # check to be sure our test tags are correct + $result = Get-PesterTag + if ( $result.Result -ne "Pass" ) { $result.Warnings throw "Tags must be CI, Feature, Scenario, or Slow" - } + } - if(Test-DailyBuild) - { - Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore - } + if(Test-DailyBuild) + { + Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -ReleaseTag $releaseTag + } - Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' + Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag } # Implements the AppVeyor 'install' step @@ -188,9 +189,10 @@ function Invoke-AppVeyorInstall { # Make sure we have all the tags Sync-PSTags -AddRemoteIfMissing + $releaseTag = Get-ReleaseTag if($env:APPVEYOR_BUILD_NUMBER) { - Update-AppveyorBuild -Version "$(Get-PSVersion -OmitCommitId)-$env:APPVEYOR_BUILD_NUMBER" + Update-AppveyorBuild -Version $releaseTag } if(Test-DailyBuild){ @@ -420,14 +422,31 @@ function Get-PackageName return $name } +function Get-ReleaseTag +{ + $metaDataPath = Join-Path -Path $PSScriptRoot -ChildPath 'metadata.json' + $metaData = Get-Content $metaDataPath | ConvertFrom-Json + + $releaseTag = $metadata.NextReleaseTag + if($env:APPVEYOR_BUILD_NUMBER) + { + $releaseTag = $releaseTag.split('.')[0..2] -join '.' + $releaseTag = $releaseTag+'.'+$env:APPVEYOR_BUILD_NUMBER + } + + return $releaseTag +} + # Implements AppVeyor 'on_finish' step function Invoke-AppveyorFinish { try { + $releaseTag = Get-ReleaseTag + $packageParams = @{} if($env:APPVEYOR_BUILD_VERSION) { - $packageParams += @{Version=$env:APPVEYOR_BUILD_VERSION} + $packageParams += @{ReleaseTag=$releaseTag} } # Build packages @@ -454,7 +473,7 @@ function Invoke-AppveyorFinish } else { - $previewVersion = (git describe --abbrev=0).Split('-') + $previewVersion = $releaseTag.Split('-') $previewPrefix = $previewVersion[0] $previewLabel = $previewVersion[1].replace('.','') diff --git a/tools/install-powershell.ps1 b/tools/install-powershell.ps1 index 8a69fb7e654..fac01dc1c48 100644 --- a/tools/install-powershell.ps1 +++ b/tools/install-powershell.ps1 @@ -1,6 +1,6 @@ <# .Synopsis - Install PowerShell Core on Windows. + Install PowerShell Core on Windows, Linux or macOS. .DESCRIPTION By default, the latest PowerShell Core release package will be installed. If '-Daily' is specified, then the latest PowerShell Core daily package will be installed. @@ -156,6 +156,19 @@ try { Move-Item -Path $contentPath -Destination $Destination } + # Edit icon to disambiguate daily builds. + if ($IsWinEnv -and $Daily.IsPresent) { + if (-not (Test-Path "~/.rcedit/rcedit-x64.exe")) { + Write-Verbose "Install RCEdit for modifying exe resources" -Verbose + $rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.0.0/rcedit-x64.exe" + New-Item -Path "~/.rcedit" -Type Directory -Force > $null + Invoke-WebRequest -OutFile "~/.rcedit/rcedit-x64.exe" -Uri $rceditUrl + } + + Write-Verbose "Change icon to disambiguate it from a released installation" -Verbose + & "~/.rcedit/rcedit-x64.exe" "$Destination\pwsh.exe" --set-icon "$Destination\assets\Powershell_av_colors.ico" + } + ## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution if (-not $IsWinEnv) { chmod 755 $Destination/pwsh } diff --git a/tools/metadata.json b/tools/metadata.json index a7f64d48e93..776d5ca3b24 100644 --- a/tools/metadata.json +++ b/tools/metadata.json @@ -1,3 +1,4 @@ { - "ReleaseTag": "v6.0.0-beta.9" + "ReleaseTag": "v6.0.0-rc", + "NextReleaseTag": "v6.1.0-preview.1" } diff --git a/tools/releaseBuild/macOS/PowerShellPackage.ps1 b/tools/releaseBuild/macOS/PowerShellPackage.ps1 index e4ee858361b..2fdc90fed11 100644 --- a/tools/releaseBuild/macOS/PowerShellPackage.ps1 +++ b/tools/releaseBuild/macOS/PowerShellPackage.ps1 @@ -34,6 +34,7 @@ if ($ReleaseTag) Push-Location try { Set-Location /PowerShell + git submodule update --init --recursive --quiet Import-Module "/PowerShell/build.psm1" Import-Module "/PowerShell/tools/packaging" diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 79cdb304919..670b012693d 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -44,6 +44,21 @@ OS Type: $($PSVersionTable.OS)
} } +function Get-ReleaseTag +{ + $metaDataPath = Join-Path -Path $PSScriptRoot -ChildPath 'metadata.json' + $metaData = Get-Content $metaDataPath | ConvertFrom-Json + + $releaseTag = $metadata.NextReleaseTag + if($env:TRAVIS_BUILD_NUMBER) + { + $releaseTag = $releaseTag.split('.')[0..2] -join '.' + $releaseTag = $releaseTag+'.'+$env:TRAVIS_BUILD_NUMBER + } + + return $releaseTag +} + # This function retrieves the appropriate svg to be used when presenting # the daily test run badge # the location in azure is public readonly @@ -171,7 +186,8 @@ if($Stage -eq 'Bootstrap') } elseif($Stage -eq 'Build') { - $BaseVersion = (Get-PSVersion -OmitCommitId) + '-' + $releaseTag = Get-ReleaseTag + Write-Host -Foreground Green "Executing travis.ps1 `$isPR='$isPr' `$isFullBuild='$isFullBuild' - $commitMessage" $output = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions)) @@ -179,7 +195,7 @@ elseif($Stage -eq 'Build') $ProgressPreference = 'SilentlyContinue' try { ## We use CrossGen build to run tests only if it's the daily build. - Start-PSBuild -CrossGen -PSModuleRestore + Start-PSBuild -CrossGen -PSModuleRestore -ReleaseTag $releaseTag } finally{ $ProgressPreference = $originalProgressPreference @@ -235,12 +251,10 @@ elseif($Stage -eq 'Build') } if ($createPackages) { + $packageParams = @{} - if($env:TRAVIS_BUILD_NUMBER) - { - $version = $BaseVersion + $env:TRAVIS_BUILD_NUMBER - $packageParams += @{Version=$version} - } + $packageParams += @{ReleaseTag=$releaseTag} + # Only build packages for branches, not pull requests $packages = @(Start-PSPackage @packageParams -SkipReleaseChecks) # Packaging AppImage depends on the deb package