diff --git a/.vsts-ci/templates/nanoserver.yml b/.vsts-ci/templates/nanoserver.yml new file mode 100644 index 0000000000..28e108e967 --- /dev/null +++ b/.vsts-ci/templates/nanoserver.yml @@ -0,0 +1,61 @@ +parameters: + vmImage: 'win1803' + jobName: 'Nanoserver_Tests' + continueOnError: false + +jobs: + +- job: ${{ parameters.jobName }} + variables: + scriptName: ${{ parameters.scriptName }} + + pool: + vmImage: ${{ parameters.vmImage }} + + displayName: ${{ parameters.jobName }} + + steps: + - script: | + set + displayName: Capture environment + condition: succeededOrFailed() + + - task: DownloadBuildArtifacts@0 + displayName: 'Download build artifacts' + inputs: + downloadType: specific + itemPattern: | + build/**/* + downloadPath: '$(System.ArtifactsDirectory)' + + - pwsh: | + Get-ChildItem "$(System.ArtifactsDirectory)\*" -Recurse + displayName: 'Capture artifacts directory' + continueOnError: true + + - pwsh: | + Install-module pester -Scope CurrentUser -Force + displayName: 'Install Pester' + continueOnError: true + + - pwsh: | + Import-Module .\tools\ci.psm1 + Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' + $options = (Get-PSOptions) + $path = split-path -path $options.Output + Write-Verbose "Path: '$path'" -Verbose + $rootPath = split-Path -path $path + Expand-Archive -Path '$(System.ArtifactsDirectory)\build\build.zip' -DestinationPath $rootPath -Force + Invoke-Pester -Path ./test/nanoserver -OutputFormat NUnitXml -OutputFile ./test-nanoserver.xml + displayName: Test + condition: succeeded() + + - task: PublishTestResults@2 + condition: succeededOrFailed() + displayName: Publish Nanoserver Test Results **\test*.xml + inputs: + testRunner: NUnit + testResultsFiles: '**\test*.xml' + testRunTitle: nanoserver + mergeTestResults: true + failTaskOnFailedTests: true diff --git a/.vsts-ci/windows.yml b/.vsts-ci/windows.yml index a7c616cd29..7b39314a20 100644 --- a/.vsts-ci/windows.yml +++ b/.vsts-ci/windows.yml @@ -73,6 +73,8 @@ stages: parameters: pool: 'Hosted VS2017' + - template: templates/nanoserver.yml + - stage: PackagingWin displayName: Packaging for Windows dependsOn: [] # by specifying an empty array, this stage doesn't depend on the stage before it diff --git a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/TaskbarJumpList.cs b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/TaskbarJumpList.cs index e567cd69ee..e6a5c2aa71 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/TaskbarJumpList.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/TaskbarJumpList.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; +using System.Management.Automation; using System.Reflection; using System.Threading; @@ -20,6 +21,13 @@ namespace Microsoft.PowerShell // not over-optimize this and always create the JumpList as a non-blocking background STA thread instead. internal static void CreateRunAsAdministratorJumpList() { + // The STA apartment state is not supported on NanoServer and Windows IoT. + // Plus, there is not need to create jump list in those environment anyways. + if (Platform.IsNanoServer || Platform.IsIoT) + { + return; + } + // Some COM APIs are implicitly STA only, therefore the executing thread must run in STA. var thread = new Thread(() => { diff --git a/test/nanoserver/nanoserver.tests.ps1 b/test/nanoserver/nanoserver.tests.ps1 new file mode 100644 index 0000000000..eb2cf76033 --- /dev/null +++ b/test/nanoserver/nanoserver.tests.ps1 @@ -0,0 +1,15 @@ +Describe "Verify PowerShell Runs" { + BeforeAll{ + $options = (Get-PSOptions) + $path = split-path -path $options.Output + Write-Verbose "Path: '$path'" -Verbose + $rootPath = split-Path -path $path + $mount = 'C:\powershell' + $container = 'mcr.microsoft.com/powershell:nanoserver-1803' + } + + it "Verify Version " { + $version = docker run --rm -v "${rootPath}:${mount}" ${container} "${mount}\publish\pwsh" -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' + $version | Should -match '^7\.' + } +}