From 4118fd2829cb1a0a64005bd5b84e08ca7ea354e2 Mon Sep 17 00:00:00 2001 From: John Eismeier <32205350+jeis2497052@users.noreply.github.com> Date: Thu, 8 Nov 2018 22:33:24 -0500 Subject: [PATCH 1/4] Propose fix some typos (#8206) --- build.psm1 | 2 +- .../resources/ScheduledJobErrorStrings.resx | 4 ++-- src/Schemas/PSMaml/ManagedDeveloper.xsd | 4 ++-- src/Schemas/PSMaml/ManagedDeveloperStructure.xsd | 4 ++-- tools/install-powershell.sh | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.psm1 b/build.psm1 index 01120cfa6b4..263ac1232a2 100644 --- a/build.psm1 +++ b/build.psm1 @@ -725,7 +725,7 @@ function New-PSOptions { # Get the Options of the last build function Get-PSOptions { param( - [Parameter(HelpMessage='Defaults to New-PSOption if a build has not ocurred.')] + [Parameter(HelpMessage='Defaults to New-PSOption if a build has not occurred.')] [switch] $DefaultToNew ) diff --git a/src/Microsoft.PowerShell.ScheduledJob/resources/ScheduledJobErrorStrings.resx b/src/Microsoft.PowerShell.ScheduledJob/resources/ScheduledJobErrorStrings.resx index 56ea7888180..047abfee829 100644 --- a/src/Microsoft.PowerShell.ScheduledJob/resources/ScheduledJobErrorStrings.resx +++ b/src/Microsoft.PowerShell.ScheduledJob/resources/ScheduledJobErrorStrings.resx @@ -355,10 +355,10 @@ The RepetitionInterval parameter cannot have a value of zero unless the RepetitionDuration parameter also has a zero value. A zero value removes repetition behavior from the Job trigger. - An error occured while attempting to rename scheduled job from {0} to {1}. + An error occurred while attempting to rename scheduled job from {0} to {1}. - An error occured while attempting to rename scheduled job from {0} to {1} with error message: {2}. + An error occurred while attempting to rename scheduled job from {0} to {1} with error message: {2}. An unrecoverable error occurred while renaming the scheduled job from {0} to {1}. The scheduled job will be removed. diff --git a/src/Schemas/PSMaml/ManagedDeveloper.xsd b/src/Schemas/PSMaml/ManagedDeveloper.xsd index 53c9383efdb..92a2ca6ba3b 100644 --- a/src/Schemas/PSMaml/ManagedDeveloper.xsd +++ b/src/Schemas/PSMaml/ManagedDeveloper.xsd @@ -4,8 +4,8 @@ This schema describes MAML, the Microsoft Assistance Markup Language. - MAML is intended for software documentation. In particular, it is - intended to accomodate the needs of Microsoft documentation. + MAML is intended for software documentation. In particular, it is + intended to accommodate the needs of Microsoft documentation. The schema is broken into three main areas: end user, developer and diff --git a/src/Schemas/PSMaml/ManagedDeveloperStructure.xsd b/src/Schemas/PSMaml/ManagedDeveloperStructure.xsd index 7580fd6b831..2f9d8dd5a22 100644 --- a/src/Schemas/PSMaml/ManagedDeveloperStructure.xsd +++ b/src/Schemas/PSMaml/ManagedDeveloperStructure.xsd @@ -4,8 +4,8 @@ This schema describes MAML, the Microsoft Assistance Markup Language. - MAML is intended for software documentation. In particular, it is - intended to accomodate the needs of Microsoft documentation. + MAML is intended for software documentation. In particular, it is + intended to accommodate the needs of Microsoft documentation. The schema is broken into three main areas: end user, developer and diff --git a/tools/install-powershell.sh b/tools/install-powershell.sh index 2e6991417c4..673a861dc85 100755 --- a/tools/install-powershell.sh +++ b/tools/install-powershell.sh @@ -9,7 +9,7 @@ install(){ #bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) - #Usage - if you do not have the ability to run scripts directly from the web, + #Usage - if you do not have the ability to run scripts directly from the web, # pull all files in this repo folder and execute, this script # automatically prefers local copies of sub-scripts @@ -132,7 +132,7 @@ install(){ bash <(wget -qO- $gitreposcriptroot/appimage.sh) $@ fi elif [ "$DistroBasedOn" == "redhat" ] || [ "$DistroBasedOn" == "debian" ] || [ "$DistroBasedOn" == "osx" ] || [ "$DistroBasedOn" == "suse" ] || [ "$DistroBasedOn" == "amazonlinux" ]; then - echo "Configuring PowerShell Core Enviornment for: $DistroBasedOn $DIST $REV" + echo "Configuring PowerShell Core Environment for: $DistroBasedOn $DIST $REV" if [ -f $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh ]; then #Script files were copied local - use them . $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh From caad7ed471d46629f155a2c7ccbbafa4ffc29355 Mon Sep 17 00:00:00 2001 From: kwkam Date: Sat, 10 Nov 2018 03:08:26 +0800 Subject: [PATCH 2/4] Fix Rename-Item -Path with wildcard char (#7398) --- .../commands/management/Navigation.cs | 79 +++++++++++++++++-- .../namespaces/LocationGlobber.cs | 8 +- .../FunctionProvider.Tests.ps1 | 6 +- .../Rename-Item.Tests.ps1 | 43 +++++++++- 4 files changed, 124 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs index 0df84608805..eedbeb4855d 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs @@ -3519,22 +3519,87 @@ protected override bool ProviderSupportsShouldProcess #region Command code + private Collection GetResolvedPaths(string path) + { + Collection results = null; + try + { + results = SessionState.Path.GetResolvedPSPathFromPSPath(path, CmdletProviderContext); + } + catch (PSNotSupportedException notSupported) + { + WriteError( + new ErrorRecord( + notSupported.ErrorRecord, + notSupported)); + } + catch (DriveNotFoundException driveNotFound) + { + WriteError( + new ErrorRecord( + driveNotFound.ErrorRecord, + driveNotFound)); + } + catch (ProviderNotFoundException providerNotFound) + { + WriteError( + new ErrorRecord( + providerNotFound.ErrorRecord, + providerNotFound)); + } + catch (ItemNotFoundException pathNotFound) + { + WriteError( + new ErrorRecord( + pathNotFound.ErrorRecord, + pathNotFound)); + } + + return results; + } + /// /// Moves the specified item to the specified destination /// protected override void ProcessRecord() + { + if (SuppressWildcardExpansion) + { + RenameItem(Path, literalPath: true); + return; + } + + Collection resolvedPaths = GetResolvedPaths(Path); + + if (resolvedPaths == null) + { + return; + } + + if (resolvedPaths.Count == 1) + { + RenameItem(resolvedPaths[0].Path, literalPath: true); + } + else + { + RenameItem(WildcardPattern.Unescape(Path), literalPath: true); + } + } + + private void RenameItem(string path, bool literalPath = false) { CmdletProviderContext currentContext = CmdletProviderContext; + currentContext.SuppressWildcardExpansion = literalPath; try { - if (!InvokeProvider.Item.Exists(Path, currentContext)) + if (!InvokeProvider.Item.Exists(path, currentContext)) { PSInvalidOperationException invalidOperation = (PSInvalidOperationException) PSTraceSource.NewInvalidOperationException( NavigationResources.RenameItemDoesntExist, - Path); + path); WriteError( new ErrorRecord( @@ -3580,7 +3645,7 @@ protected override void ProcessRecord() bool isCurrentLocationOrAncestor = false; try { - isCurrentLocationOrAncestor = SessionState.Path.IsCurrentLocationOrAncestor(_path, currentContext); + isCurrentLocationOrAncestor = SessionState.Path.IsCurrentLocationOrAncestor(path, currentContext); } catch (PSNotSupportedException notSupported) { @@ -3621,7 +3686,7 @@ protected override void ProcessRecord() (PSInvalidOperationException) PSTraceSource.NewInvalidOperationException( NavigationResources.RenamedItemInUse, - Path); + path); WriteError( new ErrorRecord( @@ -3635,12 +3700,12 @@ protected override void ProcessRecord() currentContext.PassThru = PassThru; - tracer.WriteLine("Rename {0} to {1}", Path, NewName); + tracer.WriteLine("Rename {0} to {1}", path, NewName); try { // Now do the rename - InvokeProvider.Item.Rename(Path, NewName, currentContext); + InvokeProvider.Item.Rename(path, NewName, currentContext); } catch (PSNotSupportedException notSupported) { @@ -3674,7 +3739,7 @@ protected override void ProcessRecord() pathNotFound)); return; } - } // ProcessRecord + } #endregion Command code } // RenameItemCommand diff --git a/src/System.Management.Automation/namespaces/LocationGlobber.cs b/src/System.Management.Automation/namespaces/LocationGlobber.cs index 22ae25e8b8c..ba4b05d420e 100644 --- a/src/System.Management.Automation/namespaces/LocationGlobber.cs +++ b/src/System.Management.Automation/namespaces/LocationGlobber.cs @@ -433,7 +433,13 @@ private Collection ResolveDriveQualifiedPath( s_pathResolutionTracer.WriteLine("Path is DRIVE-QUALIFIED"); - string relativePath = GetDriveRootRelativePathFromPSPath(path, context, true, out drive, out providerInstance); + string relativePath = + GetDriveRootRelativePathFromPSPath( + path, + context, + !context.SuppressWildcardExpansion, + out drive, + out providerInstance); Dbg.Diagnostics.Assert( drive != null, diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FunctionProvider.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FunctionProvider.Tests.ps1 index b21a8977b7d..f8796f33085 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FunctionProvider.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FunctionProvider.Tests.ps1 @@ -104,7 +104,7 @@ Describe "Basic Function Provider Tests" -Tags "CI" { } It "Fails to rename not existing function" { - { Rename-Item $nonExistingFunction -NewName $newName -ErrorAction Stop } | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand" + { Rename-Item $nonExistingFunction -NewName $newName -ErrorAction Stop } | Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.RenameItemCommand" } It "Fails to rename function which is Constant" { @@ -113,8 +113,8 @@ Describe "Basic Function Provider Tests" -Tags "CI" { } It "Fails to rename function which is ReadOnly" { - Set-Item $nonExistingFunction -Options "ReadOnly" - { Rename-Item $nonExistingFunction -NewName $newName -ErrorAction Stop } | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand" + Set-Item $nonExistingFunction -Options "ReadOnly" -Value $functionValue + { Rename-Item $nonExistingFunction -NewName $newName -ErrorAction Stop } | Should -Throw -ErrorId "CannotRenameFunction,Microsoft.PowerShell.Commands.RenameItemCommand" } It "Renames ReadOnly function when -Force parameter is on" { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Item.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Item.Tests.ps1 index b73461caf14..7abedaa31c1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Item.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Item.Tests.ps1 @@ -2,10 +2,15 @@ # Licensed under the MIT License. Describe "Rename-Item tests" -Tag "CI" { BeforeAll { - $content = "This is content" Setup -f originalFile.txt -content "This is content" $source = "$TESTDRIVE/originalFile.txt" $target = "$TESTDRIVE/ItemWhichHasBeenRenamed.txt" + Setup -f [orig-file].txt -content "This is not content" + $sourceSp = "$TestDrive/``[orig-file``].txt" + $targetSpName = "ItemWhichHasBeen[Renamed].txt" + $targetSp = "$TestDrive/ItemWhichHasBeen``[Renamed``].txt" + Setup -Dir [test-dir] + $wdSp = "$TestDrive/``[test-dir``]" } It "Rename-Item will rename a file" { Rename-Item $source $target @@ -13,4 +18,40 @@ Describe "Rename-Item tests" -Tag "CI" { test-path $target | Should -BeTrue "$target" | Should -FileContentMatchExactly "This is content" } + It "Rename-Item will rename a file when path contains special char" { + Rename-Item $sourceSp $targetSpName + $sourceSp | Should -Not -Exist + $targetSp | Should -Exist + $targetSp | Should -FileContentMatchExactly "This is not content" + } + It "Rename-Item will rename a file when -Path and CWD contains special char" { + $content = "This is content" + $oldSpName = "[orig]file.txt" + $oldSpBName = "``[orig``]file.txt" + $oldSp = "$wdSp/$oldSpBName" + $newSpName = "[renamed]file.txt" + $newSp = "$wdSp/``[renamed``]file.txt" + In $wdSp -Execute { + $null = New-Item -Name $oldSpName -ItemType File -Value $content -Force + Rename-Item -Path $oldSpBName $newSpName + } + $oldSp | Should -Not -Exist + $newSp | Should -Exist + $newSp | Should -FileContentMatchExactly $content + } + It "Rename-Item will rename a file when -LiteralPath and CWD contains special char" { + $content = "This is not content" + $oldSpName = "[orig]file2.txt" + $oldSpBName = "``[orig``]file2.txt" + $oldSp = "$wdSp/$oldSpBName" + $newSpName = "[renamed]file2.txt" + $newSp = "$wdSp/``[renamed``]file2.txt" + In $wdSp -Execute { + $null = New-Item -Name $oldSpName -ItemType File -Value $content -Force + Rename-Item -LiteralPath $oldSpName $newSpName + } + $oldSp | Should -Not -Exist + $newSp | Should -Exist + $newSp | Should -FileContentMatchExactly $content + } } From 9894be9c60be12fddc3e61348e86b79a1af6b7c1 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 9 Nov 2018 11:38:44 -0800 Subject: [PATCH 3/4] Add path filters to CI YAML (#8222) * Filter spelling to only PRs with `*.md` files * filter common paths in CI yml --- .vsts-ci/linux.yml | 22 ++++++++++++++++++++++ .vsts-ci/mac.yml | 22 ++++++++++++++++++++++ .vsts-ci/spelling.yml | 16 ++++++++++++++++ .vsts-ci/windows.yml | 22 ++++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/.vsts-ci/linux.yml b/.vsts-ci/linux.yml index 943487560e9..e5bb9bfc957 100644 --- a/.vsts-ci/linux.yml +++ b/.vsts-ci/linux.yml @@ -1,4 +1,26 @@ name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) +trigger: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml +pr: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml variables: DOTNET_CLI_TELEMETRY_OPTOUT: 1 POWERSHELL_TELEMETRY_OPTOUT: 1 diff --git a/.vsts-ci/mac.yml b/.vsts-ci/mac.yml index 51bbefc5669..8c0562318b5 100644 --- a/.vsts-ci/mac.yml +++ b/.vsts-ci/mac.yml @@ -1,4 +1,26 @@ name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) +trigger: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml +pr: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml variables: DOTNET_CLI_TELEMETRY_OPTOUT: 1 POWERSHELL_TELEMETRY_OPTOUT: 1 diff --git a/.vsts-ci/spelling.yml b/.vsts-ci/spelling.yml index 2c7b6047abf..b6868b97f17 100644 --- a/.vsts-ci/spelling.yml +++ b/.vsts-ci/spelling.yml @@ -1,4 +1,20 @@ name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) +trigger: + branches: + include: + - master + - release* + paths: + include: + - '*.md' +pr: + branches: + include: + - master + - release* + paths: + include: + - '*.md' resources: - repo: self diff --git a/.vsts-ci/windows.yml b/.vsts-ci/windows.yml index bf26369a1f8..d926bded093 100644 --- a/.vsts-ci/windows.yml +++ b/.vsts-ci/windows.yml @@ -1,4 +1,26 @@ name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) +trigger: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml +pr: + branches: + include: + - master + - release* + paths: + include: + - '*' + exclude: + - /tools/releaseBuild/**/* + - /.vsts-ci/spelling.yml queue: name: Hosted VS2017 parallel: 2 # Limit to two agents at a time From d4bf5c87bc10ad692c902b0474ac643acfabd623 Mon Sep 17 00:00:00 2001 From: Paul Higinbotham Date: Fri, 9 Nov 2018 15:11:02 -0800 Subject: [PATCH 4/4] Fix tests running in Azure DevOps (#8220) --- test/powershell/Host/HostUtilities.Tests.ps1 | 2 +- .../TabCompletion/TabCompletion.Tests.ps1 | 8 +- .../RemoteGetModule.Tests.ps1 | 24 +++- .../Rename-Computer.Tests.ps1 | 2 +- .../Restart-Computer.Tests.ps1 | 2 +- .../Start-Process.Tests.ps1 | 4 +- .../Implicit.Remoting.Tests.ps1 | 19 --- .../TestWSMan.Tests.ps1 | 11 +- .../ImplicitRemotingBatching.Tests.ps1 | 39 +++++- .../InvokeCommandRemoteDebug.Tests.ps1 | 54 ++++---- .../Remoting/RemoteSession.Basic.Tests.ps1 | 2 +- .../engine/ResourceValidation/TestRunner.ps1 | 13 +- .../HelpersRemoting/HelpersRemoting.psm1 | 65 ++++++++- tools/appveyor.psm1 | 129 ++++++++++++------ 14 files changed, 259 insertions(+), 115 deletions(-) diff --git a/test/powershell/Host/HostUtilities.Tests.ps1 b/test/powershell/Host/HostUtilities.Tests.ps1 index 96145b41ca7..937e167c607 100644 --- a/test/powershell/Host/HostUtilities.Tests.ps1 +++ b/test/powershell/Host/HostUtilities.Tests.ps1 @@ -32,7 +32,7 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" { } } -Describe "InvokeOnRunspace method on remote runspace" -tags "Feature" { +Describe "InvokeOnRunspace method on remote runspace" -tags "Feature","RequireAdminOnWindows" { BeforeAll { diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index b93891632b7..c87ce887d76 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -491,7 +491,7 @@ Describe "TabCompletion" -Tags CI { ## if $PSHOME contains a space tabcompletion adds ' around the path @{ inputStr = 'cd $pshome\Modu'; expected = if($PSHOME.Contains(' ')) { "'$(Join-Path $PSHOME 'Modules')'" } else { Join-Path $PSHOME 'Modules' }; setup = $null } @{ inputStr = 'cd "$pshome\Modu"'; expected = "`"$(Join-Path $PSHOME 'Modules')`""; setup = $null } - @{ inputStr = '$PSHOME\System.Management.Au'; expected = Join-Path $PSHOME 'System.Management.Automation.dll'; setup = $null } + @{ inputStr = '$PSHOME\System.Management.Au'; expected = if($PSHOME.Contains(' ')) { "`& '$(Join-Path $PSHOME 'System.Management.Automation.dll')'" } else { Join-Path $PSHOME 'System.Management.Automation.dll'; setup = $null }} @{ inputStr = '"$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null } @{ inputStr = '& "$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null } ## tab completion AST-based tests @@ -1045,7 +1045,7 @@ dir -Recurse ` } } -Describe "Tab completion tests with remote Runspace" -Tags Feature { +Describe "Tab completion tests with remote Runspace" -Tags Feature,RequireAdminOnWindows { BeforeAll { if ($IsWindows) { $session = New-RemoteSession @@ -1116,9 +1116,7 @@ Describe "WSMan Config Provider tab complete tests" -Tags Feature,RequireAdminOn $res = TabExpansion2 -inputScript $path -cursorColumn $path.Length $listener = Get-ChildItem WSMan:\localhost\Listener $res.CompletionMatches.Count | Should -Be $listener.Count - for ($i = 0; $i -lt $res.CompletionMatches.Count; $i++) { - $res.CompletionMatches[$i].ListItemText | Should -Be $listener[$i].Name - } + $res.CompletionMatches.ListItemText | Should -BeIn $listener.Name } It "Tab completion gets dynamic parameters for '' using ''" -TestCases @( diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 index 985b20291e0..27bab77bd70 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 @@ -3,18 +3,28 @@ Describe "Remote module tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { - $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() - if (!$IsWindows) { + + if (!$IsWindows) + { + $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = $true - } else { - $pssession = New-RemoteSession - # pending https://github.com/PowerShell/PowerShell/issues/4819 - # $cimsession = New-RemoteSession -CimSession + return } + + $pssession = New-RemoteSession + # pending https://github.com/PowerShell/PowerShell/issues/4819 + # $cimsession = New-RemoteSession -CimSession } AfterAll { - $global:PSDefaultParameterValues = $originalDefaultParameterValues + + if (!$IsWindows) + { + $global:PSDefaultParameterValues = $originalDefaultParameterValues + return + } + + if ($pssession -ne $null) { Remove-PSSession $pssession -ErrorAction SilentlyContinue } } It "Get-Module fails if not using -ListAvailable with ''" -TestCases @( diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 index 8cb63a0583a..a2ed536220b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 @@ -13,7 +13,7 @@ try Enable-Testhook -testhookName TestStopComputer # TEST START HERE - Describe "Rename-Computer" -Tag Feature { + Describe "Rename-Computer" -Tag Feature,RequireAdminOnWindows { # if we throw in BeforeEach, the test will fail and the stop will not be called BeforeEach { if ( ! (Test-TesthookIsSet -testhookName $RenameTesthook) ) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Restart-Computer.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Restart-Computer.Tests.ps1 index feb4c07e096..6bb32d48e3e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Restart-Computer.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Restart-Computer.Tests.ps1 @@ -12,7 +12,7 @@ try $PSDefaultParameterValues["it:skip"] = ! $IsWindows Enable-Testhook -testhookName $restartTesthookName - Describe "Restart-Computer" -Tag Feature { + Describe "Restart-Computer" -Tag Feature,RequireAdminOnWindows { # if we throw in BeforeEach, the test will fail and the restart will not be called BeforeEach { if ( ! (Test-TesthookIsSet -testhookName $restartTesthookName) ) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 index fa9789c7f58..60a1cc2bba9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Start-Process.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe "Start-Process" -Tags @("Feature") { +Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" { BeforeAll { $isNanoServer = [System.Management.Automation.Platform]::IsNanoServer @@ -113,7 +113,7 @@ Describe "Start-Process" -Tags @("Feature") { } It "Should start notepad.exe with ShellExecute" -Skip:(!$isFullWin) { - $process = Start-Process notepad -PassThru -WindowStyle Normal + $process = Start-Process notepad.exe -PassThru -WindowStyle Normal $process.Name | Should -Be "notepad" $process | Stop-Process } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 index abe47d5dae0..6fca0330ffa 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 @@ -11,25 +11,6 @@ $PSDefaultParameterValues["it:skip"] = $skipTest try { - # - # Ensure WinRM remoting is enabled - # - if (! $skipTest) - { - # Check to see if a default endpoint has been created - $endpointName = "PowerShell.$($psversiontable.GitCommitId)" - $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue - - if ($matchedEndpoint -eq $null) - { - # An endpoint for this instance of PowerShell does not exist. - # - # -SkipNetworkProfileCheck is used in case Docker or another application - # has created a publich virtual network profile on the system - Enable-PSRemoting -SkipNetworkProfileCheck - } - } - Describe "Implicit remoting and CIM cmdlets with AllSigned and Restricted policy" -tags "Feature","RequireAdminOnWindows" { BeforeAll { diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/TestWSMan.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/TestWSMan.Tests.ps1 index 9db02182b46..ec824ec0b0b 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/TestWSMan.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/TestWSMan.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe "TestWSMan tests" -Tags 'Feature' { +Describe "TestWSMan tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() @@ -46,13 +46,14 @@ Describe "TestWSMan tests" -Tags 'Feature' { { Test-WSMan -Authentication foo -ErrorAction Stop } | Should -Throw -ErrorId "CannotConvertArgumentNoMessage,Microsoft.WSMan.Management.TestWSManCommand" } - It "Test-WSMan works for ''" -TestCases @( - @{ computername = $null }, - @{ computername = "localhost" }, - @{ computername = $env:COMPUTERNAME } + It "Test-WSMan works for " -TestCases @( + @{ testName = "Null"; computername = $null }, + @{ testName = "localhost"; computername = "localhost" }, + @{ testName = "computername"; computername = $env:COMPUTERNAME } ) { param($computername) $response = Test-WSMan -ComputerName $computername + $response | Should -Not -BeNullOrEmpty $response.PSObject.TypeNames[0] | Should -Be "System.Xml.XmlElement#http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd#IdentifyResponse" $response.wsmid | Should -Be "http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd" $response.ProtocolVersion | Should -Be "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" diff --git a/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 b/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 index c694e52a567..b305bed3d2f 100644 --- a/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 +++ b/test/powershell/engine/Remoting/ImplicitRemotingBatching.Tests.ps1 @@ -1,22 +1,55 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe "TestImplicitRemotingBatching hook should correctly batch simple remote command pipelines" -Tags 'Feature','RequireAdminOnWindows' { +Describe "TestImplicitRemotingBatching hook should correctly batch simple remote command pipelines" -Tag 'Feature','RequireAdminOnWindows' { BeforeAll { if (! $isWindows) { return } + function ThrowSetupError + { + param ( + [string] $errorMessage, + [System.Management.Automation.ErrorRecord[]] $eRecords + ) + + $msg = @() + foreach ($err in $powerShell.Streams.Error) + { + $msg += $err.ToString() + "`n" + } + + throw "$errorMessage : '$msg'" + } + + # Make sure we can create a remote session + $remotePSSession = New-RemoteSession + if ($remotePSSession -eq $null) + { + Write-Verbose "Unable to create a remote session in test." + } + else + { + Remove-PSSession $remotePSSession + } + [powershell] $powerShell = [powershell]::Create([System.Management.Automation.RunspaceMode]::NewRunspace) # Create remote session in new PowerShell session $powerShell.AddScript('Import-Module -Name HelpersRemoting; $remoteSession = New-RemoteSession').Invoke() - if ($powerShell.Streams.Error.Count -gt 0) { throw "Unable to create remote session for test" } + if ($powerShell.Streams.Error.Count -gt 0) + { + ThrowSetupError -errorMessage "Unable to create remote session for test with error" -eRecords $powerShell.Streams.Error + } # Import implicit commands from remote session $powerShell.Commands.Clear() $powerShell.AddScript('Import-PSSession -Session $remoteSession -CommandName Get-Process,Write-Output -AllowClobber').Invoke() - if ($powerShell.Streams.Error.Count -gt 0) { throw "Unable to import pssession for test" } + if ($powerShell.Streams.Error.Count -gt 0) + { + ThrowSetupError -errorMessage "Unable to import pssession for test" -eRecords $powerShell.Streams.Error + } # Define $filter variable in local session $powerShell.Commands.Clear() diff --git a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 index 1b81b1d3fdf..8053cf6838a 100644 --- a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 +++ b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 @@ -116,39 +116,36 @@ if ($IsWindows) '@ } -Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { +Describe "Invoke-Command remote debugging tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { if (!$IsWindows) { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() - $PSDefaultParameterValues["it:Pending"] = $true + $PSDefaultParameterValues["it:skip"] = $true + return } - else - { - $sb = [scriptblock]::Create(@' - "Hello!" -'@) - Add-Type -TypeDefinition $typeDef + $sb = [scriptblock]::Create('"Hello!"') - $dummyHost = [TestRunner.DummyHost]::new() - [runspace] $rs = [runspacefactory]::CreateRunspace($dummyHost) - $rs.Open() - $dummyHost._runspace = $rs + Add-Type -TypeDefinition $typeDef - $testDebugger = [TestRunner.TestDebugger]::new($rs) + $dummyHost = [TestRunner.DummyHost]::new() + [runspace] $rs = [runspacefactory]::CreateRunspace($dummyHost) + $rs.Open() + $dummyHost._runspace = $rs - [runspace] $rs2 = [runspacefactory]::CreateRunspace() - $rs2.Open() + $testDebugger = [TestRunner.TestDebugger]::new($rs) - [powershell] $ps = [powershell]::Create() - $ps.Runspace = $rs + [runspace] $rs2 = [runspacefactory]::CreateRunspace() + $rs2.Open() - [powershell] $ps2 = [powershell]::Create() - $ps2.Runspace = $rs2 - } + [powershell] $ps = [powershell]::Create() + $ps.Runspace = $rs + + [powershell] $ps2 = [powershell]::Create() + $ps2.Runspace = $rs2 } AfterAll { @@ -156,16 +153,15 @@ Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { if (!$IsWindows) { $global:PSDefaultParameterValues = $originalDefaultParameterValues + return } - else - { - if ($null -ne $testDebugger) { $testDebugger.Release() } - if ($null -ne $ps) { $ps.Dispose() } - if ($null -ne $ps2) { $ps2.Dispose() } - if ($null -ne $rs) { $rs.Dispose() } - if ($null -ne $rs2) { $rs2.Dispose() } - if ($null -ne $remoteSession) { Remove-PSSession $remoteSession -ErrorAction SilentlyContinue } - } + + if ($null -ne $testDebugger) { $testDebugger.Release() } + if ($null -ne $ps) { $ps.Dispose() } + if ($null -ne $ps2) { $ps2.Dispose() } + if ($null -ne $rs) { $rs.Dispose() } + if ($null -ne $rs2) { $rs2.Dispose() } + if ($null -ne $remoteSession) { Remove-PSSession $remoteSession -ErrorAction SilentlyContinue } } BeforeEach { diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index 33b63571e6f..631c5e1b8ce 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -277,7 +277,7 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { } It 'Can invoke-command as job' { - $result = Invoke-Command -ScriptBlock { 1 + 1 } -Session $openSession -AsJob | Receive-Job -AutoRemoveJob -Wait + $result = Invoke-Command -ScriptBlock { 1 + 1 } -Session $openSession -AsJob | Receive-Job -AutoRemoveJob -Wait -ErrorAction SilentlyContinue $result | Should -Be 2 } diff --git a/test/powershell/engine/ResourceValidation/TestRunner.ps1 b/test/powershell/engine/ResourceValidation/TestRunner.ps1 index 01e3db38dcb..05bbf6107cc 100644 --- a/test/powershell/engine/ResourceValidation/TestRunner.ps1 +++ b/test/powershell/engine/ResourceValidation/TestRunner.ps1 @@ -36,6 +36,16 @@ function Test-ResourceStrings # This is the reason why this is not a general module for use. There is # no other way to run these tests Describe "Resources strings in $AssemblyName (was -ResGen used with Start-PSBuild)" -tag Feature { + + function NormalizeLineEnd + { + param ( + [string] $string + ) + + $string -replace "`r`n", "`n" + } + foreach ( $resourceFile in $resourceFiles ) { # in the event that the id has a space in it, it is replaced with a '_' @@ -50,7 +60,8 @@ function Test-ResourceStrings # check all the resource strings $xmlData = [xml](Get-Content $resourceFile.Fullname) foreach ( $inResource in $xmlData.root.data ) { - $resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) | Should -Be $inresource.value + $resourceStringToCheck = $resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) + NormalizeLineEnd($resourceStringToCheck) | Should -Be (NormalizeLineEnd($inresource.value)) } } } diff --git a/test/tools/Modules/HelpersRemoting/HelpersRemoting.psm1 b/test/tools/Modules/HelpersRemoting/HelpersRemoting.psm1 index 8fb67f63bba..23d21783079 100644 --- a/test/tools/Modules/HelpersRemoting/HelpersRemoting.psm1 +++ b/test/tools/Modules/HelpersRemoting/HelpersRemoting.psm1 @@ -10,10 +10,53 @@ if ($IsWindows) { try { $Script:AppVeyorRemoteCred = Import-Clixml -Path "$env:TEMP\AppVeyorRemoteCred.xml" } catch { } } +function Get-DefaultEndPointName +{ + $endPointName = "PowerShell.$(${PSVersionTable}.GitCommitId)" + $endPoint = Get-PSSessionConfiguration -Name $endPointName -ErrorAction SilentlyContinue + + if ($endPoint -eq $null) + { + Enable-PSRemoting -SkipNetworkProfileCheck + $endPoint = Get-PSSessionConfiguration -Name $endPointName -ErrorAction SilentlyContinue + + if ($endPoint -eq $null) + { + Write-Warning "Unable to create the remoting configuration endpoint for this PowerShell version: $(${PSVersionTable}.PSVersion)" + return $endPointName + } + } + + if ($endPoint.Permission -like "*NT AUTHORITY\NETWORK AccessDenied*") + { + Enable-PSRemoting -SkipNetworkProfileCheck + $endPoint = Get-PSSessionConfiguration -Name $endPointName -ErrorAction SilentlyContinue + + if ($endPoint.Permission -like "*NT AUTHORITY\NETWORK AccessDenied*") + { + Write-Warning "Unable to enable the remoting configuration endpoint: $(${PSVersionTable}.PSVersion)" + } + } + + return $endPointName +} + function New-RemoteRunspace { + param ( + [string] $ConfigurationName + ) + + # For PSCore6, we want to always test against a remoting endpoint running PSCore6 (not Windows PowerShell) + if ([string]::IsNullOrEmpty($ConfigurationName)) + { + $ConfigurationName = Get-DefaultEndPointName + } + $wsmanConInfo = [System.Management.Automation.Runspaces.WSManConnectionInfo]::new() + $wsmanConInfo.ShellUri = 'http://schemas.microsoft.com/powershell/' + $ConfigurationName + if ($Script:AppVeyorRemoteCred) { Write-Verbose "Using Global AppVeyor Credential" -Verbose @@ -27,6 +70,8 @@ function New-RemoteRunspace $remoteRunspace = [runspacefactory]::CreateRunspace($Host, $wsmanConInfo) $remoteRunspace.Open() + Write-Verbose "Successfully created remote runspace on endpoint: $ConfigurationName" + return $remoteRunspace } @@ -95,7 +140,14 @@ function New-RemoteSession [string] $Name, [string] $ConfigurationName, [switch] $CimSession, - [System.Management.Automation.Remoting.PSSessionOption] $SessionOption) + [System.Management.Automation.Remoting.PSSessionOption] $SessionOption + ) + + # For PSCore6, we want to always test against a remoting endpoint running PSCore6 (not Windows PowerShell) + if ([string]::IsNullOrEmpty($ConfigurationName)) + { + $ConfigurationName = Get-DefaultEndPointName + } $parameters = CreateParameters -Name $Name -ConfigurationName $ConfigurationName -SessionOption $SessionOption -CimSession:$CimSession.IsPresent @@ -105,6 +157,8 @@ function New-RemoteSession $session = New-PSSession @parameters } + Write-Verbose "Successfully created remote PSSession on endpoint: $ConfigurationName" + return $session } @@ -114,7 +168,14 @@ function Invoke-RemoteCommand [string] $ComputerName, [scriptblock] $ScriptBlock, [string] $ConfigurationName, - [switch] $InDisconnectedSession) + [switch] $InDisconnectedSession + ) + + # For PSCore6, we want to always test against a remoting endpoint running PSCore6 (not Windows PowerShell) + if ([string]::IsNullOrEmpty($ConfigurationName)) + { + $ConfigurationName = Get-DefaultEndPointName + } $parameters = CreateParameters -ComputerName $ComputerName -ConfigurationName $ConfigurationName diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 07685c4f0ea..270e21d73fb 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -91,22 +91,48 @@ function Add-UserToGroup Function Test-DailyBuild { $trueString = 'True' - if(($env:PS_DAILY_BUILD -eq $trueString) -or ($env:APPVEYOR_SCHEDULED_BUILD -eq $trueString) -or ($env:APPVEYOR_REPO_TAG_NAME)) + # PS_DAILY_BUILD says that we have previously determined that this is a daily build + # APPVEYOR_SCHEDULED_BUILD is True means that we are in an AppVeyor Scheduled build + # APPVEYOR_REPO_TAG_NAME means we are building a tag in AppVeyor + # BUILD_REASON is Schedule means we are in a VSTS Scheduled build + if(($env:PS_DAILY_BUILD -eq $trueString) -or ($env:APPVEYOR_SCHEDULED_BUILD -eq $trueString) -or ($env:APPVEYOR_REPO_TAG_NAME) -or $env:BUILD_REASON -eq 'Schedule') { return $true } # if [Feature] is in the commit message, # Run Daily tests - if($env:APPVEYOR_REPO_COMMIT_MESSAGE -match '\[feature\]') + $commitMessage = Get-CommitMessage + Write-Verbose "commitMessage: $commitMessage" -verbose + + if($commitMessage -match '\[feature\]' -or $env:FORCE_FEATURE -eq 'True') { - Set-AppveyorBuildVariable -Name PS_DAILY_BUILD -Value $trueString + Set-BuildVariable -Name PS_DAILY_BUILD -Value $trueString return $true } return $false } +# Returns the commit message for the current build +function Get-CommitMessage +{ + if ($env:APPVEYOR_REPO_COMMIT_MESSAGE) + { + return $env:APPVEYOR_REPO_COMMIT_MESSAGE + } + elseif ($env:BUILD_SOURCEVERSIONMESSAGE -match 'Merge\s*([0-9A-F]*)') + { + # We are in VSTS and have a commit ID in the Source Version Message + $commitId = $Matches[1] + return &git log --format=%B -n 1 $commitId + } + else + { + Write-Log "Unknown BUILD_SOURCEVERSIONMESSAGE format '$env:BUILD_SOURCEVERSIONMESSAGE'" -Verbose + } +} + # Sets a build variable Function Set-BuildVariable { @@ -205,28 +231,34 @@ function Invoke-AppVeyorInstall } if(Test-DailyBuild){ - $buildName = "[Daily]" - - # Add daily to title if it's not already there - # It can be there already for rerun requests - if($env:APPVEYOR_PULL_REQUEST_TITLE -and $env:APPVEYOR_PULL_REQUEST_TITLE -notmatch '^\[Daily\]') + if($env:APPVEYOR) { - $buildName += $env:APPVEYOR_PULL_REQUEST_TITLE - } - elseif($env:APPVEYOR_PULL_REQUEST_TITLE) - { - $buildName = $env:APPVEYOR_PULL_REQUEST_TITLE - } - elseif($env:APPVEYOR_REPO_COMMIT_MESSAGE -notmatch '^\[Daily\].*$') - { - $buildName += $env:APPVEYOR_REPO_COMMIT_MESSAGE + $buildName = "[Daily]" + + # Add daily to title if it's not already there + # It can be there already for rerun requests + if($env:APPVEYOR_PULL_REQUEST_TITLE -and $env:APPVEYOR_PULL_REQUEST_TITLE -notmatch '^\[Daily\]') + { + $buildName += $env:APPVEYOR_PULL_REQUEST_TITLE + } + elseif($env:APPVEYOR_PULL_REQUEST_TITLE) + { + $buildName = $env:APPVEYOR_PULL_REQUEST_TITLE + } + elseif($env:APPVEYOR_REPO_COMMIT_MESSAGE -notmatch '^\[Daily\].*$') + { + $buildName += $env:APPVEYOR_REPO_COMMIT_MESSAGE + } + else + { + $buildName = $env:APPVEYOR_REPO_COMMIT_MESSAGE + } + + Update-AppveyorBuild -message $buildName } - else - { - $buildName = $env:APPVEYOR_REPO_COMMIT_MESSAGE + elseif ($env:BUILD_REASON -eq 'Schedule') { + Write-Host "##vso[build.updatebuildnumber]Daily-$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))" } - - Update-AppveyorBuild -message $buildName } if ($env:APPVEYOR -or $env:TF_BUILD) @@ -467,13 +499,28 @@ function Invoke-AppVeyorAfterTest $codeCoverageArtifacts = Compress-CoverageArtifacts -CodeCoverageOutput $codeCoverageOutput Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts' - $codeCoverageArtifacts | ForEach-Object { Push-AppveyorArtifact $_ } + $codeCoverageArtifacts | ForEach-Object { + Push-Artifact -Path $_ + } + } +} + +# Wrapper to push artifact +function Push-Artifact +{ + param( + [Parameter(Mandatory)] + [ValidateScript({Test-Path -Path $_})] + $Path + ) - New-TestPackage -Destination $pwd - $testPackageFullName = Join-Path $pwd 'TestPackage.zip' - Write-Verbose "Created TestPackage.zip" -Verbose - Write-Host -ForegroundColor Green -'Upload test package' - Push-AppveyorArtifact $testPackageFullName + if($env:Appveyor) + { + Push-AppveyorArtifact $Path + } + elseif ($env:TF_BUILD -and $env:BUILD_REASON -ne 'PullRequest') { + # In VSTS + Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts;]$Path" } } @@ -511,7 +558,13 @@ function Get-ReleaseTag if($env:APPVEYOR_BUILD_NUMBER) { $releaseTag = $releaseTag.split('.')[0..2] -join '.' - $releaseTag = $releaseTag+'.'+$env:APPVEYOR_BUILD_NUMBER + $releaseTag = $releaseTag + '.' + $env:APPVEYOR_BUILD_NUMBER + } + elseif($env:BUILD_BUILID) + { + #In VSTS + $releaseTag = $releaseTag.split('.')[0..2] -join '.' + $releaseTag = $releaseTag + '.' + $env:BUILD_BUILID } return $releaseTag @@ -557,7 +610,14 @@ function Invoke-AppveyorFinish $previewLabel= "daily{0}" -f $previewLabel } - $preReleaseVersion = "$previewPrefix-$previewLabel.$env:APPVEYOR_BUILD_NUMBER" + if ($env:TF_BUILD) + { + $preReleaseVersion = "$previewPrefix-$previewLabel.$env:BUILD_BUILDID" + } + else + { + $preReleaseVersion = "$previewPrefix-$previewLabel.$env:APPVEYOR_BUILD_NUMBER" + } } # the packaging tests find the MSI package using env:PSMsiX64Path @@ -604,14 +664,7 @@ function Invoke-AppveyorFinish Write-Host "Pushing $_ as Appveyor artifact" if(Test-Path $_) { - if($env:Appveyor) - { - Push-AppveyorArtifact $_ - } - elseif ($env:TF_BUILD -and $env:BUILD_REASON -ne 'PullRequest') { - # In VSTS - Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts;]$_" - } + Push-Artifact -Path $_ } else {