From b4687adc7e47995a6b457ea82f850ad87a7c0eee Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 16:38:59 +0100 Subject: [PATCH 001/103] try upgrade to 2.2preview2 of .net core --- PowerShell.Common.props | 2 +- build.psm1 | 8 ++++---- docs/building/linux.md | 2 +- docs/building/macos.md | 2 +- docs/building/windows-core.md | 4 ++-- global.json | 2 +- test/Test.Common.props | 2 +- test/tools/OpenCover/OpenCover.psm1 | 2 +- tools/packaging/packaging.psm1 | 6 +++--- tools/packaging/packaging.strings.psd1 | 2 +- .../microsoft_powershell_alpine3/build-and-run-pwsh.sh | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index d25ddac462b..65f5ec37939 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -93,7 +93,7 @@ Microsoft Corporation (c) Microsoft Corporation. All rights reserved. - netcoreapp2.1 + netcoreapp2.2 2.1.5 Latest diff --git a/build.psm1 b/build.psm1 index aac038df249..952d5285b78 100644 --- a/build.psm1 +++ b/build.psm1 @@ -9,7 +9,7 @@ $script:TestModulePathSeparator = [System.IO.Path]::PathSeparator $script:TestModuleDirPath = Join-Path ([System.IO.Path]::GetTempPath()) 'PwshTestModules' $null = New-Item -Force -ItemType Directory -Path $script:TestModuleDirPath -$dotnetCLIChannel = "release" +$dotnetCLIChannel = 'preview' # TODO: Change this to 'release' once .Net Core 2.2 goes RTM $dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version # Track if tags have been sync'ed @@ -380,7 +380,7 @@ Fix steps: Pop-Location } - # publish netcoreapp2.1 reference assemblies + # publish netcoreapp2.2 reference assemblies try { Push-Location "$PSScriptRoot/src/TypeCatalogGen" $refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') } @@ -580,7 +580,7 @@ function New-PSOptions { [ValidateSet("Debug", "Release", "CodeCoverage", '')] [string]$Configuration, - [ValidateSet("netcoreapp2.1")] + [ValidateSet("netcoreapp2.2")] [string]$Framework, # These are duplicated from Start-PSBuild @@ -633,7 +633,7 @@ function New-PSOptions { Write-Verbose "Top project directory is $Top" if (-not $Framework) { - $Framework = "netcoreapp2.1" + $Framework = "netcoreapp2.2" Write-Verbose "Using framework '$Framework'" } diff --git a/docs/building/linux.md b/docs/building/linux.md index be37662a19f..32ff1c7e3ac 100644 --- a/docs/building/linux.md +++ b/docs/building/linux.md @@ -71,7 +71,7 @@ Start-PSBuild Congratulations! If everything went right, PowerShell is now built. The `Start-PSBuild` script will output the location of the executable: -`./src/powershell-unix/bin/Debug/netcoreapp2.1/linux-x64/publish/pwsh`. +`./src/powershell-unix/bin/Debug/netcoreapp2.2/linux-x64/publish/pwsh`. You should now be running the PowerShell Core that you just built, if your run the above executable. You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`. diff --git a/docs/building/macos.md b/docs/building/macos.md index 8f4e2594105..9df5ee95721 100644 --- a/docs/building/macos.md +++ b/docs/building/macos.md @@ -36,4 +36,4 @@ We cannot do this for you in the build module due to #[847][]. Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module. -After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp2.1/osx-x64/publish/pwsh`. +After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp2.2/osx-x64/publish/pwsh`. diff --git a/docs/building/windows-core.md b/docs/building/windows-core.md index 92755f323db..81c049f5b46 100644 --- a/docs/building/windows-core.md +++ b/docs/building/windows-core.md @@ -58,11 +58,11 @@ Import-Module ./build.psm1 Start-PSBuild ``` -Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp2.1/win7-x64/publish/pwsh.exe`. +Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp2.2/win7-x64/publish/pwsh.exe`. This location is of the form `./[project]/bin/[configuration]/[framework]/[rid]/publish/[binary name]`, and our project is `powershell`, configuration is `Debug` by default, -framework is `netcoreapp2.1`, runtime identifier is `win7-x64` by default, +framework is `netcoreapp2.2`, runtime identifier is `win7-x64` by default, and binary name is `pwsh`. The function `Get-PSOutput` will return the path to the executable; thus you can execute the development copy via `& (Get-PSOutput)`. diff --git a/global.json b/global.json index 55e448dfe00..d6ef34167ac 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.2.100-preview2" } } diff --git a/test/Test.Common.props b/test/Test.Common.props index 11b20a9fed7..8e24622a19f 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -4,7 +4,7 @@ Microsoft Corporation (c) Microsoft Corporation. All rights reserved. - netcoreapp2.1 + netcoreapp2.2 2.1.5 true diff --git a/test/tools/OpenCover/OpenCover.psm1 b/test/tools/OpenCover/OpenCover.psm1 index 78502650761..dbafa8b722a 100644 --- a/test/tools/OpenCover/OpenCover.psm1 +++ b/test/tools/OpenCover/OpenCover.psm1 @@ -624,7 +624,7 @@ function Invoke-OpenCover [parameter()]$OutputLog = "$home/Documents/OpenCover.xml", [parameter()]$TestPath = "${script:psRepoPath}/test/powershell", [parameter()]$OpenCoverPath = "$home/OpenCover", - [parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp2.1/win7-x64/publish", + [parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp2.2/win7-x64/publish", [parameter()]$PesterLogElevated = "$HOME/Documents/TestResultsElevated.xml", [parameter()]$PesterLogUnelevated = "$HOME/Documents/TestResultsUnelevated.xml", [parameter()]$PesterLogFormat = "NUnitXml", diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index dd15d2e6924..88d156ef97c 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -117,14 +117,14 @@ function Start-PSPackage { -not $Script:Options -or ## Start-PSBuild hasn't been executed yet -not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' - $Script:Options.Framework -ne "netcoreapp2.1" ## Last build wasn't for CoreCLR + $Script:Options.Framework -ne "netcoreapp2.2" ## Last build wasn't for CoreCLR } else { -not $Script:Options -or ## Start-PSBuild hasn't been executed yet -not $crossGenCorrect -or ## Last build didn't specify '-CrossGen' correctly -not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly $Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' - $Script:Options.Framework -ne "netcoreapp2.1" ## Last build wasn't for CoreCLR + $Script:Options.Framework -ne "netcoreapp2.2" ## Last build wasn't for CoreCLR } # Make sure the most recent build satisfies the package requirement @@ -2432,7 +2432,7 @@ function New-MSIPatch # This example shows how to produce a Debug-x64 installer for development purposes. cd $RootPathOfPowerShellRepo Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1 - New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' + New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.2\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' #> function New-MSIPackage { diff --git a/tools/packaging/packaging.strings.psd1 b/tools/packaging/packaging.strings.psd1 index 1e862b5885b..a562533cbdd 100644 --- a/tools/packaging/packaging.strings.psd1 +++ b/tools/packaging/packaging.strings.psd1 @@ -127,7 +127,7 @@ NuspecTemplate = @' - + diff --git a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh index e7144c9c505..fabb5d721f0 100755 --- a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh +++ b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh @@ -94,10 +94,10 @@ cd ../powershell-unix dotnet publish --configuration Release --runtime linux-musl-x64 $dotnetArguments # add libpsl-native to build -mv libpsl-native.so bin/Release/netcoreapp2.1/linux-musl-x64/publish +mv libpsl-native.so bin/Release/netcoreapp2.2/linux-musl-x64/publish # tar build for output -cd bin/Release/netcoreapp2.1/linux-musl-x64/publish +cd bin/Release/netcoreapp2.2/linux-musl-x64/publish tar -czvf $tarName . From 56ba0a129c7c11893cccc19dca7a80c66772bb83 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 16:43:07 +0100 Subject: [PATCH 002/103] fix version number of sdk (needs to include build number) --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index d6ef34167ac..f83fbed4ce7 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.2.100-preview2" + "version": "2.2.100-preview2-009404" } } From b961bc21dfaf800aade9571514f75aa2ed288950 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 19:54:21 +0100 Subject: [PATCH 003/103] [feature] set runtimeversion and revert changes made to alpine docker image creation process --- PowerShell.Common.props | 2 +- appveyor.yml | 2 +- test/Test.Common.props | 2 +- test/tools/WebListener/WebListener.csproj | 2 +- .../Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 65f5ec37939..2d083e20dca 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -94,7 +94,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp2.2 - 2.1.5 + 2.2.0-preview2-26905-02 Latest true diff --git a/appveyor.yml b/appveyor.yml index 45bda6488b4..7a7618957f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Purpose: ElevatedPesterTests_xUnit_Packaging -# cache version - netcoreapp.2.1-sdk.2.1.403 +# cache version - netcoreapp2.2.100-preview2-009404 cache: - '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml' diff --git a/test/Test.Common.props b/test/Test.Common.props index 8e24622a19f..4bbdae89a21 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp2.2 - 2.1.5 + 2.2.0-preview2-26905-02 true true diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index a24e519ac4f..6ba331e7c22 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,7 +7,7 @@ - + diff --git a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh index fabb5d721f0..e7144c9c505 100755 --- a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh +++ b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh @@ -94,10 +94,10 @@ cd ../powershell-unix dotnet publish --configuration Release --runtime linux-musl-x64 $dotnetArguments # add libpsl-native to build -mv libpsl-native.so bin/Release/netcoreapp2.2/linux-musl-x64/publish +mv libpsl-native.so bin/Release/netcoreapp2.1/linux-musl-x64/publish # tar build for output -cd bin/Release/netcoreapp2.2/linux-musl-x64/publish +cd bin/Release/netcoreapp2.1/linux-musl-x64/publish tar -czvf $tarName . From 04f8a7d7bee2869102cd66d6167535acfd6ba651 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 20:58:38 +0100 Subject: [PATCH 004/103] [feature] Fix NuGet package version of WebListener.csproj test project (build number does not match sdk) --- test/tools/WebListener/WebListener.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 6ba331e7c22..8d1731f18a6 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,7 +7,7 @@ - + From 35716298830cc4bc41cab6722fac8b941e582deb Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 21:18:53 +0100 Subject: [PATCH 005/103] [feature] Fix WiX file components due to newer versions of DLLS --- assets/files.wxs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index a7e70612a50..b3a795de852 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -2017,11 +2017,11 @@ - - + + - - + + @@ -2670,8 +2670,8 @@ - - + + From 0a61826f4f1c9f99463bac1f1ff8f380e246430f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 6 Oct 2018 21:42:35 +0100 Subject: [PATCH 006/103] trigger ci From 97a67bea0b19cfb2cc01bb646c7910aacbedeff5 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 00:20:01 +0100 Subject: [PATCH 007/103] The dotnet-xunit test runner does not work with .Net Core 2.2 and due to problems, they have stopped supporting it, therefore use dotnet test as an alternative https://github.com/xunit/xunit/issues/1675 https://xunit.github.io/releases/2.4 --- build.psm1 | 30 ++++++++++++++++-------------- test/csharp/csharp.tests.csproj | 2 -- test/hosting/hosting.tests.csproj | 2 -- tools/appveyor.psm1 | 14 +++++++------- tools/travis.ps1 | 8 ++++---- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/build.psm1 b/build.psm1 index 952d5285b78..03a938d7e9c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1357,8 +1357,8 @@ function Test-PSPesterResults function Start-PSxUnit { [CmdletBinding()]param( - [string] $SequentialTestResultsFile = "SequentialXUnitResults.xml", - [string] $ParallelTestResultsFile = "ParallelXUnitResults.xml" + [string] $SequentialTestResultsFolder = "SequentialXUnitResults", + [string] $ParallelTestResultsFolder = "ParallelXUnitResults" ) # Add .NET CLI tools to PATH @@ -1369,13 +1369,6 @@ function Start-PSxUnit { throw "PowerShell must be built before running tests!" } - if (Test-Path $SequentialTestResultsFile) { - Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue - } - if (Test-Path $ParallelTestResultsFile) { - Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue - } - try { Push-Location $PSScriptRoot/test/csharp @@ -1412,10 +1405,14 @@ function Start-PSxUnit { } } + if (Test-Path (Join-Path $pwd $SequentialTestResultsFolder)) { + Remove-Item $SequentialTestResultsFolder -Force -Recurse -ErrorAction SilentlyContinue + } # Run sequential tests first, and then run the tests that can execute in parallel - dotnet xunit -configuration $Options.configuration -xml $SequentialTestResultsFile -namespace "PSTests.Sequential" -parallel none - - Publish-TestResults -Path $SequentialTestResultsFile -Type 'XUnit' -Title 'Xunit Sequential' + $sequentialResultDirectory = Join-Path $pwd $SequentialTestResultsFolder + dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential --logger:trx -p:ParallelizeTestCollections=false --results-directory $sequentialResultDirectory + $sequentialTestResultsFile = Get-ChildItem $sequentialResultDirectory + Publish-TestResults -Path $sequentialTestResultsFile.FullName -Type 'NUnit' -Title 'Xunit Sequential' $extraParams = @() @@ -1430,8 +1427,13 @@ function Start-PSxUnit { ) } - dotnet xunit -configuration $Options.configuration -xml $ParallelTestResultsFile -namespace "PSTests.Parallel" -nobuild @extraParams - Publish-TestResults -Path $ParallelTestResultsFile -Type 'XUnit' -Title 'Xunit Parallel' + if (Test-Path (Join-Path $pwd $ParallelTestResultsFolder)) { + Remove-Item $ParallelTestResultsFolder -Force -Recurse -ErrorAction SilentlyContinue + } + $parallelResultDirectory = Join-Path $pwd $ParallelTestResultsFolder + dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --logger:trx --no-build --results-directory $parallelResultDirectory + $parallelTestResultsFile = Get-ChildItem $parallelResultDirectory + Publish-TestResults -Path $parallelTestResultsFile.FullName -Type 'NUnit' -Title 'Xunit Parallel' } finally { Pop-Location diff --git a/test/csharp/csharp.tests.csproj b/test/csharp/csharp.tests.csproj index ba31c86b5fd..c3d6d999049 100644 --- a/test/csharp/csharp.tests.csproj +++ b/test/csharp/csharp.tests.csproj @@ -24,8 +24,6 @@ - - diff --git a/test/hosting/hosting.tests.csproj b/test/hosting/hosting.tests.csproj index 82c6b8f298c..c021c1a6cbd 100644 --- a/test/hosting/hosting.tests.csproj +++ b/test/hosting/hosting.tests.csproj @@ -17,8 +17,6 @@ - - diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index b70cb093cd5..8190658bc84 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -337,8 +337,8 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Run CoreCLR tests' $testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml" $testResultsAdminFile = "$pwd\TestsResultsAdmin.xml" - $SequentialXUnitTestResultsFile = "$pwd\SequentialXUnitTestResults.xml" - $ParallelXUnitTestResultsFile = "$pwd\ParallelXUnitTestResults.xml" + $SequentialXUnitTestResultsFolder = "$pwd\SequentialXUnitTestResults" + $ParallelXUnitTestResultsFolder = "$pwd\ParallelXUnitTestResults" if(!(Test-Path "$env:CoreOutput\pwsh.exe")) { throw "CoreCLR pwsh.exe was not built" @@ -411,16 +411,16 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFile $ParallelXUnitTestResultsFolder Write-Host -ForegroundColor Green 'Uploading PSxUnit test results' - Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFile - Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFile + Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFolder + Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFolder # Fail the build, if tests failed Test-PSPesterResults -TestResultsFile $testResultsAdminFile @( - $SequentialXUnitTestResultsFile, - $ParallelXUnitTestResultsFile + $SequentialXUnitTestResultsFolder, + $ParallelXUnitTestResultsFolder ) | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 791ca4560cb..415937fd552 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -330,12 +330,12 @@ elseif($Stage -eq 'Build') } try { - $SequentialXUnitTestResultsFile = "$pwd/SequentialXUnitTestResults.xml" - $ParallelXUnitTestResultsFile = "$pwd/ParallelXUnitTestResults.xml" + $SequentialXUnitTestResultsFolder = "$pwd/SequentialXUnitTestResults" + $ParallelXUnitTestResultsFolder = "$pwd/ParallelXUnitTestResults" - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFile $ParallelXUnitTestResultsFolder # If there are failures, Test-XUnitTestResults throws - $SequentialXUnitTestResultsFile, $ParallelXUnitTestResultsFile | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } + $SequentialXUnitTestResultsFolder, $ParallelXUnitTestResultsFolder | ForEach-Object { Test-XUnitTestResults -TestResultsFolder $_ } } catch { $result = "FAIL" From 9c48a7af43b62e242025b94e97ac46046507a5d9 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 00:31:55 +0100 Subject: [PATCH 008/103] I forgot that trx format ix VsTest, not NUnit --- build.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.psm1 b/build.psm1 index 03a938d7e9c..bd7ad6ead43 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1172,7 +1172,7 @@ function Publish-TestResults [string] $Path, - [ValidateSet('NUnit','XUnit')] + [ValidateSet('NUnit','VsTest')] [string] $Type='NUnit' ) @@ -1412,7 +1412,7 @@ function Start-PSxUnit { $sequentialResultDirectory = Join-Path $pwd $SequentialTestResultsFolder dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential --logger:trx -p:ParallelizeTestCollections=false --results-directory $sequentialResultDirectory $sequentialTestResultsFile = Get-ChildItem $sequentialResultDirectory - Publish-TestResults -Path $sequentialTestResultsFile.FullName -Type 'NUnit' -Title 'Xunit Sequential' + Publish-TestResults -Path $sequentialTestResultsFile.FullName -Type 'VsTest' -Title 'Xunit Sequential' $extraParams = @() @@ -1433,7 +1433,7 @@ function Start-PSxUnit { $parallelResultDirectory = Join-Path $pwd $ParallelTestResultsFolder dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --logger:trx --no-build --results-directory $parallelResultDirectory $parallelTestResultsFile = Get-ChildItem $parallelResultDirectory - Publish-TestResults -Path $parallelTestResultsFile.FullName -Type 'NUnit' -Title 'Xunit Parallel' + Publish-TestResults -Path $parallelTestResultsFile.FullName -Type 'VsTest' -Title 'Xunit Parallel' } finally { Pop-Location From 91d1c8287013a701662983e1966bdb46480f657b Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 00:33:10 +0100 Subject: [PATCH 009/103] [feature] From 17fab9b53a0f5d200f8e77935ef1a2698be0ab68 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 01:00:10 +0100 Subject: [PATCH 010/103] [feature] Fix parameter name due to rename --- tools/appveyor.psm1 | 2 +- tools/travis.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 8190658bc84..13ad8e6c9ec 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -411,7 +411,7 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile - Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFile $ParallelXUnitTestResultsFolder + Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFolder $ParallelXUnitTestResultsFolder Write-Host -ForegroundColor Green 'Uploading PSxUnit test results' Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFolder Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFolder diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 415937fd552..97023515f85 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -333,7 +333,7 @@ elseif($Stage -eq 'Build') $SequentialXUnitTestResultsFolder = "$pwd/SequentialXUnitTestResults" $ParallelXUnitTestResultsFolder = "$pwd/ParallelXUnitTestResults" - Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFile $ParallelXUnitTestResultsFolder + Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFolder $ParallelXUnitTestResultsFolder # If there are failures, Test-XUnitTestResults throws $SequentialXUnitTestResultsFolder, $ParallelXUnitTestResultsFolder | ForEach-Object { Test-XUnitTestResults -TestResultsFolder $_ } } From 5750e86d272d8f63c376a6ac6637bf5913e81fd4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 10:07:33 +0100 Subject: [PATCH 011/103] [feature] revert to use xml test logger again --- build.psm1 | 28 ++++++++++++---------------- test/csharp/csharp.tests.csproj | 3 ++- test/hosting/hosting.tests.csproj | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/build.psm1 b/build.psm1 index bd7ad6ead43..9dca1546f93 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1172,7 +1172,7 @@ function Publish-TestResults [string] $Path, - [ValidateSet('NUnit','VsTest')] + [ValidateSet('NUnit','XUnit')] [string] $Type='NUnit' ) @@ -1357,8 +1357,8 @@ function Test-PSPesterResults function Start-PSxUnit { [CmdletBinding()]param( - [string] $SequentialTestResultsFolder = "SequentialXUnitResults", - [string] $ParallelTestResultsFolder = "ParallelXUnitResults" + [string] $SequentialTestResultsFile = "SequentialXUnitResults.xml", + [string] $ParallelTestResultsFile = "ParallelXUnitResults.xml" ) # Add .NET CLI tools to PATH @@ -1405,14 +1405,12 @@ function Start-PSxUnit { } } - if (Test-Path (Join-Path $pwd $SequentialTestResultsFolder)) { - Remove-Item $SequentialTestResultsFolder -Force -Recurse -ErrorAction SilentlyContinue - } # Run sequential tests first, and then run the tests that can execute in parallel - $sequentialResultDirectory = Join-Path $pwd $SequentialTestResultsFolder - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential --logger:trx -p:ParallelizeTestCollections=false --results-directory $sequentialResultDirectory - $sequentialTestResultsFile = Get-ChildItem $sequentialResultDirectory - Publish-TestResults -Path $sequentialTestResultsFile.FullName -Type 'VsTest' -Title 'Xunit Sequential' + if (Test-Path $SequentialTestResultsFile) { + Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue + } + dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential -p:ParallelizeTestCollections=false --test-adapter-path:. "--logger:xunit;LogFilePath=$SequentialTestResultsFile" + Publish-TestResults -Path $sequentialTestResultsFile -Type 'XUnit' -Title 'Xunit Sequential' $extraParams = @() @@ -1427,13 +1425,11 @@ function Start-PSxUnit { ) } - if (Test-Path (Join-Path $pwd $ParallelTestResultsFolder)) { - Remove-Item $ParallelTestResultsFolder -Force -Recurse -ErrorAction SilentlyContinue + if (Test-Path $ParallelTestResultsFile) { + Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue } - $parallelResultDirectory = Join-Path $pwd $ParallelTestResultsFolder - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --logger:trx --no-build --results-directory $parallelResultDirectory - $parallelTestResultsFile = Get-ChildItem $parallelResultDirectory - Publish-TestResults -Path $parallelTestResultsFile.FullName -Type 'VsTest' -Title 'Xunit Parallel' + dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" + Publish-TestResults -Path $parallelTestResultsFile -Type 'XUnit' -Title 'Xunit Parallel' } finally { Pop-Location diff --git a/test/csharp/csharp.tests.csproj b/test/csharp/csharp.tests.csproj index c3d6d999049..c4326b26b77 100644 --- a/test/csharp/csharp.tests.csproj +++ b/test/csharp/csharp.tests.csproj @@ -22,8 +22,9 @@ - + + diff --git a/test/hosting/hosting.tests.csproj b/test/hosting/hosting.tests.csproj index c021c1a6cbd..ca4ec43d2d7 100644 --- a/test/hosting/hosting.tests.csproj +++ b/test/hosting/hosting.tests.csproj @@ -16,9 +16,9 @@ - - + + From b75514aa44ff71d5fba7501d21f61c467193dbfe Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 10:12:48 +0100 Subject: [PATCH 012/103] [feature] forgot some folder->file reverts --- tools/appveyor.psm1 | 14 +++++++------- tools/travis.ps1 | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 13ad8e6c9ec..b70cb093cd5 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -337,8 +337,8 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Run CoreCLR tests' $testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml" $testResultsAdminFile = "$pwd\TestsResultsAdmin.xml" - $SequentialXUnitTestResultsFolder = "$pwd\SequentialXUnitTestResults" - $ParallelXUnitTestResultsFolder = "$pwd\ParallelXUnitTestResults" + $SequentialXUnitTestResultsFile = "$pwd\SequentialXUnitTestResults.xml" + $ParallelXUnitTestResultsFile = "$pwd\ParallelXUnitTestResults.xml" if(!(Test-Path "$env:CoreOutput\pwsh.exe")) { throw "CoreCLR pwsh.exe was not built" @@ -411,16 +411,16 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile - Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFolder $ParallelXUnitTestResultsFolder + Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile Write-Host -ForegroundColor Green 'Uploading PSxUnit test results' - Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFolder - Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFolder + Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFile + Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFile # Fail the build, if tests failed Test-PSPesterResults -TestResultsFile $testResultsAdminFile @( - $SequentialXUnitTestResultsFolder, - $ParallelXUnitTestResultsFolder + $SequentialXUnitTestResultsFile, + $ParallelXUnitTestResultsFile ) | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 97023515f85..791ca4560cb 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -330,12 +330,12 @@ elseif($Stage -eq 'Build') } try { - $SequentialXUnitTestResultsFolder = "$pwd/SequentialXUnitTestResults" - $ParallelXUnitTestResultsFolder = "$pwd/ParallelXUnitTestResults" + $SequentialXUnitTestResultsFile = "$pwd/SequentialXUnitTestResults.xml" + $ParallelXUnitTestResultsFile = "$pwd/ParallelXUnitTestResults.xml" - Start-PSxUnit -SequentialTestResultsFolder $SequentialXUnitTestResultsFolder -ParallelTestResultsFolder $ParallelXUnitTestResultsFolder + Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile # If there are failures, Test-XUnitTestResults throws - $SequentialXUnitTestResultsFolder, $ParallelXUnitTestResultsFolder | ForEach-Object { Test-XUnitTestResults -TestResultsFolder $_ } + $SequentialXUnitTestResultsFile, $ParallelXUnitTestResultsFile | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } } catch { $result = "FAIL" From e0924411cf6fff2f44aabe9fb91f1e12d960350c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 10:55:10 +0100 Subject: [PATCH 013/103] [feature] Update Markdig.Signed NuGet package to 0.15.4 due to new release 2h ago --- .../Microsoft.PowerShell.MarkdownRender.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.MarkdownRender/Microsoft.PowerShell.MarkdownRender.csproj b/src/Microsoft.PowerShell.MarkdownRender/Microsoft.PowerShell.MarkdownRender.csproj index 975e7757823..1481ead2b16 100644 --- a/src/Microsoft.PowerShell.MarkdownRender/Microsoft.PowerShell.MarkdownRender.csproj +++ b/src/Microsoft.PowerShell.MarkdownRender/Microsoft.PowerShell.MarkdownRender.csproj @@ -9,7 +9,7 @@ - + From 699afb8ac5059fa99b3e10d33b837c008b06e3d9 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 7 Oct 2018 12:07:05 +0100 Subject: [PATCH 014/103] [feature] retrigger CI due to sporadic failure From 7de084d33bd0757d280cd6a2762e9d6876c1895f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 10 Oct 2018 22:17:48 +0100 Subject: [PATCH 015/103] fix merge conflict error to have no diff again in the upstreamed xunit code --- build.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.psm1 b/build.psm1 index b4776579ccc..5aab20bbc70 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1410,6 +1410,8 @@ function Start-PSxUnit { Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue } dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential -p:ParallelizeTestCollections=false --test-adapter-path:. "--logger:xunit;LogFilePath=$SequentialTestResultsFile" + Publish-TestResults -Path $SequentialTestResultsFile -Type 'XUnit' -Title 'Xunit Sequential' + $extraParams = @() # we are having intermittent issues on macOS with these tests failing. From fda3fb9a21ee440f013474580aca785b1e07cc75 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 22 Oct 2018 21:27:47 +0100 Subject: [PATCH 016/103] Update to .Net Core 2.2-preview3 --- PowerShell.Common.props | 2 +- global.json | 2 +- test/tools/WebListener/WebListener.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 2d083e20dca..79a33e915a1 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -94,7 +94,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp2.2 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-27014-02 Latest true diff --git a/global.json b/global.json index f83fbed4ce7..b082538e039 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.2.100-preview2-009404" + "version": "2.2.100-preview3-009430" } } diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 8d1731f18a6..4fc854c36a0 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,7 +7,7 @@ - + From 8a13d7cb3a47de98b3a48e55e4164a2bfba8164c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 22 Oct 2018 21:29:00 +0100 Subject: [PATCH 017/103] [feature] udpate test project version and appveyor cache --- appveyor.yml | 2 +- test/Test.Common.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7a7618957f8..74cc5bada1f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Purpose: ElevatedPesterTests_xUnit_Packaging -# cache version - netcoreapp2.2.100-preview2-009404 +# cache version - netcoreapp2.2.100-preview3-009430 cache: - '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml' diff --git a/test/Test.Common.props b/test/Test.Common.props index 4bbdae89a21..d4a9fcad66a 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp2.2 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-27014-02 true true From 52de7b779ec7df84c84de3ba755fd0c4278b1bee Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 22 Oct 2018 22:39:31 +0100 Subject: [PATCH 018/103] [feature] Fix MSI installer by updating to the new version of mscordaccore and sos due to the upgrade from preview2 to preview3 --- assets/files.wxs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index f29ed29b183..31807510065 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -2018,10 +2018,10 @@ - + - + From d6f499c390a21fc833eb4e1e3ed6fbccc6654555 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 13:22:29 +0000 Subject: [PATCH 019/103] Upgrade to .Net Core 3.0.100-preview-009806 (latest master) --- PowerShell.Common.props | 4 ++-- appveyor.yml | 2 +- build.psm1 | 6 +++--- docs/building/linux.md | 2 +- docs/building/macos.md | 2 +- docs/building/windows-core.md | 4 ++-- global.json | 2 +- test/Test.Common.props | 4 ++-- test/tools/OpenCover/OpenCover.psm1 | 2 +- tools/packaging/packaging.psm1 | 6 +++--- tools/packaging/packaging.strings.psd1 | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 79a33e915a1..860972f44ac 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -93,8 +93,8 @@ Microsoft Corporation (c) Microsoft Corporation. All rights reserved. - netcoreapp2.2 - 2.2.0-preview3-27014-02 + netcoreapp3.0 + 3.0.0-alpha-27128-4 Latest true diff --git a/appveyor.yml b/appveyor.yml index 140bb155f91..2a42ffb47f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Purpose: ElevatedPesterTests_xUnit_Packaging -# cache version - netcoreapp2.2.100-preview3-009430 +# cache version - netcoreapp3.0.100-preview-009806 cache: - '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml' diff --git a/build.psm1 b/build.psm1 index 314525b920a..229ddb08ce3 100644 --- a/build.psm1 +++ b/build.psm1 @@ -388,7 +388,7 @@ Fix steps: Pop-Location } - # publish netcoreapp2.2 reference assemblies + # publish netcoreapp3.0 reference assemblies try { Push-Location "$PSScriptRoot/src/TypeCatalogGen" $refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') } @@ -588,7 +588,7 @@ function New-PSOptions { [ValidateSet("Debug", "Release", "CodeCoverage", '')] [string]$Configuration, - [ValidateSet("netcoreapp2.2")] + [ValidateSet("netcoreapp3.0")] [string]$Framework, # These are duplicated from Start-PSBuild @@ -645,7 +645,7 @@ function New-PSOptions { Write-Verbose "Top project directory is $Top" if (-not $Framework) { - $Framework = "netcoreapp2.2" + $Framework = "netcoreapp3.0" Write-Verbose "Using framework '$Framework'" } diff --git a/docs/building/linux.md b/docs/building/linux.md index 32ff1c7e3ac..cb00b692998 100644 --- a/docs/building/linux.md +++ b/docs/building/linux.md @@ -71,7 +71,7 @@ Start-PSBuild Congratulations! If everything went right, PowerShell is now built. The `Start-PSBuild` script will output the location of the executable: -`./src/powershell-unix/bin/Debug/netcoreapp2.2/linux-x64/publish/pwsh`. +`./src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/pwsh`. You should now be running the PowerShell Core that you just built, if your run the above executable. You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`. diff --git a/docs/building/macos.md b/docs/building/macos.md index 9df5ee95721..536d3669996 100644 --- a/docs/building/macos.md +++ b/docs/building/macos.md @@ -36,4 +36,4 @@ We cannot do this for you in the build module due to #[847][]. Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module. -After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp2.2/osx-x64/publish/pwsh`. +After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/pwsh`. diff --git a/docs/building/windows-core.md b/docs/building/windows-core.md index 81c049f5b46..ed45a2ae958 100644 --- a/docs/building/windows-core.md +++ b/docs/building/windows-core.md @@ -58,11 +58,11 @@ Import-Module ./build.psm1 Start-PSBuild ``` -Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp2.2/win7-x64/publish/pwsh.exe`. +Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp3.0/win7-x64/publish/pwsh.exe`. This location is of the form `./[project]/bin/[configuration]/[framework]/[rid]/publish/[binary name]`, and our project is `powershell`, configuration is `Debug` by default, -framework is `netcoreapp2.2`, runtime identifier is `win7-x64` by default, +framework is `netcoreapp3.0`, runtime identifier is `win7-x64` by default, and binary name is `pwsh`. The function `Get-PSOutput` will return the path to the executable; thus you can execute the development copy via `& (Get-PSOutput)`. diff --git a/global.json b/global.json index b082538e039..95e00960423 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.2.100-preview3-009430" + "version": "3.0.100-preview-009806" } } diff --git a/test/Test.Common.props b/test/Test.Common.props index d4a9fcad66a..707118a96aa 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -4,8 +4,8 @@ Microsoft Corporation (c) Microsoft Corporation. All rights reserved. - netcoreapp2.2 - 2.2.0-preview3-27014-02 + netcoreapp3.0 + 3.0.0-alpha-27128-4 true true diff --git a/test/tools/OpenCover/OpenCover.psm1 b/test/tools/OpenCover/OpenCover.psm1 index dbafa8b722a..d64dc9e5eb8 100644 --- a/test/tools/OpenCover/OpenCover.psm1 +++ b/test/tools/OpenCover/OpenCover.psm1 @@ -624,7 +624,7 @@ function Invoke-OpenCover [parameter()]$OutputLog = "$home/Documents/OpenCover.xml", [parameter()]$TestPath = "${script:psRepoPath}/test/powershell", [parameter()]$OpenCoverPath = "$home/OpenCover", - [parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp2.2/win7-x64/publish", + [parameter()]$PowerShellExeDirectory = "${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp3.0/win7-x64/publish", [parameter()]$PesterLogElevated = "$HOME/Documents/TestResultsElevated.xml", [parameter()]$PesterLogUnelevated = "$HOME/Documents/TestResultsUnelevated.xml", [parameter()]$PesterLogFormat = "NUnitXml", diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index a20ddcbf5a0..96c7f6dc9ee 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -117,14 +117,14 @@ function Start-PSPackage { -not $Script:Options -or ## Start-PSBuild hasn't been executed yet -not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' - $Script:Options.Framework -ne "netcoreapp2.2" ## Last build wasn't for CoreCLR + $Script:Options.Framework -ne "netcoreapp3.0" ## Last build wasn't for CoreCLR } else { -not $Script:Options -or ## Start-PSBuild hasn't been executed yet -not $crossGenCorrect -or ## Last build didn't specify '-CrossGen' correctly -not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly $Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' - $Script:Options.Framework -ne "netcoreapp2.2" ## Last build wasn't for CoreCLR + $Script:Options.Framework -ne "netcoreapp3.0" ## Last build wasn't for CoreCLR } # Make sure the most recent build satisfies the package requirement @@ -2448,7 +2448,7 @@ function New-MSIPatch # This example shows how to produce a Debug-x64 installer for development purposes. cd $RootPathOfPowerShellRepo Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1 - New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.2\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' + New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp3.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' #> function New-MSIPackage { diff --git a/tools/packaging/packaging.strings.psd1 b/tools/packaging/packaging.strings.psd1 index a562533cbdd..a3df379f8d5 100644 --- a/tools/packaging/packaging.strings.psd1 +++ b/tools/packaging/packaging.strings.psd1 @@ -127,7 +127,7 @@ NuspecTemplate = @' - + From 0450437de01174f259f2fd2d4916e9584c05d242 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 14:19:17 +0000 Subject: [PATCH 020/103] fix runtime version --- PowerShell.Common.props | 2 +- test/Test.Common.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 860972f44ac..e5c461e57c3 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -94,7 +94,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-alpha-27128-4 + 3.0.0-preview-27122-01 Latest true diff --git a/test/Test.Common.props b/test/Test.Common.props index 707118a96aa..493b353c66f 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-alpha-27128-4 + 3.0.0-preview-27122-01 true true From ede5bc68f66738b37ffa2220bb984a6a0225613a Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 15:03:40 +0000 Subject: [PATCH 021/103] fix installer and ignore nupkg info files --- assets/files.wxs | 24 ++++++++++++++++++++++-- tools/packaging/packaging.psm1 | 5 ++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index 31807510065..f98c93f9a64 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -46,6 +46,15 @@ + + + + + + + + + @@ -1232,6 +1241,9 @@ + + + @@ -1241,6 +1253,9 @@ + + + @@ -2018,10 +2033,10 @@ - + - + @@ -2041,6 +2056,9 @@ + + + @@ -2437,9 +2455,11 @@ + + diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 96c7f6dc9ee..8011766a172 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -2692,9 +2692,12 @@ function Test-FileWxs { if ($indexedAssetFiles -inotcontains $file) { + $name = Split-Path -Path $file -Leaf + if ($name -eq '.nupkg.metadata') { + break; + } $passed = $false $folder = Split-Path -Path $file - $name = Split-Path -Path $file -Leaf $heatNode = $heatNodesByFile[$file] $compGroupNode = Get-ComponentGroupNode -XmlDoc $newFilesAssetXml -XmlNsManager $xmlns $filesNode = Get-DirectoryNode -Node $heatNode -XmlDoc $newFilesAssetXml -XmlNsManager $xmlns From 7d842261db6937549fdca4ae1c581aaa56c64c38 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 15:04:02 +0000 Subject: [PATCH 022/103] [feature] From f7e51276e1149e861d0b9865057fb5e160c82cf9 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 30 Nov 2018 11:15:51 +0000 Subject: [PATCH 023/103] update ResGen project to .Net Core 3.9 since 2.0 is deprecated and is not working with using netcore3.0 --- src/ResGen/ResGen.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResGen/ResGen.csproj b/src/ResGen/ResGen.csproj index 2596f346664..2056aaedf75 100644 --- a/src/ResGen/ResGen.csproj +++ b/src/ResGen/ResGen.csproj @@ -2,7 +2,7 @@ Generates C# typed bindings for .resx files - netcoreapp2.0 + netcoreapp3.0 resgen Exe win7-x86;win7-x64;osx-x64;linux-x64 From b50c906fc138e837ef1bc36a9af6f003de409387 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 30 Nov 2018 11:35:25 +0000 Subject: [PATCH 024/103] [feature] upgrade typegen to .net core 3.0 as well and update comments --- .../commands/utility/AddType.cs | 6 +++--- src/TypeCatalogGen/TypeCatalogGen.csproj | 2 +- tools/packaging/project/package.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index 6e8486df885..df3a152a50b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -597,9 +597,9 @@ protected override void EndProcessing() #region LoadAssembly - // We now ship the NetCoreApp2.0 reference assemblies with PowerShell Core, so that Add-Type can work + // We now ship .Net Core's reference assemblies with PowerShell Core, so that Add-Type can work // in a predictable way and won't be broken when we move to newer version of .NET Core. - // The NetCoreApp2.0 reference assemblies are located at '$PSHOME\ref'. + // The reference assemblies are located at '$PSHOME\ref'. private static string s_netcoreAppRefFolder = PathType.Combine(PathType.GetDirectoryName(typeof(PSObject).Assembly.Location), "ref"); private static string s_frameworkFolder = PathType.GetDirectoryName(typeof(object).Assembly.Location); @@ -655,7 +655,7 @@ private void LoadAssemblies(IEnumerable assemblies) /// private static IEnumerable InitDefaultRefAssemblies() { - // netcoreapp2.0 currently comes with 137 reference assemblies (maybe more in future), so we use a capacity of '150'. + // netcoreapp3.0 currently comes with 145 reference assemblies (maybe more in future), so we use a capacity of '150'. var defaultRefAssemblies = new List(150); foreach (string file in Directory.EnumerateFiles(s_netcoreAppRefFolder, "*.dll", SearchOption.TopDirectoryOnly)) diff --git a/src/TypeCatalogGen/TypeCatalogGen.csproj b/src/TypeCatalogGen/TypeCatalogGen.csproj index d5aaa7462a9..cbb22d806cc 100644 --- a/src/TypeCatalogGen/TypeCatalogGen.csproj +++ b/src/TypeCatalogGen/TypeCatalogGen.csproj @@ -2,7 +2,7 @@ Generates CorePsTypeCatalog.cs given powershell.inc - netcoreapp2.0 + netcoreapp3.0 TypeCatalogGen Exe win7-x86;win7-x64;osx-x64;linux-x64 diff --git a/tools/packaging/project/package.csproj b/tools/packaging/project/package.csproj index e1f68b86c45..2c7c9c40944 100644 --- a/tools/packaging/project/package.csproj +++ b/tools/packaging/project/package.csproj @@ -11,6 +11,6 @@ runtime=$(RID);version=$(SemVer);PackageName=$(PackageName) $(StagingPath) True - netcoreapp2.0 + netcoreapp3.0 From 92465112b00f7198352d271464002503dbf4133e Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 30 Nov 2018 11:56:32 +0000 Subject: [PATCH 025/103] [feature] fix comment --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 229ddb08ce3..4c44fcc6e31 100644 --- a/build.psm1 +++ b/build.psm1 @@ -9,7 +9,7 @@ $script:TestModulePathSeparator = [System.IO.Path]::PathSeparator $script:TestModuleDirPath = Join-Path ([System.IO.Path]::GetTempPath()) 'PwshTestModules' $null = New-Item -Force -ItemType Directory -Path $script:TestModuleDirPath -$dotnetCLIChannel = 'preview' # TODO: Change this to 'release' once .Net Core 2.2 goes RTM +$dotnetCLIChannel = 'preview' # TODO: Change this to 'release' once .Net Core 3.0 goes RTM $dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version # Track if tags have been sync'ed From 498345746ccbee517c277076c004eafb993fa282 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 30 Nov 2018 12:20:26 +0000 Subject: [PATCH 026/103] [feature] use .net core 2.1 for web listener --- test/tools/WebListener/WebListener.csproj | 6 +++++- test/tools/WebListener/global.json | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/tools/WebListener/global.json diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 4fc854c36a0..1f882281c3f 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -3,11 +3,15 @@ + + netcoreapp2.1 + 2.1.5 A simple ASP.NET Core MVC app to provide an HTTP and HTTPS server for testing. - + diff --git a/test/tools/WebListener/global.json b/test/tools/WebListener/global.json new file mode 100644 index 00000000000..55e448dfe00 --- /dev/null +++ b/test/tools/WebListener/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.1.403" + } +} From e15e5fddf5cef77869adf055021e31e9911e1af5 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 15 Dec 2018 11:58:44 +0000 Subject: [PATCH 027/103] update WebListener.csproj to use new netcore3.0 NuGet packages --- appveyor.yml | 2 +- global.json | 2 +- test/tools/WebListener/WebListener.csproj | 6 +----- test/tools/WebListener/global.json | 5 ----- 4 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 test/tools/WebListener/global.json diff --git a/appveyor.yml b/appveyor.yml index 2a42ffb47f8..f1a5f8e4fb0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Purpose: ElevatedPesterTests_xUnit_Packaging -# cache version - netcoreapp3.0.100-preview-009806 +# cache version - netcoreapp3.0.100-preview-009812 cache: - '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml' diff --git a/global.json b/global.json index 95e00960423..f701075e385 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100-preview-009806" + "version": "3.0.100-preview-009812" } } diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 1f882281c3f..4254c744ca4 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -3,15 +3,11 @@ - - netcoreapp2.1 - 2.1.5 A simple ASP.NET Core MVC app to provide an HTTP and HTTPS server for testing. - + diff --git a/test/tools/WebListener/global.json b/test/tools/WebListener/global.json deleted file mode 100644 index 55e448dfe00..00000000000 --- a/test/tools/WebListener/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "2.1.403" - } -} From ee0be764f1e59646df44a416a13dbff31a7d5f52 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 9 Jan 2019 20:45:59 -0800 Subject: [PATCH 028/103] [feature] fix tests due to differences with .Net Core 3.0 --- test/powershell/Host/Startup.Tests.ps1 | 1 + .../TabCompletion/TabCompletion.Tests.ps1 | 2 +- .../Language/Parser/Parser.Tests.ps1 | 2 +- .../Test-Connection.Tests.ps1 | 11 +- .../SelfSignedCertificate.psd1 | 121 ++++ .../SelfSignedCertificate.psm1 | 685 ++++++++++++++++++ 6 files changed, 816 insertions(+), 6 deletions(-) create mode 100755 test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 create mode 100755 test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index 8570d6c8a67..af8936411bc 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -72,6 +72,7 @@ Describe "Validate start of console host" -Tag CI { 'System.Threading.Tasks.dll' 'System.Threading.Tasks.Parallel.dll' 'System.Threading.Thread.dll' + 'System.Threading.ThreadPool.dll' 'System.Threading.Timer.dll' 'System.Xml.ReaderWriter.dll' 'System.Xml.XDocument.dll' diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index a718331499d..7cff3404951 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -413,7 +413,7 @@ Describe "TabCompletion" -Tags CI { @{ inputStr = '$x= gps pwsh;$x.*pm'; expected = 'NPM'; setup = $null } @{ inputStr = 'function write-output {param($abcd) $abcd};Write-Output -a'; expected = '-abcd'; setup = $null } @{ inputStr = 'function write-output {param($abcd) $abcd};Microsoft.PowerShell.Utility\Write-Output -'; expected = '-InputObject'; setup = $null } - @{ inputStr = '[math]::Co'; expected = 'Cos('; setup = $null } + @{ inputStr = '[math]::Co'; expected = 'CopySign('; setup = $null } @{ inputStr = '[math]::PI.GetT'; expected = 'GetType('; setup = $null } @{ inputStr = '[math]'; expected = '::E'; setup = $null } @{ inputStr = '[math].'; expected = 'Assembly'; setup = $null } diff --git a/test/powershell/Language/Parser/Parser.Tests.ps1 b/test/powershell/Language/Parser/Parser.Tests.ps1 index 6387417648a..5501012e4ab 100644 --- a/test/powershell/Language/Parser/Parser.Tests.ps1 +++ b/test/powershell/Language/Parser/Parser.Tests.ps1 @@ -667,7 +667,7 @@ foo``u{2195}abc #Exponential @{ Script = "0e0"; ExpectedValue = "0"; ExpectedType = [double] } @{ Script = "0e1"; ExpectedValue = "0"; ExpectedType = [double] } - @{ Script = "-0e2"; ExpectedValue = "0"; ExpectedType = [double] } + @{ Script = "-0e2"; ExpectedValue = "-0"; ExpectedType = [double] } @{ Script = "3e0"; ExpectedValue = "3"; ExpectedType = [double] } @{ Script = "5e-2"; ExpectedValue = "0.05"; ExpectedType = [double] } @{ Script = "5e2"; ExpectedValue = "500"; ExpectedType = [double] } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 index 8eb68012492..6ec60554c60 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -76,12 +76,15 @@ Describe "Test-Connection" -tags "CI" { It "Ping fake host" { { $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } | Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand" - # Error code = 11001 - Host not found. + # Error code = Host not found. if (!$isWindows) { - $Error[0].Exception.InnerException.ErrorCode | Should -Be 6 - } else { - $Error[0].Exception.InnerException.ErrorCode | Should -Be 11001 + $errorCode = -131073 + } + else { + $errorCode = 11001 } + + $Error[0].Exception.InnerException.ErrorCode | Should -Be $errorCode } # In VSTS, address is 0.0.0.0 diff --git a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 new file mode 100755 index 00000000000..ca8b7ebf849 --- /dev/null +++ b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 @@ -0,0 +1,121 @@ +# Copyright (c) Robert Holt. +# Licensed under the MIT License. + +# Module manifest for module 'SelfSignedCertificate' +# +# Generated on: 9/18/2018 + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'SelfSignedCertificate.psm1' + +# Version number of this module. +ModuleVersion = '0.0.2' + +# Supported PSEditions +CompatiblePSEditions = 'Core' + +# ID used to uniquely identify this module +GUID = '634218b8-3334-4f10-ba89-2b79b0fd9fc4' + +# Author of this module +Author = 'Robert Holt' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '© Robert Holt' + +# Description of the functionality provided by this module +Description = 'Provides functionality for creating, processing and manipulating self-signed certificates in PowerShell' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '6.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = @('New-SelfSignedCertificate') + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/rjmholt/SelfSignedCertificate/blob/master/LICENSE.txt' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/rjmholt/SelfSignedCertificate' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} diff --git a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 new file mode 100755 index 00000000000..542d7190af8 --- /dev/null +++ b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 @@ -0,0 +1,685 @@ +# Copyright (c) Robert Holt. All rights reserved. +# Licensed under the MIT License. + +# The default length of a certificate in days +$script:DefaultCertDurationDays = 365 +# Default RSA key length +$script:DefaultRsaKeyLength = 2048 +# Default format for certificates +$script:DefaultCertificateFormat = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx +# Default name for the certificate file without extension +$script:DefaultCertificateFileName = 'certificate' +# Default key usage for certificates +$script:DefaultKeyUsage = [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::None +# Default certificate subject Common Name +$script:DefaultCommonName = 'localhost' + +$script:IsUnix = $IsLinux -or $IsMacOS + +# List of certificate key usages supported +enum EnhancedKeyUsage +{ + ServerAuthentication + ClientAuthentication +} + +# Lookup table for usage OIDs +$script:SupportedUsages = @{ + [EnhancedKeyUsage]::ServerAuthentication = [System.Security.Cryptography.Oid]::new("1.3.6.1.5.5.7.3.1", "Server Authentication") + [EnhancedKeyUsage]::ClientAuthentication = [System.Security.Cryptography.Oid]::new("1.3.6.1.5.5.7.3.2", "Client Authentication") +} + +# Class to represent a certificate distinguished name +# like "CN=com.contoso, C=US, S=Nebraska, L=Omaha, O=Contoso Ltd, OU=Sales, E=sales@contoso.com". +# See https://docs.microsoft.com/en-us/windows/desktop/seccrypto/distinguished-name-fields. +class CertificateDistinguishedName +{ + # Name of a person or an object host name + [ValidateNotNullOrEmpty()] + [string]$CommonName + + # 2-character ISO country code + [ValidateLength(2, 2)] + [string]$Country + + # The state or province where the owner is physically located + [string]$StateOrProvince + + # The city where the owner is located + [string]$Locality + + # The name of the registering organization + [string]$Organization + + # The division of the organization owning the certificate + [string]$OrganizationalUnit + + # The email address of the certificate owner + [Obsolete("The email field is deprecated by the PKIX standard")] + [mailaddress]$EmailAddress + + # Format the distinguished name like 'CN="com.contoso"; C="US"; S="Nebraska"' + [string] Format() + { + return $this.Format(';', <# UseQuotes #> $true) + } + + # Format the distinguished name with the given separator and quote usage setting + [string] Format([char]$Separator, [bool]$UseQuotes) + { + $sb = [System.Text.StringBuilder]::new() + + if ($UseQuotes) + { + $sb.Append("CN=`"$($this.CommonName)`"") + } + else + { + $sb.Append("CN=$($this.CommonName)") + } + + $fields = @{ + OU = $this.OrganizationalUnit + O = $this.Organization + L = $this.Locality + S = $this.StateOrProvince + C = $this.Country + E = $this.EmailAddress.Address + } + + foreach ($field in 'OU','O','L','S','C','E') + { + $val = $fields[$field] + + if (-not $val) + { + continue + } + + $sb.Append($Separator) + $sb.Append(" ") + + if ($UseQuotes) + { + $sb.Append("$field=`"$val`"") + } + else + { + $sb.Append("$field=$val") + } + } + + return $sb.ToString() + } + + # Format the distinguished name like 'CN=com.contoso, C=US, S=Nebraska' + [string] ToString() + { + return $this.Format(',', $false) + } + + # OpenSSL expects a strange distinguished name format + # like '/CN=com.contoso/C=US/S=Nebraska' + [string] FormatForOpenSsl() + { + $sb = [System.Text.StringBuilder]::new() + + $sb.Append("/CN=$($this.CommonName)") + + $fields = @{ + OU = $this.OrganizationalUnit + O = $this.Organization + L = $this.Locality + S = $this.StateOrProvince + C = $this.Country + E = $this.EmailAddress.Address + } + + foreach ($field in 'OU','O','L','S','C','E') + { + $val = $fields[$field] + + if (-not $val) + { + continue + } + + $sb.Append("/$field=$val") + } + + return $sb.ToString() + } + + # Create a new X500DistinguishedName object from this certificate + [X500DistinguishedName] AsX500DistinguishedName() + { + return [X500DistinguishedName]::new($this.Format()) + } +} + +# Represents the data in a self-signed certificate +class SelfSignedCertificate +{ + # The friendly name of the certificate + [string]$FriendlyName = [string]::Empty + + # The length of the private key to use in bits + [int]$KeyLength = $script:DefaultRsaKeyLength + + # The format of the certificate + [System.Security.Cryptography.X509Certificates.X509ContentType]$Format = $script:DefaultCertificateFormat + + # The start time of the certificate's valid period + [datetime]$NotBefore = [datetime]::Now + + # The end time of the certificate's valid period + [datetime]$NotAfter = [datetime]::Now.AddDays($script:DefaultCertDurationDays) + + # The certificate's subject and issuer name (since it's self-signed) + [CertificateDistinguishedName]$SubjectName + + # The key usages for the certificate -- what it will be used to do + [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]$KeyUsage = $script:DefaultKeyUsage + + # Extensions to be added to the certificate beyond those added automatically + [System.Security.Cryptography.X509Certificates.X509Extension[]]$AdditionalExtensions + + # The enhanced key usages for the certificate -- what specific scenarios it will be used for + [EnhancedKeyUsage[]]$EnhancedKeyUsage + + # Whether or not this certificate is for a certificate authority + [bool]$ForCertificateAuthority + + # Instantiate an X509Certificate2 object from this object + [System.Security.Cryptography.X509Certificates.X509Certificate2] AsX509Certificate2() + { + $extensions = [System.Collections.Generic.List[System.Security.Cryptography.X509Certificates.X509Extension]]::new() + + if ($this.AdditionalExtensions) + { + $extensions.AddRange($this.AdditionalExtensions) + } + + if ($this.KeyUsage) + { + # Create Key Usage + $keyUsages = [System.Security.Cryptography.X509Certificates.X509KeyUsageExtension]::new( + $this.KeyUsage, + <# critical #> $false) + $extensions.Add($keyUsages) + } + + # Create Enhanced Key Usage from configured usages + if ($this.EnhancedKeyUsage) + { + $ekuOidCollection = [System.Security.Cryptography.OidCollection]::new() + foreach ($usage in $this.EnhancedKeyUsage) + { + if ($script:SupportedUsages.Keys -contains $usage) + { + $ekuOidCollection.Add($script:SupportedUsages[$usage]) + } + } + $enhancedKeyUsages = [System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension]::new( + $ekuOidCollection, + <# critical #> $false) + $extensions.Add($enhancedKeyUsages) + } + + # Create Basic Constraints + $basicConstraints = [System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension]::new( + <# certificateAuthority #> $this.ForCertificateAuthority, + <# hasPathLengthConstraint #> $false, + <# pathLengthConstraint #> 0, + <# critical #> $false) + $extensions.Add($basicConstraints) + + # Create Private Key + $key = [System.Security.Cryptography.RSA]::Create($this.KeyLength) + + # Create the subject of the certificate + $subject = $this.SubjectName.AsX500DistinguishedName() + + # Create Certificate Request + $certRequest = [System.Security.Cryptography.X509Certificates.CertificateRequest]::new( + $subject, + $key, + [System.Security.Cryptography.HashAlgorithmName]::SHA256, + [System.Security.Cryptography.RSASignaturePadding]::Pkcs1) + + # Create the Subject Key Identifier extension + $subjectKeyIdentifier = [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension]::new( + $certRequest.PublicKey, + <# critical #> $false) + $extensions.Add($subjectKeyIdentifier) + + # Create Authority Key Identifier if the certificate is for a CA + if ($this.ForCertificateAuthority) + { + $authorityKeyIdentifier = New-AuthorityKeyIdentifier -SubjectKeyIdentifier $subjectKeyIdentifier + $extensions.Add($authorityKeyIdentifier) + } + + foreach ($extension in $extensions) + { + $certRequest.CertificateExtensions.Add($extension) + } + + $cert = $certRequest.CreateSelfSigned($this.NotBefore, $this.NotAfter) + + # FriendlyName is not supported on UNIX platforms + if (-not $script:IsUnix) + { + $cert.FriendlyName = $this.FriendlyName + } + + return $cert + } +} + +<# +.SYNOPSIS +Creates a self-signed certificate for testing use. + +.DESCRIPTION +Creates a self-signed certificate for testing usage in a +given format and using a given backend and outputs it to a given filepath. + +.PARAMETER OutFilePath +The filepath to output the generated certificate to. + +.PARAMETER CommonName +The common name of the certificate subject, e.g. "com.contoso" or "Jennifer McCallum". + +.PARAMETER Country +The country of the certificate subject as a two-character ISO code, e.g. "US" or "GB". + +.PARAMETER StateOrProvince +The state or province of the physical location of the certificate subject, e.g. "California" or "New South Wales". + +.PARAMETER Locality +The city or regional locality where the certificate subject is located, e.g. "Seattle". + +.PARAMETER Organization +The organization to which the certificate subject belongs, e.g. "Contoso Ltd". + +.PARAMETER OrganizationalUnit +The department or sub-organizational group the certificate subject belongs to, e.g. "Marketing". + +.PARAMETER EmailAddress +--DEPRECATED-- The email address of the certificate owner. + +.PARAMETER FriendlyName +A descriptive, human-readable name for the certificate. + +.PARAMETER CertificateFormat +The file format the certificate will take. + +.PARAMETER KeyLength +The length of the key in bits. + +.PARAMETER KeyUsage +What general usages the certificate will be used for. + +.PARAMETER EnhancedKeyUsage +The particular scenarios the certificate will be used for. + +.PARAMETER AdditionalExtension +Additional certificate extensions desired to add to the certificate. + +.PARAMETER ForCertificateAuthority +Specifies that the certificate is for a certification authority (CA). + +.PARAMETER Passphrase +The encryption passphrase or password for the certificate to protect its contents. + +.PARAMETER Force +Force overwriting if a certificate file already exists on the path to write to. + +.PARAMETER NotBefore +The time when the certificate becomes valid. + +.PARAMETER NotAfter +The time when the certificate ceases to be valid. + +.PARAMETER Duration +The length of the validity period of the certificate. +#> +function New-SelfSignedCertificate +{ + [CmdletBinding(DefaultParameterSetName = "NotAfter")] + param( + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $OutCertPath = $PWD, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [Alias("CN")] + [string] + $CommonName = $script:DefaultCommonName, + + [Parameter()] + [Alias("C")] + [string] + $Country, + + [Parameter()] + [Alias("S")] + [string] + $StateOrProvince, + + [Parameter()] + [Alias("L")] + [string] + $Locality, + + [Parameter()] + [Alias("O")] + [string] + $Organization, + + [Parameter()] + [Alias("OU")] + [string] + $OrganizationalUnit, + + [Parameter()] + [Alias("E")] + [Obsolete("The email name component is deprecated by the PKIX standard")] + [mailaddress] + $EmailAddress, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $FriendlyName, + + [Parameter()] + [System.Security.Cryptography.X509Certificates.X509ContentType] + $CertificateFormat = $script:DefaultCertificateFormat, + + [Parameter()] + [ValidateSet(2048, 3072, 4096)] + [int] + $KeyLength = $script:DefaultRsaKeyLength, + + [Parameter()] + [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags[]] + $KeyUsage = $script:DefaultKeyUsage, + + [Parameter()] + [EnhancedKeyUsage[]] + $EnhancedKeyUsage, + + [Parameter()] + [System.Security.Cryptography.X509Certificates.X509Extension[]] + $AdditionalExtension, + + [Parameter()] + [Alias("CA")] + [switch] + $ForCertificateAuthority, + + [Parameter()] + [Alias('Password')] + [securestring] + $Passphrase, + + [Parameter()] + [switch] + $Force, + + [Parameter()] + [Alias("StartDate")] + [datetime] + $NotBefore = [datetime]::Now, + + [Parameter(ParameterSetName="NotAfter")] + [datetime] + $NotAfter = [datetime]::Now.AddDays($script:DefaultCertDurationDays), + + [Parameter(ParameterSetName="Duration")] + [timespan] + $Duration = [timespan]::FromDays($script:DefaultCertDurationDays) + ) + + process + { + if ($PSCmdlet.ParameterSetName.Contains("Duration")) + { + $NotAfter = $NotBefore.Add($Duration) + } + + # Normalize the given paths (make them absolute, with relative interpreted as relative to PWD) + $OutCertPath = Get-AbsolutePathFromSupplied -Path $OutCertPath + + # Make sure the certificate's output path matches the given format + $ext = Get-CertificateFormatExtension $CertificateFormat + $OutCertPath = Get-ProperFilePath -Path $OutCertPath -DefaultFileName $script:DefaultCertificateFileName -RequiredExtension $ext + + # Ensure the directory where the certificate will go exists and that another certificate does not already exist + $destinationDir = [System.IO.Path]::GetDirectoryName($OutCertPath) + if (-not (Test-Path $destinationDir)) + { + throw [System.InvalidOperationException] "Destination directory '$destinationDir' for certificate does not exist or is not accessible" + } + elseif (Test-Path $OutCertPath) + { + if ($Force) + { + Remove-Item -Path $OutCertPath -Force + } + else + { + throw [System.IO.IOException] "File already exists at path $OutCertPath" + } + } + + # Roll the key usage flags into a single value (since they are flags) + $keyUsageFlags = [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::None + foreach ($keyUsageFlag in $KeyUsage) + { + $keyUsageFlags = $keyUsageFlags -bor $keyUsageFlag + } + + # Construct the subject name + $subjectName = [CertificateDistinguishedName] (Get-FalsyRemovedHashtable -Hashtable @{ + CommonName = $CommonName + Country = $Country + StateOrProvince = $StateOrProvince + Locality = $Locality + Organization = $Organization + OrganizationalUnit = $OrganizationalUnit + EmailAddress = $EmailAddress + }) + + # Construct the certificate object + $certificate = [SelfSignedCertificate] (Get-FalsyRemovedHashtable -Hashtable @{ + SubjectName = $subjectName + KeyLength = $KeyLength + KeyUsage = $keyUsageFlags + EnhancedKeyUsage = $EnhancedKeyUsage + NotBefore = $NotBefore + NotAfter = $NotAfter + FriendlyName = $FriendlyName + ForCertificateAuthority = $ForCertificateAuthority + AdditionalExtensions = $AdditionalExtension + }) + + # Turn the certificate object into an X509 certificate (2) object + [System.Security.Cryptography.X509Certificates.X509Certificate2]$x509Certificate2 = $certificate.AsX509Certificate2() + + # Write the certificate to the file system + if ($PSBoundParameters.ContainsKey('Passphrase')) + { + $bytes = $x509Certificate2.Export($CertificateFormat, $Passphrase) + try + { + [System.IO.File]::WriteAllBytes($OutCertPath, $bytes) + } + finally + { + [array]::Clear($bytes, 0, $bytes.Length) + } + } + else + { + $bytes = $x509Certificate2.Export($CertificateFormat) + [System.IO.File]::WriteAllBytes($OutCertPath, $bytes) + } + + Write-Host "Certificate written to $OutCertPath" + + # Return the certificate object for inspection + return $x509Certificate2 + } +} + +# Copy a hashtable with all the falsy entries removed +# @{ x = 'x'; y = '' } -> @{ x = 'x' } +function Get-FalsyRemovedHashtable +{ + param([hashtable]$Hashtable) + + $outTable = @{} + + foreach ($key in $Hashtable.Keys) + { + if ($Hashtable[$key]) + { + $outTable[$key] = $Hashtable[$key] + } + } + + return $outTable +} + +# Gets the appropriate extension for a given certificate format +function Get-CertificateFormatExtension +{ + param([System.Security.Cryptography.X509Certificates.X509ContentType]$CertificateFormat) + + switch ($CertificateFormat) + { + Cert + { + return 'cer' + } + + Pfx + { + return 'pfx' + } + + default + { + throw [System.NotSupportedException] "No extension known for format '$CertificateFormat'" + } + } +} + +# Normalizes paths so that relative paths are interpreted +# relative to PWD and returned as absolute +function Get-AbsolutePathFromSupplied +{ + param( + [string]$Path + ) + + if ([System.IO.Path]::IsPathRooted($Path)) + { + return $Path + } + + return [System.IO.Path]::GetFullPath((Join-Path $PWD $Path)) +} + +# Take a user-supplied path and fix it up to point to a file path that makes sense +function Get-ProperFilePath +{ + param( + [string]$Path, + [string]$DefaultFileName, + [string]$RequiredExtension + ) + + # If we're given a directory, point the path to a default filename in that directory + if ($Path.EndsWith([System.IO.Path]::DirectorySeparatorChar) -or (Test-Path -Path $Path -PathType Container)) + { + return Join-Path $Path "$DefaultFileName.$RequiredExtension" + } + + # We're pointing to a file, so just correct the extension if necessary + if ([System.IO.Path]::GetExtension($Path) -ne $RequiredExtension) + { + return [System.IO.Path]::ChangeExtension($Path, $RequiredExtension) + } + + return $Path +} + +# Produce a new authority key identifier from the authority's subject key identifier +function New-AuthorityKeyIdentifier +{ + param( + [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension] + $SubjectKeyIdentifier, + + [switch] + $Critical + ) + + # The canonical OID of an Authority Key Identifier + $akiOid = "2.5.29.35" + + # AKI is not supported directly by .NET, we have to make our own + # The ASN.1 rule we follow is: + # AuthorityKeyId ::= SEQUENCE { keyIdentifier [0] IMPLICIT_OCTET_STRING } + # Because nothing documents what that means in DER encoding: + # - SEQUENCE: 0x30 tag, then length in bytes up to 0x79 + # - keyIdentifier: + # - [0]: a context-specific tag (bit 8 = 1, bit 7 = 0) of value 0 (bits 6-1 = 0) + # - IMPLICIT_OCTECT_STRING: no 0x04 octet string tag, first byte is length in bytes up to 0x79, then the string content + # Example: + # | SEQUENCE | [0] | IMPLICIT_OCTET_STRING | 0x01 0x02 0x03 0x04 + # | 0x30 0x06 | 0x80 | 0x04 | 0x01 0x02 0x03 0x04 + # sequence ^ length ^ octet string length + # + # For more information see: + # - Microsoft's resources on this: https://docs.microsoft.com/en-us/windows/desktop/seccertenroll/about-certificate-request-encoding + # - This helpful page: http://luca.ntop.org/Teaching/Appunti/asn1.html + + # Compose the key here + # We could extract from the SKI's raw data, but the string is a safer bet + $ski = $SubjectKeyIdentifier.SubjectKeyIdentifier + $key = [System.Collections.Generic.List[byte]]::new() + for ($i = 0; $i -lt $SubjectKeyIdentifier.SubjectKeyIdentifier.Length; $i += 2) + { + $x = $ski[$i] + $ski[$i+1] + $b = [System.Convert]::ToByte($x, 16) + [void]$key.Add($b) + } + + # Ensure our assumptions about not having to encode too much are correct + if ($key.Count + 2 -gt 0x79) + { + throw [System.InvalidOperationException] "Subject key identifier length is to high to encode: $($key.Count)" + } + + [byte]$octetLength = $key.Count + [byte]$sequenceLength = $octetLength+2 + + [byte]$sequenceTag = 0x30 + [byte]$keyIdentifierTag = 0x80 + + # Assemble the raw data + [byte[]]$akiRawData = @($sequenceTag, $sequenceLength, $keyIdentifierTag, $octetLength) + $key + + # Construct the Authority Key Identifier extension + return [System.Security.Cryptography.X509Certificates.X509Extension]::new( + $akiOid, + $akiRawData, + $Critical) +} \ No newline at end of file From 79269e3ff8b35bdc5bbc45d047adc44f0cf5e933 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 9 Jan 2019 21:42:44 -0800 Subject: [PATCH 029/103] [feature] update to 3.0.100-preview-009817 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index f701075e385..bb77cddf616 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100-preview-009812" + "version": "3.0.100-preview-009817" } } From e9ef32ee8e9ec3311a1facd4d30ed4677eabeeb4 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 9 Jan 2019 23:09:22 -0800 Subject: [PATCH 030/103] [feature] update to latest rcedit, some test fixes --- build.psm1 | 4 ++-- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- test/powershell/Host/Startup.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Management/Set-Location.Tests.ps1 | 3 ++- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 2 +- .../engine/ParameterBinding/ParameterBinding.Tests.ps1 | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build.psm1 b/build.psm1 index cfafca09145..399095f75c5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1415,7 +1415,7 @@ function Start-PSxUnit { } } - dotnet build --configuration $Options.configuration + dotnet build --configuration $Options.configuration if (Test-Path $ParallelTestResultsFile) { Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue @@ -1690,7 +1690,7 @@ function Start-PSBootstrap { if (-not (Test-Path "~/.rcedit/rcedit-x64.exe")) { Write-Log "Install RCEdit for modifying exe resources" - $rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.0.0/rcedit-x64.exe" + $rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe" New-Item -Path "~/.rcedit" -Type Directory -Force > $null ## need to specify TLS version 1.2 since GitHub API requires it diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 3b41812dec9..03d5d5588bd 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -599,7 +599,7 @@ foo $out = pwsh -workingdirectory ~ -c '(Get-Location).Path' $out | Should -HaveCount 2 $out[0] | Should -BeExactly (Get-Item ~).FullName - $out[1] | Should -BeExactly "$testdrive" + $out[1] | Should -BeExactly ([System.IO.FileInfo]::new($testdrive).FullName) } finally { if ($currentProfile) { diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index af8936411bc..16648a585d8 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -72,7 +72,6 @@ Describe "Validate start of console host" -Tag CI { 'System.Threading.Tasks.dll' 'System.Threading.Tasks.Parallel.dll' 'System.Threading.Thread.dll' - 'System.Threading.ThreadPool.dll' 'System.Threading.Timer.dll' 'System.Xml.ReaderWriter.dll' 'System.Xml.XDocument.dll' @@ -93,6 +92,7 @@ Describe "Validate start of console host" -Tag CI { 'System.IO.MemoryMappedFiles.dll' 'System.Net.Sockets.dll' 'System.Reflection.Metadata.dll' + 'System.Threading.ThreadPool.dll' ) } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 index 5824419f3b1..6bc48927e7b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 @@ -172,7 +172,8 @@ Describe "Set-Location" -Tags "CI" { param($path) Set-Location $TestDrive - $literalPath = Join-Path $TestDrive $path + # use FileInfo to get the long name if $TestDrive is using 8.3 path + $literalPath = [System.IO.FileInfo]::new((Join-Path $TestDrive $path)).FullName New-Item -ItemType Directory -Path $literalPath Set-Location -LiteralPath $path (Get-Location).Path | Should -BeExactly $literalPath diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index be5aaca1b1e..677d7db6bf8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { BeforeAll { $scriptFileName = "GetTryCatchCallStack.ps1" - $scriptFilePath = Join-Path $TestDrive -ChildPath $scriptFileName + $scriptFilePath = [System.IO.FileInfo]::new((Join-Path $TestDrive -ChildPath $scriptFileName)).FullName } It "Verifies that the script block of a catch clause does not show up on the call stack" { $fileStream = @" diff --git a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 index a3a51831e41..f0ed4d1c09c 100644 --- a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 @@ -272,7 +272,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { ) "[$Root]" '@ - $tempDir = Join-Path -Path $TestDrive -ChildPath "DefaultValueTest" + $tempDir = [System.IO.FileInfo]::new((Join-Path -Path $TestDrive -ChildPath "DefaultValueTest")).FullName $test1File = Join-Path -Path $tempDir -ChildPath "test1.ps1" $test2File = Join-Path -Path $tempDir -ChildPath "test2.ps1" From a07f965f92d33543d51634ae5d64cb1a57544821 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 15 Jan 2019 19:03:44 -0800 Subject: [PATCH 031/103] [feature] remove dependency on rcedit as .Net Core 3.0 SDK supports embedding manifest from csproj --- PowerShell.Common.props | 3 +++ build.psm1 | 41 ----------------------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index e5c461e57c3..538e666abca 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -62,6 +62,9 @@ Tracking Issue https://github.com/dotnet/sdk/issues/1557 --> $(PSCoreBuildVersion) + ..\..\assets\pwsh.manifest + ..\..\assets\Powershell_av_colors.ico + ..\..\assets\Powershell_black.ico diff --git a/build.psm1 b/build.psm1 index 399095f75c5..873133bef5b 100644 --- a/build.psm1 +++ b/build.psm1 @@ -425,15 +425,6 @@ Fix steps: } if ($Environment.IsWindows) { - ## need RCEdit to modify the binaries embedded resources - $rcedit = "~/.rcedit/rcedit-x64.exe" - if (-not (Test-Path -Type Leaf $rcedit)) { - $rcedit = Get-Command "rcedit-x64.exe" -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 | ForEach-Object Name - } - if (-not $rcedit) { - throw "RCEdit is required to modify pwsh.exe resources, please run 'Start-PSBootStrap' to install" - } - $ReleaseVersion = "" if ($ReleaseTagToUse) { $ReleaseVersion = $ReleaseTagToUse @@ -448,25 +439,6 @@ Fix steps: $fileVersion = $ReleaseVersion.Split("-")[0] } - # in VSCode, the build output folder doesn't include the name of the exe so we have to add it for rcedit - $pwshPath = $Options.Output - if (!$pwshPath.EndsWith("pwsh.exe")) { - $pwshPath = Join-Path $Options.Output "pwsh.exe" - } - - if (Test-IsPreview $ReleaseVersion) { - $iconPath = "$PSScriptRoot\assets\Powershell_av_colors.ico" - } else { - $iconPath = "$PSScriptRoot\assets\Powershell_black.ico" - } - - # fxdependent package does not have an executable to set iconPath etc. - if ($Options.Runtime -ne 'fxdependent') { - Start-NativeExecution { & $rcedit $pwshPath --set-icon $iconPath ` - --set-file-version $fileVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell Core 6" ` - --set-version-string "LegalCopyright" "(C) Microsoft Corporation. All Rights Reserved." ` - --application-manifest "$PSScriptRoot\assets\pwsh.manifest" } | Write-Verbose - } } # download modules from powershell gallery. @@ -1685,19 +1657,6 @@ function Start-PSBootstrap { $psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1") & $psInstallFile -AddToPath } - - ## need RCEdit to modify the binaries embedded resources - if (-not (Test-Path "~/.rcedit/rcedit-x64.exe")) - { - Write-Log "Install RCEdit for modifying exe resources" - $rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe" - New-Item -Path "~/.rcedit" -Type Directory -Force > $null - - ## need to specify TLS version 1.2 since GitHub API requires it - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 - - Invoke-WebRequest -OutFile "~/.rcedit/rcedit-x64.exe" -Uri $rceditUrl - } } } finally { Pop-Location From 6fec9c95f153ea825b86cb867ef25bac223278b2 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 15 Jan 2019 19:22:46 -0800 Subject: [PATCH 032/103] [feature] fix merge conflict --- appveyor.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index f1a5f8e4fb0..00000000000 --- a/appveyor.yml +++ /dev/null @@ -1,34 +0,0 @@ -# version is set in tools\appveyor.psm1 - Invoke-AppVeyorInstall -environment: - POWERSHELL_TELEMETRY_OPTOUT: 1 - # Avoid expensive initialization of dotnet cli, see: http://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - Purpose: UnelevatedPesterTests - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - Purpose: ElevatedPesterTests_xUnit_Packaging - -# cache version - netcoreapp3.0.100-preview-009812 -cache: - - '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml' - -nuget: - project_feed: true - -install: - - ps: Import-Module .\tools\Appveyor.psm1 - - ps: Invoke-AppveyorInstall - -build_script: - - ps: Invoke-AppveyorBuild - -test_script: - - ps: Invoke-AppveyorTest -Purpose $env:Purpose - -after_test: - - ps: Invoke-AppVeyorAfterTest - -# Packaging -on_finish: - - ps: if ($env:Purpose -eq 'ElevatedPesterTests_xUnit_Packaging'){ Invoke-AppveyorFinish } From 8f088a3c7c922cb3b239cbe0ae8f168fa18a3b9c Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 16 Jan 2019 19:41:30 -0800 Subject: [PATCH 033/103] [feature] update NormalizePath() to also return long paths --- .../namespaces/FileSystemProvider.cs | 13 +++++++++++-- .../namespaces/NavigationProviderBase.cs | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index aa1454128c4..25459172a4a 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -88,16 +88,25 @@ public FileSystemProvider() }; /// - /// Converts all / in the path to \ + /// Converts all / in the path to \ and on Windows shortpaths to longpaths /// /// /// The path to normalize. /// /// - /// The path with all / normalized to \ + /// The path with all / normalized to \ and on Windows a longpath /// private static string NormalizePath(string path) { + if (string.IsNullOrEmpty(path)) + { + return path; + } + + // Use FileInfo to convert short paths to long paths on Windows +#if !UNIX + path = (new FileInfo(path)).FullName; +#endif return path.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); } diff --git a/src/System.Management.Automation/namespaces/NavigationProviderBase.cs b/src/System.Management.Automation/namespaces/NavigationProviderBase.cs index ef44eaeff20..5458e54b1ea 100644 --- a/src/System.Management.Automation/namespaces/NavigationProviderBase.cs +++ b/src/System.Management.Automation/namespaces/NavigationProviderBase.cs @@ -335,7 +335,7 @@ protected string MakePath(string parent, string child, bool childIsLeaf) // If the parent is empty but the child is not, return the // child - result = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); + result = NormalizePath(child); } else if (!string.IsNullOrEmpty(parent) && string.IsNullOrEmpty(child)) @@ -369,8 +369,8 @@ protected string MakePath(string parent, string child, bool childIsLeaf) // Normalize the path so that only the default path separator is used as a // separator even if the user types the alternate slash. - parent = parent.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); - child = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); + parent = NormalizePath(parent); + child = NormalizePath(child); } // Joins the paths From f79e91457d01ef6af25b066644e877b0d3fe2079 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 17 Jan 2019 19:41:33 -0800 Subject: [PATCH 034/103] [feature] address Jeremy's feedback remove reserved device names that now work with 3.0 update check of file properties to match values from csproj --- .../namespaces/FileSystemProvider.cs | 2 +- test/powershell/Host/ConsoleHost.Tests.ps1 | 11 +++- .../FileSystem.Tests.ps1 | 65 ++++++++----------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 25459172a4a..b362b677f0c 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -105,7 +105,7 @@ private static string NormalizePath(string path) // Use FileInfo to convert short paths to long paths on Windows #if !UNIX - path = (new FileInfo(path)).FullName; + path = Path.GetFullPath(path); #endif return path.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); } diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 03d5d5588bd..20e7846eb2c 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -716,9 +716,14 @@ Describe "Console host api tests" -Tag CI { Describe "Pwsh exe resources tests" -Tag CI { It "Resource strings are embedded in the executable" -Skip:(!$IsWindows) { $pwsh = Get-Item -Path "$PSHOME\pwsh.exe" - $pwsh.VersionInfo.FileVersion | Should -BeExactly $PSVersionTable.PSVersion.ToString().Split("-")[0] - $pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId - $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell Core 6" + $pwsh.VersionInfo.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0] + $productVersion = $pwsh.VersionInfo.ProductVersion.Replace("-dirty","").Replace(" Commits: ","-").Replace(" SHA: ","-g") + if ($PSVersionTable.GitCommitId.Contains("-g")) { + $productVersion | Should -BeExactly $PSVersionTable.GitCommitId + } else { + $PSVersionTable.GitCommitId | Should -Match $productVersion + } + $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell Core" } It "Manifest contains compatibility section" -Skip:(!$IsWindows) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index f974e370eb8..7bb3f327646 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -22,9 +22,10 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { $newTestFile = "NewTestFile.txt" $testContent = "Some Content" $testContent2 = "More Content" - $reservedNames = "CON", "PRN", "AUX", "CLOCK$", "NUL", - "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", - "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" + $reservedNamesTests = @( + # other formally reserved names work with .Net Core 3.0 + @{ deviceName = "CLOCK$" } + ) } BeforeEach { @@ -154,51 +155,39 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { $contentAfter.Count | Should -Be 0 } - It "Copy-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) { - foreach ($deviceName in $reservedNames) - { - { Copy-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand" - } + It "Copy-Item on Windows rejects Windows reserved device name: " -Skip:(-not $IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + { Copy-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand" } - It "Move-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) { - foreach ($deviceName in $reservedNames) - { - { Move-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "MoveError,Microsoft.PowerShell.Commands.MoveItemCommand" - } + It "Move-Item on Windows rejects Windows reserved device name: " -Skip:(-not $IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + { Move-Item -Path $testFile -Destination $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "MoveError,Microsoft.PowerShell.Commands.MoveItemCommand" } - It "Rename-Item on Windows rejects Windows reserved device names" -Skip:(-not $IsWindows) { - foreach ($deviceName in $reservedNames) - { - { Rename-Item -Path $testFile -NewName $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "RenameError,Microsoft.PowerShell.Commands.RenameItemCommand" - } + It "Rename-Item on Windows rejects Windows reserved device name: " -Skip:(-not $IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + { Rename-Item -Path $testFile -NewName $deviceName -ErrorAction Stop } | Should -Throw -ErrorId "RenameError,Microsoft.PowerShell.Commands.RenameItemCommand" } - It "Copy-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) { - foreach ($deviceName in $reservedNames) - { - Copy-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue - Test-Path $deviceName | Should -BeTrue - } + It "Copy-Item on Unix succeeds with Windows reserved device name: " -Skip:($IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + Copy-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue + Test-Path $deviceName | Should -BeTrue } - It "Move-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) { - foreach ($deviceName in $reservedNames) - { - Move-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue - Test-Path $deviceName | Should -BeTrue - New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue - } + It "Move-Item on Unix succeeds with Windows reserved device name: " -Skip:($IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + Move-Item -Path $testFile -Destination $deviceName -Force -ErrorAction SilentlyContinue + Test-Path $deviceName | Should -BeTrue + New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue } - It "Rename-Item on Unix succeeds with Windows reserved device names" -Skip:($IsWindows) { - foreach ($deviceName in $reservedNames) - { - Rename-Item -Path $testFile -NewName $deviceName -Force -ErrorAction SilentlyContinue - Test-Path $deviceName | Should -BeTrue - New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue - } + It "Rename-Item on Unix succeeds with Windows reserved device name: " -Skip:($IsWindows) -TestCases $reservedNamesTests { + param($deviceName) + Rename-Item -Path $testFile -NewName $deviceName -Force -ErrorAction SilentlyContinue + Test-Path $deviceName | Should -BeTrue + New-Item -Path $testFile -ItemType File -Force -ErrorAction SilentlyContinue } It "Set-Location on Unix succeeds with folder with colon: " -Skip:($IsWindows) -TestCases @( From 0d3b15ec1b9893927311608e540607b21190105e Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 18 Jan 2019 13:59:35 -0800 Subject: [PATCH 035/103] [feature] fix psversion test and test-connection test --- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- .../Test-Connection.Tests.ps1 | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 20e7846eb2c..2cb04d2bfb1 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -721,7 +721,7 @@ Describe "Pwsh exe resources tests" -Tag CI { if ($PSVersionTable.GitCommitId.Contains("-g")) { $productVersion | Should -BeExactly $PSVersionTable.GitCommitId } else { - $PSVersionTable.GitCommitId | Should -Match $productVersion + $productVersion | Should -Match $PSVersionTable.GitCommitId } $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell Core" } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 index 6ec60554c60..a4a2c14433f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -76,15 +76,12 @@ Describe "Test-Connection" -tags "CI" { It "Ping fake host" { { $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } | Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand" - # Error code = Host not found. + # Error code = 11001 - Host not found. if (!$isWindows) { - $errorCode = -131073 - } - else { - $errorCode = 11001 + $Error[0].Exception.InnerException.ErrorCode | Should -Be -131073 + } else { + $Error[0].Exception.InnerException.ErrorCode | Should -Be 11001 } - - $Error[0].Exception.InnerException.ErrorCode | Should -Be $errorCode } # In VSTS, address is 0.0.0.0 @@ -116,8 +113,9 @@ Describe "Test-Connection" -tags "CI" { $result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut","Success" } else { $result1.Replies[0].Options.DontFragment | Should -BeFalse - # We expect 'TtlExpired' but if a router don't reply we get `TimeOut` - $result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut" + # We expect 'TtlExpired' but if a router don't reply we get `TimedOut` + # AzPipelines returns $null + $result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut",$null } } From 88c3e08ea74bfaca00fe2329f49c8c623187d229 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 18 Jan 2019 22:09:38 -0800 Subject: [PATCH 036/103] [feature] fix get-process test --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index db1d117a4c7..1be72d65da2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -16,10 +16,10 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { It "Should support -FileVersionInfo" { $pwshVersion = Get-Process -Id $pid -FileVersionInfo if ($IsWindows) { - $PSVersionTable.PSVersion | Should -MatchExactly $pwshVersion.FileVersion + $PSVersionTable.PSVersion.ToString().Split("-")[0] | Should -MatchExactly $pwshVersion.FileVersion $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } - $pwshVersion.ProductVersion.Replace("-dirty","") | Should -BeExactly $gitCommitId + $pwshVersion.ProductVersion.Replace("-dirty","").Replace(" Commits:","-'").Replace(" SHA:","-g") | Should -BeExactly $gitCommitId } else { $pwshVersion.FileVersion | Should -BeNullOrEmpty } From 17333bb38d290a74766b045af2ba8444a065cc4a Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 18 Jan 2019 22:23:39 -0800 Subject: [PATCH 037/103] [feature] update IsReservedDeviceName() method due to .Net Core 3.0 changes --- src/System.Management.Automation/engine/Utils.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index dc553f79c9c..d1228b561d2 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -936,16 +936,12 @@ internal static bool IsAdministrator() internal static bool IsReservedDeviceName(string destinationPath) { #if !UNIX - string[] reservedDeviceNames = { "CON", "PRN", "AUX", "CLOCK$", "NUL", - "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", - "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; + string[] reservedDeviceNames = { "CLOCK$" }; string compareName = Path.GetFileName(destinationPath); string noExtensionCompareName = Path.GetFileNameWithoutExtension(destinationPath); - // See if it's the correct length. If it's shorter than CON, AUX, etc, it can't be a device name. - // Likewise, if it's longer than 'CLOCK$', it can't be a device name. - if (((compareName.Length < 3) || (compareName.Length > 6)) && - ((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 6))) + // If it's longer than 'CLOCK$', it can't be a device name. + if (compareName.Length > 6 && noExtensionCompareName.Length > 6) { return false; } From 77fc8d988a46ff6099f3ca60c830960f50b06582 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 20 Jan 2019 00:20:28 +0000 Subject: [PATCH 038/103] Enable WinForms and WPF --- assets/files.wxs | 60 +++++++++++++++++++ .../powershell-win-core.csproj | 4 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/assets/files.wxs b/assets/files.wxs index c424a7a2736..e4205ee60a5 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -2198,6 +2198,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2904,6 +2949,21 @@ + + + + + + + + + + + + + + + diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 93f3a9446f0..9517d569598 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -1,10 +1,12 @@ - + PowerShell Core on Windows top-level project pwsh Exe true + true + true win7-x86;win7-x64 Microsoft.PowerShell From b9447f145e46bd3a29cb784e4b08db18554fa24d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 22 Jan 2019 21:22:30 +0000 Subject: [PATCH 039/103] Move exclusion of '*.nupkg.metadata' to build.psm1 as agreed by @SteveL-MSFT in PR discussion --- build.psm1 | 2 +- tools/packaging/packaging.psm1 | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index 0d96ca3e6fa..ef1ec75b9c9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2271,7 +2271,7 @@ function Copy-PSGalleryModules Remove-Item -Force -ErrorAction Ignore -Recurse "$Destination/$name" New-Item -Path $dest -ItemType Directory -Force -ErrorAction Stop > $null - $dontCopy = '*.nupkg', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll' + $dontCopy = '*.nupkg', '*.nupkg.metadata', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll' Copy-Item -Exclude $dontCopy -Recurse $src/* $dest } } diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 07da8eb5f9a..8db0db96444 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -2747,10 +2747,6 @@ function Test-FileWxs { if ($indexedAssetFiles -inotcontains $file) { - $name = Split-Path -Path $file -Leaf - if ($name -eq '.nupkg.metadata') { - break; - } $passed = $false $folder = Split-Path -Path $file $heatNode = $heatNodesByFile[$file] From ed344734c2aa88bbfe735f2a251d6b042eebb934 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 23 Jan 2019 12:26:23 -0800 Subject: [PATCH 040/103] [feature] fix application manifest --- PowerShell.Common.props | 1 - assets/pwsh.manifest | 10 +++++----- src/powershell-win-core/powershell-win-core.csproj | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 538e666abca..7c988f113f2 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -62,7 +62,6 @@ Tracking Issue https://github.com/dotnet/sdk/issues/1557 --> $(PSCoreBuildVersion) - ..\..\assets\pwsh.manifest ..\..\assets\Powershell_av_colors.ico ..\..\assets\Powershell_black.ico diff --git a/assets/pwsh.manifest b/assets/pwsh.manifest index 3584aba51b5..d47133e8457 100644 --- a/assets/pwsh.manifest +++ b/assets/pwsh.manifest @@ -7,13 +7,13 @@ + /> - - - + + + @@ -21,6 +21,6 @@ - + diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 9517d569598..cb35819223b 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -9,6 +9,7 @@ true win7-x86;win7-x64 Microsoft.PowerShell + ..\..\assets\pwsh.manifest From 145f274f940444e73b9e4c25048ad8171f15f538 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 23 Jan 2019 12:28:35 -0800 Subject: [PATCH 041/103] [feature] remove selfsignedcert module from repo --- .../SelfSignedCertificate.psd1 | 121 ---- .../SelfSignedCertificate.psm1 | 685 ------------------ 2 files changed, 806 deletions(-) delete mode 100755 test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 delete mode 100755 test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 diff --git a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 deleted file mode 100755 index ca8b7ebf849..00000000000 --- a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psd1 +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (c) Robert Holt. -# Licensed under the MIT License. - -# Module manifest for module 'SelfSignedCertificate' -# -# Generated on: 9/18/2018 - -@{ - -# Script module or binary module file associated with this manifest. -RootModule = 'SelfSignedCertificate.psm1' - -# Version number of this module. -ModuleVersion = '0.0.2' - -# Supported PSEditions -CompatiblePSEditions = 'Core' - -# ID used to uniquely identify this module -GUID = '634218b8-3334-4f10-ba89-2b79b0fd9fc4' - -# Author of this module -Author = 'Robert Holt' - -# Company or vendor of this module -CompanyName = 'Microsoft Corporation' - -# Copyright statement for this module -Copyright = '© Robert Holt' - -# Description of the functionality provided by this module -Description = 'Provides functionality for creating, processing and manipulating self-signed certificates in PowerShell' - -# Minimum version of the PowerShell engine required by this module -PowerShellVersion = '6.1' - -# Name of the PowerShell host required by this module -# PowerShellHostName = '' - -# Minimum version of the PowerShell host required by this module -# PowerShellHostVersion = '' - -# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# DotNetFrameworkVersion = '' - -# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# CLRVersion = '' - -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' - -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() - -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() - -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() - -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() - -# Format files (.ps1xml) to be loaded when importing this module -# FormatsToProcess = @() - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() - -# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = @('New-SelfSignedCertificate') - -# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -CmdletsToExport = @() - -# Variables to export from this module -VariablesToExport = '*' - -# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. -AliasesToExport = @() - -# DSC resources to export from this module -# DscResourcesToExport = @() - -# List of all modules packaged with this module -# ModuleList = @() - -# List of all files packaged with this module -# FileList = @() - -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - LicenseUri = 'https://github.com/rjmholt/SelfSignedCertificate/blob/master/LICENSE.txt' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/rjmholt/SelfSignedCertificate' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - # ReleaseNotes = '' - - } # End of PSData hashtable - -} # End of PrivateData hashtable - -# HelpInfo URI of this module -# HelpInfoURI = '' - -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' - -} diff --git a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 b/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 deleted file mode 100755 index 542d7190af8..00000000000 --- a/test/tools/Modules/SelfSignedCertificate/SelfSignedCertificate.psm1 +++ /dev/null @@ -1,685 +0,0 @@ -# Copyright (c) Robert Holt. All rights reserved. -# Licensed under the MIT License. - -# The default length of a certificate in days -$script:DefaultCertDurationDays = 365 -# Default RSA key length -$script:DefaultRsaKeyLength = 2048 -# Default format for certificates -$script:DefaultCertificateFormat = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx -# Default name for the certificate file without extension -$script:DefaultCertificateFileName = 'certificate' -# Default key usage for certificates -$script:DefaultKeyUsage = [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::None -# Default certificate subject Common Name -$script:DefaultCommonName = 'localhost' - -$script:IsUnix = $IsLinux -or $IsMacOS - -# List of certificate key usages supported -enum EnhancedKeyUsage -{ - ServerAuthentication - ClientAuthentication -} - -# Lookup table for usage OIDs -$script:SupportedUsages = @{ - [EnhancedKeyUsage]::ServerAuthentication = [System.Security.Cryptography.Oid]::new("1.3.6.1.5.5.7.3.1", "Server Authentication") - [EnhancedKeyUsage]::ClientAuthentication = [System.Security.Cryptography.Oid]::new("1.3.6.1.5.5.7.3.2", "Client Authentication") -} - -# Class to represent a certificate distinguished name -# like "CN=com.contoso, C=US, S=Nebraska, L=Omaha, O=Contoso Ltd, OU=Sales, E=sales@contoso.com". -# See https://docs.microsoft.com/en-us/windows/desktop/seccrypto/distinguished-name-fields. -class CertificateDistinguishedName -{ - # Name of a person or an object host name - [ValidateNotNullOrEmpty()] - [string]$CommonName - - # 2-character ISO country code - [ValidateLength(2, 2)] - [string]$Country - - # The state or province where the owner is physically located - [string]$StateOrProvince - - # The city where the owner is located - [string]$Locality - - # The name of the registering organization - [string]$Organization - - # The division of the organization owning the certificate - [string]$OrganizationalUnit - - # The email address of the certificate owner - [Obsolete("The email field is deprecated by the PKIX standard")] - [mailaddress]$EmailAddress - - # Format the distinguished name like 'CN="com.contoso"; C="US"; S="Nebraska"' - [string] Format() - { - return $this.Format(';', <# UseQuotes #> $true) - } - - # Format the distinguished name with the given separator and quote usage setting - [string] Format([char]$Separator, [bool]$UseQuotes) - { - $sb = [System.Text.StringBuilder]::new() - - if ($UseQuotes) - { - $sb.Append("CN=`"$($this.CommonName)`"") - } - else - { - $sb.Append("CN=$($this.CommonName)") - } - - $fields = @{ - OU = $this.OrganizationalUnit - O = $this.Organization - L = $this.Locality - S = $this.StateOrProvince - C = $this.Country - E = $this.EmailAddress.Address - } - - foreach ($field in 'OU','O','L','S','C','E') - { - $val = $fields[$field] - - if (-not $val) - { - continue - } - - $sb.Append($Separator) - $sb.Append(" ") - - if ($UseQuotes) - { - $sb.Append("$field=`"$val`"") - } - else - { - $sb.Append("$field=$val") - } - } - - return $sb.ToString() - } - - # Format the distinguished name like 'CN=com.contoso, C=US, S=Nebraska' - [string] ToString() - { - return $this.Format(',', $false) - } - - # OpenSSL expects a strange distinguished name format - # like '/CN=com.contoso/C=US/S=Nebraska' - [string] FormatForOpenSsl() - { - $sb = [System.Text.StringBuilder]::new() - - $sb.Append("/CN=$($this.CommonName)") - - $fields = @{ - OU = $this.OrganizationalUnit - O = $this.Organization - L = $this.Locality - S = $this.StateOrProvince - C = $this.Country - E = $this.EmailAddress.Address - } - - foreach ($field in 'OU','O','L','S','C','E') - { - $val = $fields[$field] - - if (-not $val) - { - continue - } - - $sb.Append("/$field=$val") - } - - return $sb.ToString() - } - - # Create a new X500DistinguishedName object from this certificate - [X500DistinguishedName] AsX500DistinguishedName() - { - return [X500DistinguishedName]::new($this.Format()) - } -} - -# Represents the data in a self-signed certificate -class SelfSignedCertificate -{ - # The friendly name of the certificate - [string]$FriendlyName = [string]::Empty - - # The length of the private key to use in bits - [int]$KeyLength = $script:DefaultRsaKeyLength - - # The format of the certificate - [System.Security.Cryptography.X509Certificates.X509ContentType]$Format = $script:DefaultCertificateFormat - - # The start time of the certificate's valid period - [datetime]$NotBefore = [datetime]::Now - - # The end time of the certificate's valid period - [datetime]$NotAfter = [datetime]::Now.AddDays($script:DefaultCertDurationDays) - - # The certificate's subject and issuer name (since it's self-signed) - [CertificateDistinguishedName]$SubjectName - - # The key usages for the certificate -- what it will be used to do - [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]$KeyUsage = $script:DefaultKeyUsage - - # Extensions to be added to the certificate beyond those added automatically - [System.Security.Cryptography.X509Certificates.X509Extension[]]$AdditionalExtensions - - # The enhanced key usages for the certificate -- what specific scenarios it will be used for - [EnhancedKeyUsage[]]$EnhancedKeyUsage - - # Whether or not this certificate is for a certificate authority - [bool]$ForCertificateAuthority - - # Instantiate an X509Certificate2 object from this object - [System.Security.Cryptography.X509Certificates.X509Certificate2] AsX509Certificate2() - { - $extensions = [System.Collections.Generic.List[System.Security.Cryptography.X509Certificates.X509Extension]]::new() - - if ($this.AdditionalExtensions) - { - $extensions.AddRange($this.AdditionalExtensions) - } - - if ($this.KeyUsage) - { - # Create Key Usage - $keyUsages = [System.Security.Cryptography.X509Certificates.X509KeyUsageExtension]::new( - $this.KeyUsage, - <# critical #> $false) - $extensions.Add($keyUsages) - } - - # Create Enhanced Key Usage from configured usages - if ($this.EnhancedKeyUsage) - { - $ekuOidCollection = [System.Security.Cryptography.OidCollection]::new() - foreach ($usage in $this.EnhancedKeyUsage) - { - if ($script:SupportedUsages.Keys -contains $usage) - { - $ekuOidCollection.Add($script:SupportedUsages[$usage]) - } - } - $enhancedKeyUsages = [System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension]::new( - $ekuOidCollection, - <# critical #> $false) - $extensions.Add($enhancedKeyUsages) - } - - # Create Basic Constraints - $basicConstraints = [System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension]::new( - <# certificateAuthority #> $this.ForCertificateAuthority, - <# hasPathLengthConstraint #> $false, - <# pathLengthConstraint #> 0, - <# critical #> $false) - $extensions.Add($basicConstraints) - - # Create Private Key - $key = [System.Security.Cryptography.RSA]::Create($this.KeyLength) - - # Create the subject of the certificate - $subject = $this.SubjectName.AsX500DistinguishedName() - - # Create Certificate Request - $certRequest = [System.Security.Cryptography.X509Certificates.CertificateRequest]::new( - $subject, - $key, - [System.Security.Cryptography.HashAlgorithmName]::SHA256, - [System.Security.Cryptography.RSASignaturePadding]::Pkcs1) - - # Create the Subject Key Identifier extension - $subjectKeyIdentifier = [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension]::new( - $certRequest.PublicKey, - <# critical #> $false) - $extensions.Add($subjectKeyIdentifier) - - # Create Authority Key Identifier if the certificate is for a CA - if ($this.ForCertificateAuthority) - { - $authorityKeyIdentifier = New-AuthorityKeyIdentifier -SubjectKeyIdentifier $subjectKeyIdentifier - $extensions.Add($authorityKeyIdentifier) - } - - foreach ($extension in $extensions) - { - $certRequest.CertificateExtensions.Add($extension) - } - - $cert = $certRequest.CreateSelfSigned($this.NotBefore, $this.NotAfter) - - # FriendlyName is not supported on UNIX platforms - if (-not $script:IsUnix) - { - $cert.FriendlyName = $this.FriendlyName - } - - return $cert - } -} - -<# -.SYNOPSIS -Creates a self-signed certificate for testing use. - -.DESCRIPTION -Creates a self-signed certificate for testing usage in a -given format and using a given backend and outputs it to a given filepath. - -.PARAMETER OutFilePath -The filepath to output the generated certificate to. - -.PARAMETER CommonName -The common name of the certificate subject, e.g. "com.contoso" or "Jennifer McCallum". - -.PARAMETER Country -The country of the certificate subject as a two-character ISO code, e.g. "US" or "GB". - -.PARAMETER StateOrProvince -The state or province of the physical location of the certificate subject, e.g. "California" or "New South Wales". - -.PARAMETER Locality -The city or regional locality where the certificate subject is located, e.g. "Seattle". - -.PARAMETER Organization -The organization to which the certificate subject belongs, e.g. "Contoso Ltd". - -.PARAMETER OrganizationalUnit -The department or sub-organizational group the certificate subject belongs to, e.g. "Marketing". - -.PARAMETER EmailAddress ---DEPRECATED-- The email address of the certificate owner. - -.PARAMETER FriendlyName -A descriptive, human-readable name for the certificate. - -.PARAMETER CertificateFormat -The file format the certificate will take. - -.PARAMETER KeyLength -The length of the key in bits. - -.PARAMETER KeyUsage -What general usages the certificate will be used for. - -.PARAMETER EnhancedKeyUsage -The particular scenarios the certificate will be used for. - -.PARAMETER AdditionalExtension -Additional certificate extensions desired to add to the certificate. - -.PARAMETER ForCertificateAuthority -Specifies that the certificate is for a certification authority (CA). - -.PARAMETER Passphrase -The encryption passphrase or password for the certificate to protect its contents. - -.PARAMETER Force -Force overwriting if a certificate file already exists on the path to write to. - -.PARAMETER NotBefore -The time when the certificate becomes valid. - -.PARAMETER NotAfter -The time when the certificate ceases to be valid. - -.PARAMETER Duration -The length of the validity period of the certificate. -#> -function New-SelfSignedCertificate -{ - [CmdletBinding(DefaultParameterSetName = "NotAfter")] - param( - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $OutCertPath = $PWD, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [Alias("CN")] - [string] - $CommonName = $script:DefaultCommonName, - - [Parameter()] - [Alias("C")] - [string] - $Country, - - [Parameter()] - [Alias("S")] - [string] - $StateOrProvince, - - [Parameter()] - [Alias("L")] - [string] - $Locality, - - [Parameter()] - [Alias("O")] - [string] - $Organization, - - [Parameter()] - [Alias("OU")] - [string] - $OrganizationalUnit, - - [Parameter()] - [Alias("E")] - [Obsolete("The email name component is deprecated by the PKIX standard")] - [mailaddress] - $EmailAddress, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $FriendlyName, - - [Parameter()] - [System.Security.Cryptography.X509Certificates.X509ContentType] - $CertificateFormat = $script:DefaultCertificateFormat, - - [Parameter()] - [ValidateSet(2048, 3072, 4096)] - [int] - $KeyLength = $script:DefaultRsaKeyLength, - - [Parameter()] - [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags[]] - $KeyUsage = $script:DefaultKeyUsage, - - [Parameter()] - [EnhancedKeyUsage[]] - $EnhancedKeyUsage, - - [Parameter()] - [System.Security.Cryptography.X509Certificates.X509Extension[]] - $AdditionalExtension, - - [Parameter()] - [Alias("CA")] - [switch] - $ForCertificateAuthority, - - [Parameter()] - [Alias('Password')] - [securestring] - $Passphrase, - - [Parameter()] - [switch] - $Force, - - [Parameter()] - [Alias("StartDate")] - [datetime] - $NotBefore = [datetime]::Now, - - [Parameter(ParameterSetName="NotAfter")] - [datetime] - $NotAfter = [datetime]::Now.AddDays($script:DefaultCertDurationDays), - - [Parameter(ParameterSetName="Duration")] - [timespan] - $Duration = [timespan]::FromDays($script:DefaultCertDurationDays) - ) - - process - { - if ($PSCmdlet.ParameterSetName.Contains("Duration")) - { - $NotAfter = $NotBefore.Add($Duration) - } - - # Normalize the given paths (make them absolute, with relative interpreted as relative to PWD) - $OutCertPath = Get-AbsolutePathFromSupplied -Path $OutCertPath - - # Make sure the certificate's output path matches the given format - $ext = Get-CertificateFormatExtension $CertificateFormat - $OutCertPath = Get-ProperFilePath -Path $OutCertPath -DefaultFileName $script:DefaultCertificateFileName -RequiredExtension $ext - - # Ensure the directory where the certificate will go exists and that another certificate does not already exist - $destinationDir = [System.IO.Path]::GetDirectoryName($OutCertPath) - if (-not (Test-Path $destinationDir)) - { - throw [System.InvalidOperationException] "Destination directory '$destinationDir' for certificate does not exist or is not accessible" - } - elseif (Test-Path $OutCertPath) - { - if ($Force) - { - Remove-Item -Path $OutCertPath -Force - } - else - { - throw [System.IO.IOException] "File already exists at path $OutCertPath" - } - } - - # Roll the key usage flags into a single value (since they are flags) - $keyUsageFlags = [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::None - foreach ($keyUsageFlag in $KeyUsage) - { - $keyUsageFlags = $keyUsageFlags -bor $keyUsageFlag - } - - # Construct the subject name - $subjectName = [CertificateDistinguishedName] (Get-FalsyRemovedHashtable -Hashtable @{ - CommonName = $CommonName - Country = $Country - StateOrProvince = $StateOrProvince - Locality = $Locality - Organization = $Organization - OrganizationalUnit = $OrganizationalUnit - EmailAddress = $EmailAddress - }) - - # Construct the certificate object - $certificate = [SelfSignedCertificate] (Get-FalsyRemovedHashtable -Hashtable @{ - SubjectName = $subjectName - KeyLength = $KeyLength - KeyUsage = $keyUsageFlags - EnhancedKeyUsage = $EnhancedKeyUsage - NotBefore = $NotBefore - NotAfter = $NotAfter - FriendlyName = $FriendlyName - ForCertificateAuthority = $ForCertificateAuthority - AdditionalExtensions = $AdditionalExtension - }) - - # Turn the certificate object into an X509 certificate (2) object - [System.Security.Cryptography.X509Certificates.X509Certificate2]$x509Certificate2 = $certificate.AsX509Certificate2() - - # Write the certificate to the file system - if ($PSBoundParameters.ContainsKey('Passphrase')) - { - $bytes = $x509Certificate2.Export($CertificateFormat, $Passphrase) - try - { - [System.IO.File]::WriteAllBytes($OutCertPath, $bytes) - } - finally - { - [array]::Clear($bytes, 0, $bytes.Length) - } - } - else - { - $bytes = $x509Certificate2.Export($CertificateFormat) - [System.IO.File]::WriteAllBytes($OutCertPath, $bytes) - } - - Write-Host "Certificate written to $OutCertPath" - - # Return the certificate object for inspection - return $x509Certificate2 - } -} - -# Copy a hashtable with all the falsy entries removed -# @{ x = 'x'; y = '' } -> @{ x = 'x' } -function Get-FalsyRemovedHashtable -{ - param([hashtable]$Hashtable) - - $outTable = @{} - - foreach ($key in $Hashtable.Keys) - { - if ($Hashtable[$key]) - { - $outTable[$key] = $Hashtable[$key] - } - } - - return $outTable -} - -# Gets the appropriate extension for a given certificate format -function Get-CertificateFormatExtension -{ - param([System.Security.Cryptography.X509Certificates.X509ContentType]$CertificateFormat) - - switch ($CertificateFormat) - { - Cert - { - return 'cer' - } - - Pfx - { - return 'pfx' - } - - default - { - throw [System.NotSupportedException] "No extension known for format '$CertificateFormat'" - } - } -} - -# Normalizes paths so that relative paths are interpreted -# relative to PWD and returned as absolute -function Get-AbsolutePathFromSupplied -{ - param( - [string]$Path - ) - - if ([System.IO.Path]::IsPathRooted($Path)) - { - return $Path - } - - return [System.IO.Path]::GetFullPath((Join-Path $PWD $Path)) -} - -# Take a user-supplied path and fix it up to point to a file path that makes sense -function Get-ProperFilePath -{ - param( - [string]$Path, - [string]$DefaultFileName, - [string]$RequiredExtension - ) - - # If we're given a directory, point the path to a default filename in that directory - if ($Path.EndsWith([System.IO.Path]::DirectorySeparatorChar) -or (Test-Path -Path $Path -PathType Container)) - { - return Join-Path $Path "$DefaultFileName.$RequiredExtension" - } - - # We're pointing to a file, so just correct the extension if necessary - if ([System.IO.Path]::GetExtension($Path) -ne $RequiredExtension) - { - return [System.IO.Path]::ChangeExtension($Path, $RequiredExtension) - } - - return $Path -} - -# Produce a new authority key identifier from the authority's subject key identifier -function New-AuthorityKeyIdentifier -{ - param( - [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension] - $SubjectKeyIdentifier, - - [switch] - $Critical - ) - - # The canonical OID of an Authority Key Identifier - $akiOid = "2.5.29.35" - - # AKI is not supported directly by .NET, we have to make our own - # The ASN.1 rule we follow is: - # AuthorityKeyId ::= SEQUENCE { keyIdentifier [0] IMPLICIT_OCTET_STRING } - # Because nothing documents what that means in DER encoding: - # - SEQUENCE: 0x30 tag, then length in bytes up to 0x79 - # - keyIdentifier: - # - [0]: a context-specific tag (bit 8 = 1, bit 7 = 0) of value 0 (bits 6-1 = 0) - # - IMPLICIT_OCTECT_STRING: no 0x04 octet string tag, first byte is length in bytes up to 0x79, then the string content - # Example: - # | SEQUENCE | [0] | IMPLICIT_OCTET_STRING | 0x01 0x02 0x03 0x04 - # | 0x30 0x06 | 0x80 | 0x04 | 0x01 0x02 0x03 0x04 - # sequence ^ length ^ octet string length - # - # For more information see: - # - Microsoft's resources on this: https://docs.microsoft.com/en-us/windows/desktop/seccertenroll/about-certificate-request-encoding - # - This helpful page: http://luca.ntop.org/Teaching/Appunti/asn1.html - - # Compose the key here - # We could extract from the SKI's raw data, but the string is a safer bet - $ski = $SubjectKeyIdentifier.SubjectKeyIdentifier - $key = [System.Collections.Generic.List[byte]]::new() - for ($i = 0; $i -lt $SubjectKeyIdentifier.SubjectKeyIdentifier.Length; $i += 2) - { - $x = $ski[$i] + $ski[$i+1] - $b = [System.Convert]::ToByte($x, 16) - [void]$key.Add($b) - } - - # Ensure our assumptions about not having to encode too much are correct - if ($key.Count + 2 -gt 0x79) - { - throw [System.InvalidOperationException] "Subject key identifier length is to high to encode: $($key.Count)" - } - - [byte]$octetLength = $key.Count - [byte]$sequenceLength = $octetLength+2 - - [byte]$sequenceTag = 0x30 - [byte]$keyIdentifierTag = 0x80 - - # Assemble the raw data - [byte[]]$akiRawData = @($sequenceTag, $sequenceLength, $keyIdentifierTag, $octetLength) + $key - - # Construct the Authority Key Identifier extension - return [System.Security.Cryptography.X509Certificates.X509Extension]::new( - $akiOid, - $akiRawData, - $Critical) -} \ No newline at end of file From 9b18dd6a88534ceefa382e75d8f14b4a9323266d Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 23 Jan 2019 13:18:28 -0800 Subject: [PATCH 042/103] [feature] remove system.windows.forms from blacklist --- .../CoreCLR/CorePsAssemblyLoadContext.cs | 4 +--- .../engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs index e7cdc3debdc..83934ed343d 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs @@ -109,9 +109,7 @@ private PowerShellAssemblyLoadContext(string basePaths) // - Value: strong name of the TPA that contains the type represented by Key. private readonly Dictionary _coreClrTypeCatalog; private readonly Lazy> _availableDotNetAssemblyNames; - private readonly HashSet _blackListedAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase){ - "System.Windows.Forms" - }; + private readonly HashSet _blackListedAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase){}; #if !UNIX private string _winDir; diff --git a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 index edf54b703dc..cd0765ceddf 100644 --- a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 @@ -6,6 +6,8 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" { $defaultErrorId = 'FileLoadException' $testcases = @( # verify winforms is blocked + # winforms assembly is supported for .Net Core 3.0, if a new assembly needs to be blocked + # enable this test and add to list below @{ Name = 'system.windows.forms' ErrorId = $defaultErrorId @@ -19,7 +21,7 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" { # All existing cases should fail on all platforms either because it doesn't exist or # because the assembly is blacklisted - It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: " -TestCases $testcases { + It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: " -Skip -TestCases $testcases { param( [Parameter(Mandatory)] [string] From 80f0baabc96260470fe3b474c01f3754df8edb99 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 23 Jan 2019 13:57:08 -0800 Subject: [PATCH 043/103] [feature] fix Get-Process test due to fileversion change --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index 1be72d65da2..29e05beb182 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -16,7 +16,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { It "Should support -FileVersionInfo" { $pwshVersion = Get-Process -Id $pid -FileVersionInfo if ($IsWindows) { - $PSVersionTable.PSVersion.ToString().Split("-")[0] | Should -MatchExactly $pwshVersion.FileVersion + $PSVersionTable.PSVersion.ToString().Split("-")[0] | Should -Match $pwshVersion.FileVersion $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } $pwshVersion.ProductVersion.Replace("-dirty","").Replace(" Commits:","-'").Replace(" SHA:","-g") | Should -BeExactly $gitCommitId From 5b2a5e133034ff8c6de79d89b4fca974c3ec0c3b Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 23 Jan 2019 17:09:08 -0800 Subject: [PATCH 044/103] [feature] revert change to resolve paths to long paths --- .../namespaces/FileSystemProvider.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 5057c75cc3b..d1f975e20a4 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -88,25 +88,16 @@ public FileSystemProvider() }; /// - /// Converts all / in the path to \ and on Windows shortpaths to longpaths + /// Converts all / in the path to \ /// /// /// The path to normalize. /// /// - /// The path with all / normalized to \ and on Windows a longpath + /// The path with all / normalized to \ /// private static string NormalizePath(string path) { - if (string.IsNullOrEmpty(path)) - { - return path; - } - - // Use FileInfo to convert short paths to long paths on Windows -#if !UNIX - path = Path.GetFullPath(path); -#endif return path.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator); } From 9e956d4e1aac0e1b1f8f5942e4054c459540558a Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 25 Jan 2019 15:00:55 -0800 Subject: [PATCH 045/103] [feature] fix symlink test where `target` member is an array and we need to use ToString() to compare with original path --- .../FileSystem.Tests.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 7bb3f327646..84c62e78387 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -451,7 +451,8 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" $real = Get-Item -Path $realFile $link = Get-Item -Path $symLinkToFile $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target | Should -Be $real.FullName + $link.Target.Count | Should -Be 1 + $link.Target[0] | Should -BeExactly $real.ToString() Get-Content -Path $symLinkToFile | Should -Be $fileContent } It "New-Item can create a symbolic link to nothing" { @@ -459,7 +460,8 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" Test-Path $symLinkToNothing | Should -BeTrue $link = Get-Item -Path $symLinkToNothing $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target | Should -Be $nonFile + $link.Target.Count | Should -Be 1 + $link.Target[0] | Should -Be $nonFile.ToString() } It "New-Item emits an error when path to symbolic link already exists." { { New-Item -ItemType SymbolicLink -Path $realDir -Value $symLinkToDir -ErrorAction Stop } | Should -Throw -ErrorId "SymLinkExists,Microsoft.PowerShell.Commands.NewItemCommand" @@ -470,7 +472,8 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" $real = Get-Item -Path $realDir $link = Get-Item -Path $symLinkToDir $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target | Should -Be $real.FullName + $link.Target.Count | Should -Be 1 + $link.Target[0] | Should -BeExactly $real.ToString() } It "New-Item can create a directory symbolic link to a directory" -Skip:(-Not $IsWindows) { New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir @@ -479,7 +482,8 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" $link = Get-Item -Path $symLinkToDir $link | Should -BeOfType System.IO.DirectoryInfo $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target | Should -BeExactly $real.FullName + $link.Target.Count | Should -Be 1 + $link.Target[0] | Should -BeExactly $real.ToString() } It "New-Item can create a directory junction to a directory" -Skip:(-Not $IsWindows) { New-Item -ItemType Junction -Path $junctionToDir -Value $realDir From 908a7836465ead87f91b8a86f6094c80db078030 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Sat, 26 Jan 2019 10:17:05 -0800 Subject: [PATCH 046/103] [feature] fix conversion test so longfilename is used --- test/powershell/Language/Parser/Conversions.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/powershell/Language/Parser/Conversions.Tests.ps1 b/test/powershell/Language/Parser/Conversions.Tests.ps1 index ced48d9cf3a..07a4f8af0ea 100644 --- a/test/powershell/Language/Parser/Conversions.Tests.ps1 +++ b/test/powershell/Language/Parser/Conversions.Tests.ps1 @@ -126,7 +126,8 @@ namespace TestTypeResolution { [TestTypeResolution.TestTypeFoo].Assembly.Location "@ $location = & $powershell -noprofile -command $command - $location | Should -Be $cmdletDllPath + # need to resolve short filename to long filename using FileInfo + $location | Should -Be ([System.IO.FileInfo]::new($cmdletDllPath)).FullName } } From bb369d5d4c68e7cd5bf82d74e38ebc08a1b9da26 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Sat, 26 Jan 2019 10:49:54 -0800 Subject: [PATCH 047/103] [feature] change longfile resolution to more optimal api --- test/powershell/Language/Parser/Conversions.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Language/Parser/Conversions.Tests.ps1 b/test/powershell/Language/Parser/Conversions.Tests.ps1 index 07a4f8af0ea..cf635f90f5c 100644 --- a/test/powershell/Language/Parser/Conversions.Tests.ps1 +++ b/test/powershell/Language/Parser/Conversions.Tests.ps1 @@ -127,7 +127,7 @@ namespace TestTypeResolution { "@ $location = & $powershell -noprofile -command $command # need to resolve short filename to long filename using FileInfo - $location | Should -Be ([System.IO.FileInfo]::new($cmdletDllPath)).FullName + $location | Should -Be ([System.IO.Path]::GetFullPath($cmdletDllPath)) } } From 05fe7541a71e7b0ef5901bb0e4826da679550c6c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 26 Jan 2019 19:17:27 +0000 Subject: [PATCH 048/103] [feature] Empty commit after pulling in upstream changes from master to resolve trivial merge conflict. From 8eda518d6c57180cd9f8629fd64d6632b2e18b50 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sun, 27 Jan 2019 22:29:12 +0000 Subject: [PATCH 049/103] [feature] Fix first half of 'Get-Process for admin.Should support -FileVersionInfo' Pester test - Use expected value at LHS, which also fixes test due to the way matching works - Add extra tests for other properties This will still not make the test pass since the issue with the git commit id still persists --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index 29e05beb182..5d6a01f7e53 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -16,7 +16,10 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { It "Should support -FileVersionInfo" { $pwshVersion = Get-Process -Id $pid -FileVersionInfo if ($IsWindows) { - $PSVersionTable.PSVersion.ToString().Split("-")[0] | Should -Match $pwshVersion.FileVersion + $pwshVersion.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0] + $pwshVersion.FileMajorPart | Should -BeExactly $PSVersionTable.PSVersion.Major + $pwshVersion.FileMinorPart | Should -BeExactly $PSVersionTable.PSVersion.Minor + $pwshVersion.FileBuildPart | Should -BeExactly $PSVersionTable.PSVersion.Patch $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } $pwshVersion.ProductVersion.Replace("-dirty","").Replace(" Commits:","-'").Replace(" SHA:","-g") | Should -BeExactly $gitCommitId From 49fe439258953ccc5766bbbedaff220309197265 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 28 Jan 2019 19:56:10 -0800 Subject: [PATCH 050/103] [feature] fix get-process test for fileversion check --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index 5d6a01f7e53..2d78707a2c8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -22,7 +22,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { $pwshVersion.FileBuildPart | Should -BeExactly $PSVersionTable.PSVersion.Patch $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } - $pwshVersion.ProductVersion.Replace("-dirty","").Replace(" Commits:","-'").Replace(" SHA:","-g") | Should -BeExactly $gitCommitId + $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g") | Should -BeExactly $gitCommitId } else { $pwshVersion.FileVersion | Should -BeNullOrEmpty } From c4b837153716a0a05ad1f319ec42d50dbcf80e3f Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 28 Jan 2019 21:22:26 -0800 Subject: [PATCH 051/103] [feature] change get-process -fileversioninfo validation due to difference in CI --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index 2d78707a2c8..604de1c68af 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -22,7 +22,8 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { $pwshVersion.FileBuildPart | Should -BeExactly $PSVersionTable.PSVersion.Patch $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } - $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g") | Should -BeExactly $gitCommitId + $productVersion = $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g") + $gitCommitId | Should -Match $productVersion } else { $pwshVersion.FileVersion | Should -BeNullOrEmpty } From b981137eba01a6d4e7e9230dee8481fc8a3ca5b6 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 28 Jan 2019 21:46:54 -0800 Subject: [PATCH 052/103] [feature] reverse check of productversion to gitcommitid --- .../Microsoft.PowerShell.Management/Get-Process.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 index 604de1c68af..ed35c6437cc 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1 @@ -23,7 +23,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') { $gitCommitId = $PSVersionTable.GitCommitId if ($gitCommitId.StartsWith("v")) { $gitCommitId = $gitCommitId.Substring(1) } $productVersion = $pwshVersion.ProductVersion.Replace(" Commits: ","-").Replace(" SHA: ","-g") - $gitCommitId | Should -Match $productVersion + $productVersion | Should -Match $gitCommitId } else { $pwshVersion.FileVersion | Should -BeNullOrEmpty } From d18a23a53a2c0fb9d45a55c2cca11da9da9f8b21 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 28 Jan 2019 22:50:46 -0800 Subject: [PATCH 053/103] [feature] disable overflow test as it takes too long; use optimal method to get longfile path --- test/powershell/Host/ConsoleHost.Tests.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 2cb04d2bfb1..c0bbc98ac64 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -479,7 +479,8 @@ foo } Context "Exception handling" { - It "Should handle a CallDepthOverflow" { + # This test takes too long on big machines, perhaps needs a test hook + It "Should handle a CallDepthOverflow" -Pending { # Infinite recursion function recurse { @@ -599,7 +600,7 @@ foo $out = pwsh -workingdirectory ~ -c '(Get-Location).Path' $out | Should -HaveCount 2 $out[0] | Should -BeExactly (Get-Item ~).FullName - $out[1] | Should -BeExactly ([System.IO.FileInfo]::new($testdrive).FullName) + $out[1] | Should -BeExactly ([System.IO.Path]::GetFullPath($testdrive)) } finally { if ($currentProfile) { From 584c132d4fff3d07eaa23f5a89e13651e6807322 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 29 Jan 2019 06:53:22 +0000 Subject: [PATCH 054/103] [feature] Empty commit to retrigger CI From 621e710b510681bf4197c80663939023aea81107 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 29 Jan 2019 10:02:32 -0800 Subject: [PATCH 055/103] [feature] update files.wxs --- assets/files.wxs | 108 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 98 insertions(+), 10 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index c3dee0f465f..b60335885fc 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -2003,9 +2003,6 @@ - - - @@ -2217,11 +2214,80 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -2865,7 +2931,6 @@ - @@ -2936,8 +3001,31 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + From 8f62ed860dde44d666e1adfd73a09208c3ca2a70 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 29 Jan 2019 12:51:17 -0800 Subject: [PATCH 056/103] [feature] move to .Net Core 3.0 preview 2 --- PowerShell.Common.props | 4 ++-- build.psm1 | 12 +++++++----- global.json | 2 +- test/Test.Common.props | 2 +- test/tools/WebListener/WebListener.csproj | 1 - 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 7c988f113f2..e9cdbc9dc5b 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -96,8 +96,8 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-preview-27122-01 - Latest + 3.0.0-preview-27324-05 + 8.0 true true diff --git a/build.psm1 b/build.psm1 index 62272d1228f..dfe4df453e7 100644 --- a/build.psm1 +++ b/build.psm1 @@ -388,13 +388,15 @@ Fix steps: try { Push-Location "$PSScriptRoot/src/TypeCatalogGen" $refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') } - $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" + if ($null -ne $refAssemblies) { + $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" - if (Test-Path $refDestFolder -PathType Container) { - Remove-Item $refDestFolder -Force -Recurse -ErrorAction Stop + if (Test-Path $refDestFolder -PathType Container) { + Remove-Item $refDestFolder -Force -Recurse -ErrorAction Stop + } + New-Item -Path $refDestFolder -ItemType Directory -Force -ErrorAction Stop > $null + Copy-Item -Path $refAssemblies -Destination $refDestFolder -Force -ErrorAction Stop } - New-Item -Path $refDestFolder -ItemType Directory -Force -ErrorAction Stop > $null - Copy-Item -Path $refAssemblies -Destination $refDestFolder -Force -ErrorAction Stop } finally { Pop-Location } diff --git a/global.json b/global.json index bb77cddf616..e66ff4ebef5 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100-preview-009817" + "version": "3.0.100-preview-010184" } } diff --git a/test/Test.Common.props b/test/Test.Common.props index 159cec11eba..52e5fe61240 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-preview-27122-01 + 3.0.0-preview-27324-05 Latest true diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 913dc7c0ea8..8e856b3a0f8 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,7 +7,6 @@ - From 8013cc6c3cc22b94f82acefb36ef9c5374826c1d Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 29 Jan 2019 14:02:28 -0800 Subject: [PATCH 057/103] [feature] fix case where typegen has an empty string in the file --- build.psm1 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build.psm1 b/build.psm1 index dfe4df453e7..e98e1ea39bc 100644 --- a/build.psm1 +++ b/build.psm1 @@ -384,19 +384,17 @@ Fix steps: Pop-Location } - # publish netcoreapp3.0 reference assemblies + # publish reference assemblies try { Push-Location "$PSScriptRoot/src/TypeCatalogGen" - $refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') } - if ($null -ne $refAssemblies) { - $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" + $refAssemblies = Get-Content -Path $incFileName | ForEach-Object { $_.TrimEnd(';') } | Where-Object { $_ -ne "" } + $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" - if (Test-Path $refDestFolder -PathType Container) { - Remove-Item $refDestFolder -Force -Recurse -ErrorAction Stop - } - New-Item -Path $refDestFolder -ItemType Directory -Force -ErrorAction Stop > $null - Copy-Item -Path $refAssemblies -Destination $refDestFolder -Force -ErrorAction Stop + if (Test-Path $refDestFolder -PathType Container) { + Remove-Item $refDestFolder -Force -Recurse -ErrorAction Stop } + New-Item -Path $refDestFolder -ItemType Directory -Force -ErrorAction Stop > $null + Copy-Item -Path $refAssemblies -Destination $refDestFolder -Force -ErrorAction Stop } finally { Pop-Location } From ecb7e485d25fd4c03574922a8c330a4a3904d7e0 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 18 Apr 2019 18:48:55 -0700 Subject: [PATCH 058/103] move to preview4 --- PowerShell.Common.props | 1 - global.json | 2 +- test/Test.Common.props | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 130e608fc28..a76d0db90b0 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -96,7 +96,6 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-preview-27324-05 8.0 true diff --git a/global.json b/global.json index e66ff4ebef5..ba439e3c473 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100-preview-010184" + "version": "3.0.100-preview4-011223" } } diff --git a/test/Test.Common.props b/test/Test.Common.props index de015807c0a..305de3c9884 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,14 +5,13 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - 3.0.0-preview-27324-05 Latest true true true - + $(DefineConstants);UNIX From bb26c80281c361ce2a2a71493d63f5a2d609b7a8 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 10:52:05 -0700 Subject: [PATCH 059/103] add version 7.0.0 --- .../engine/PSVersionInfo.cs | 19 +++++++++++++++---- test/hosting/hosting.tests.csproj | 2 +- tools/metadata.json | 6 +++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 2910509b868..1f1b2cf4359 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -59,7 +59,8 @@ public class PSVersionInfo private static Version s_psV4Version = new Version(4, 0); private static Version s_psV5Version = new Version(5, 0); private static Version s_psV51Version = new Version(5, 1, NTVerpVars.PRODUCTBUILD, NTVerpVars.PRODUCTBUILD_QFE); - private static SemanticVersion s_psV6Version; + private static SemanticVersion s_psV6Version = new SemanticVersion(6, 0, 0, null, null); + private static SemanticVersion s_psV7Version; /// /// A constant to track current PowerShell Edition. @@ -98,12 +99,12 @@ static PSVersionInfo() rawGitCommitId = mainVersion; } - s_psV6Version = new SemanticVersion(mainVersion); + s_psV7Version = new SemanticVersion(mainVersion); - s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; + s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV7Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; s_psVersionTable[PSGitCommitIdName] = rawGitCommitId; - s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version }; + s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV7Version }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion(); @@ -270,6 +271,11 @@ internal static string FeatureVersionString internal static bool IsValidPSVersion(Version version) { + if (version.Major == s_psV7Version.Major) + { + return version.Minor == s_psV7Version.Minor; + } + if (version.Major == s_psV6Version.Major) { return version.Minor == s_psV6Version.Minor; @@ -320,6 +326,11 @@ internal static SemanticVersion PSV6Version get { return s_psV6Version; } } + internal static SemanticVersion PSV7Version + { + get { return s_psV7Version; } + } + #endregion } diff --git a/test/hosting/hosting.tests.csproj b/test/hosting/hosting.tests.csproj index 92224de7e8a..f25b83635e9 100644 --- a/test/hosting/hosting.tests.csproj +++ b/test/hosting/hosting.tests.csproj @@ -18,7 +18,7 @@ - + diff --git a/tools/metadata.json b/tools/metadata.json index 41340363b50..70d9c37d4ce 100644 --- a/tools/metadata.json +++ b/tools/metadata.json @@ -1,7 +1,7 @@ { "StableReleaseTag": "v6.2.0", - "PreviewReleaseTag": "v6.2.0-rc.1", + "PreviewReleaseTag": "v7.0.0-preview.1", "ServicingReleaseTag": "v6.0.5", - "ReleaseTag": "v6.2.0", - "NextReleaseTag": "v6.2.0-rc.1" + "ReleaseTag": "v7.0.0", + "NextReleaseTag": "v7.0.0-preview.1" } From 025b2ec40c69b064894e9cc621be55b4ebfc02c6 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Fri, 19 Apr 2019 11:27:33 -0700 Subject: [PATCH 060/103] Allow CI to run on branches with this name pattern: feature* (#9415) --- .vsts-ci/install-ps.yml | 2 ++ .vsts-ci/linux.yml | 2 ++ .vsts-ci/mac.yml | 2 ++ .vsts-ci/misc-analysis.yml | 2 ++ .vsts-ci/windows.yml | 2 ++ 5 files changed, 10 insertions(+) diff --git a/.vsts-ci/install-ps.yml b/.vsts-ci/install-ps.yml index 67b21241de7..2d7d07a63f6 100644 --- a/.vsts-ci/install-ps.yml +++ b/.vsts-ci/install-ps.yml @@ -6,6 +6,7 @@ trigger: include: - master - release* + - feature* paths: include: - /tools/install-powershell.sh @@ -21,6 +22,7 @@ pr: include: - master - release* + - feature* paths: include: - /tools/install-powershell.sh diff --git a/.vsts-ci/linux.yml b/.vsts-ci/linux.yml index ecc83ee813a..7e442ad99c3 100644 --- a/.vsts-ci/linux.yml +++ b/.vsts-ci/linux.yml @@ -6,6 +6,7 @@ trigger: include: - master - release* + - feature* paths: include: - '*' @@ -19,6 +20,7 @@ pr: include: - master - release* + - feature* paths: include: - '*' diff --git a/.vsts-ci/mac.yml b/.vsts-ci/mac.yml index 2e72d6d779f..de46de6b182 100644 --- a/.vsts-ci/mac.yml +++ b/.vsts-ci/mac.yml @@ -6,6 +6,7 @@ trigger: include: - master - release* + - feature* paths: include: - '*' @@ -19,6 +20,7 @@ pr: include: - master - release* + - feature* paths: include: - '*' diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml index f18a3c5a037..f8504fd730f 100644 --- a/.vsts-ci/misc-analysis.yml +++ b/.vsts-ci/misc-analysis.yml @@ -6,12 +6,14 @@ trigger: include: - master - release* + - feature* pr: branches: include: - master - release* + - feature* resources: - repo: self diff --git a/.vsts-ci/windows.yml b/.vsts-ci/windows.yml index 91ed0829157..56ccd52fbbb 100644 --- a/.vsts-ci/windows.yml +++ b/.vsts-ci/windows.yml @@ -6,6 +6,7 @@ trigger: include: - master - release* + - feature* paths: include: - '*' @@ -19,6 +20,7 @@ pr: include: - master - release* + - feature* paths: include: - '*' From 83cbfb384787f79a2eca7e1c84da9fa6dde3ccb2 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 13:53:52 -0700 Subject: [PATCH 061/103] fix typegen for getting ref assemblies to enable add-type --- build.psm1 | 2 +- .../commands/utility/AddType.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 79bd222995f..25df05cfc1d 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1809,7 +1809,7 @@ function Start-TypeGen - <_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> + <_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.IsSystemReference)' == 'true' and '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index bec594e3e9c..c25fc30facc 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -663,7 +663,7 @@ private void LoadAssemblies(IEnumerable assemblies) /// private static IEnumerable InitDefaultRefAssemblies() { - // netcoreapp3.0 currently comes with 145 reference assemblies (maybe more in future), so we use a capacity of '150'. + // netcoreapp3.0 currently comes with 148 reference assemblies (maybe more in future), so we use a capacity of '150'. var defaultRefAssemblies = new List(150); foreach (string file in Directory.EnumerateFiles(s_netcoreAppRefFolder, "*.dll", SearchOption.TopDirectoryOnly)) From 9230cf4b91c61bf76d49b55c8751164e64188353 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 14:50:37 -0700 Subject: [PATCH 062/103] fix psversion test to expect 7 fix building of weblistener due to deprecated apis in aspnet.core --- test/Test.Common.props | 2 +- test/powershell/Host/PSVersionTable.Tests.ps1 | 2 +- test/tools/WebListener/Controllers/MultipartController.cs | 4 ++-- test/tools/WebListener/Startup.cs | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/Test.Common.props b/test/Test.Common.props index 305de3c9884..91853ff7315 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - Latest + Preview true true diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index c1e0d5ef837..573a0a8216e 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -45,7 +45,7 @@ Describe "PSVersionTable" -Tags "CI" { $PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion" $PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion $PSVersionTable.PSVersion | Should -Match $expectedVersionPattern - $PSVersionTable.PSVersion.Major | Should -Be 6 + $PSVersionTable.PSVersion.Major | Should -Be 7 } It "GitCommitId property" { diff --git a/test/tools/WebListener/Controllers/MultipartController.cs b/test/tools/WebListener/Controllers/MultipartController.cs index 43c43681932..435347470ad 100644 --- a/test/tools/WebListener/Controllers/MultipartController.cs +++ b/test/tools/WebListener/Controllers/MultipartController.cs @@ -17,9 +17,9 @@ namespace mvc.Controllers { public class MultipartController : Controller { - private IHostingEnvironment _environment; + private IWebHostEnvironment _environment; - public MultipartController(IHostingEnvironment environment) + public MultipartController(IWebHostEnvironment environment) { _environment = environment; } diff --git a/test/tools/WebListener/Startup.cs b/test/tools/WebListener/Startup.cs index 96aca01e2f6..4f0e2951f07 100644 --- a/test/tools/WebListener/Startup.cs +++ b/test/tools/WebListener/Startup.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Routing.Constraints; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace mvc { @@ -25,11 +26,13 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc(); + services.AddMvc(options => { + options.EnableEndpointRouting = false; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { From 702e8ae040fa3b73d6ba63e1a87c7780dd3669a3 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 16:08:05 -0700 Subject: [PATCH 063/103] update files.wxs due to .NET Core 3.0 dependency changes --- assets/files.wxs | 706 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 559 insertions(+), 147 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index 172c1c71082..47f3776fd2b 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -1205,146 +1205,449 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2017,18 +2320,24 @@ - - - - - - + + + + + + + + + + + + @@ -2612,57 +2921,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2674,6 +2936,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6a0818532c61dbc9a146f4041a150d39e03db6ee Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 17:14:55 -0700 Subject: [PATCH 064/103] set httpsys option to allow sync as aspnetcore3.0 requires it --- test/tools/WebListener/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/tools/WebListener/Program.cs b/test/tools/WebListener/Program.cs index a5535500fc2..9f936a3bfed 100644 --- a/test/tools/WebListener/Program.cs +++ b/test/tools/WebListener/Program.cs @@ -23,7 +23,7 @@ public static void Main(string[] args) if (args.Count() != 6) { System.Console.WriteLine("Required: "); - Environment.Exit(1); + Environment.Exit(1); } BuildWebHost(args).Run(); @@ -68,6 +68,10 @@ public static IWebHost BuildWebHost(string[] args) => listenOptions.UseHttps(httpsOption); }); }) + .UseHttpSys(options => + { + options.AllowSynchronousIO = true; + }) .Build(); } } From 24f58991e98b6854d41298cb36cef74210e6fe49 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 18:43:12 -0700 Subject: [PATCH 065/103] make WindowsDesktop SDK conditional as it doesn't apply to win-arm nor win-arm64 --- src/powershell-win-core/powershell-win-core.csproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index cb35819223b..e85ff974ded 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -1,4 +1,7 @@ - + + + + PowerShell Core on Windows top-level project @@ -12,6 +15,9 @@ ..\..\assets\pwsh.manifest + + + From c59613dce6da5aab5654e1fc1e0ae9194ba07755 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 19 Apr 2019 19:38:26 -0700 Subject: [PATCH 066/103] only use httpsys on Windows --- test/tools/WebListener/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tools/WebListener/Program.cs b/test/tools/WebListener/Program.cs index 9f936a3bfed..64ee02afa02 100644 --- a/test/tools/WebListener/Program.cs +++ b/test/tools/WebListener/Program.cs @@ -68,10 +68,12 @@ public static IWebHost BuildWebHost(string[] args) => listenOptions.UseHttps(httpsOption); }); }) +#if !UNIX .UseHttpSys(options => { options.AllowSynchronousIO = true; }) +#endif .Build(); } } From b05ef05781c2ddee0163eeeaf078f3a543bbfb70 Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Sat, 20 Apr 2019 21:33:29 -0700 Subject: [PATCH 067/103] Fix WebListener for .NET Core 3.0 --- test/tools/WebListener/Program.cs | 7 +------ test/tools/WebListener/Startup.cs | 3 ++- test/tools/WebListener/WebListener.csproj | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test/tools/WebListener/Program.cs b/test/tools/WebListener/Program.cs index 64ee02afa02..54af72860fe 100644 --- a/test/tools/WebListener/Program.cs +++ b/test/tools/WebListener/Program.cs @@ -33,6 +33,7 @@ public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder() .UseStartup().UseKestrel(options => { + options.AllowSynchronousIO = true; options.Listen(IPAddress.Loopback, int.Parse(args[2])); options.Listen(IPAddress.Loopback, int.Parse(args[3]), listenOptions => { @@ -68,12 +69,6 @@ public static IWebHost BuildWebHost(string[] args) => listenOptions.UseHttps(httpsOption); }); }) -#if !UNIX - .UseHttpSys(options => - { - options.AllowSynchronousIO = true; - }) -#endif .Build(); } } diff --git a/test/tools/WebListener/Startup.cs b/test/tools/WebListener/Startup.cs index 4f0e2951f07..4cf2685cadc 100644 --- a/test/tools/WebListener/Startup.cs +++ b/test/tools/WebListener/Startup.cs @@ -28,7 +28,8 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.EnableEndpointRouting = false; - }); + }) + .AddNewtonsoftJson(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 8e856b3a0f8..b25eac44693 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,6 +7,7 @@ + From 3141a8bd56c469f265fcbaa6a59b0ba05c5951b5 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 22 Apr 2019 09:57:28 -0700 Subject: [PATCH 068/103] fix symlink tests - /tmp on macOS is hidden, so need to use -force - target is no longer an array, so remove indexing --- .../FileSystem.Tests.ps1 | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 3d083b9b756..29d6551421f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -414,7 +414,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" { $item = Get-Item $TestPath $dirName = $item.BaseName - $item = Get-Item $item.PSParentPath + $item = Get-Item $item.PSParentPath -Force if ($item.LinkType -eq "SymbolicLink") { $TestPath = Join-Path $item.Target $dirName @@ -439,44 +439,41 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" Context "New-Item and hard/symbolic links" { It "New-Item can create a hard link to a file" { - New-Item -ItemType HardLink -Path $hardLinkToFile -Value $realFile + New-Item -ItemType HardLink -Path $hardLinkToFile -Value $realFile > $null Test-Path $hardLinkToFile | Should -BeTrue $link = Get-Item -Path $hardLinkToFile $link.LinkType | Should -BeExactly "HardLink" Get-Content -Path $hardLinkToFile | Should -Be $fileContent } It "New-Item can create symbolic link to file" { - New-Item -ItemType SymbolicLink -Path $symLinkToFile -Value $realFile + New-Item -ItemType SymbolicLink -Path $symLinkToFile -Value $realFile > $null Test-Path $symLinkToFile | Should -BeTrue $real = Get-Item -Path $realFile $link = Get-Item -Path $symLinkToFile $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target.Count | Should -Be 1 - $link.Target[0] | Should -BeExactly $real.ToString() + $link.Target | Should -BeExactly $real.ToString() Get-Content -Path $symLinkToFile | Should -Be $fileContent } It "New-Item can create a symbolic link to nothing" { - New-Item -ItemType SymbolicLink -Path $symLinkToNothing -Value $nonFile + New-Item -ItemType SymbolicLink -Path $symLinkToNothing -Value $nonFile > $null Test-Path $symLinkToNothing | Should -BeTrue $link = Get-Item -Path $symLinkToNothing $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target.Count | Should -Be 1 - $link.Target[0] | Should -Be $nonFile.ToString() + $link.Target | Should -Be $nonFile.ToString() } It "New-Item emits an error when path to symbolic link already exists." { { New-Item -ItemType SymbolicLink -Path $realDir -Value $symLinkToDir -ErrorAction Stop } | Should -Throw -ErrorId "SymLinkExists,Microsoft.PowerShell.Commands.NewItemCommand" } It "New-Item can create a symbolic link to a directory" -Skip:($IsWindows) { - New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir + New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir > $null Test-Path $symLinkToDir | Should -BeTrue $real = Get-Item -Path $realDir $link = Get-Item -Path $symLinkToDir $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target.Count | Should -Be 1 - $link.Target[0] | Should -BeExactly $real.ToString() + $link.Target | Should -BeExactly $real.ToString() } It "New-Item can create a directory symbolic link to a directory" -Skip:(-Not $IsWindows) { - New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir + New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $realDir > $null Test-Path $symLinkToDir | Should -BeTrue $real = Get-Item -Path $realDir $link = Get-Item -Path $symLinkToDir @@ -486,7 +483,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" $link.Target[0] | Should -BeExactly $real.ToString() } It "New-Item can create a directory junction to a directory" -Skip:(-Not $IsWindows) { - New-Item -ItemType Junction -Path $junctionToDir -Value $realDir + New-Item -ItemType Junction -Path $junctionToDir -Value $realDir > $null Test-Path $junctionToDir | Should -BeTrue } } From 01931dd2a896abb0f0bad8271a5288afa9b15f25 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 22 Apr 2019 10:06:14 -0700 Subject: [PATCH 069/103] rename and update json tests for change in precision update measure-objec test for additional precision --- ...ter.Commands.Cmdlets.Json.Tests.ps1 => Json.Tests.ps1} | 8 ++++---- .../Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename test/powershell/Modules/Microsoft.PowerShell.Utility/{Pester.Commands.Cmdlets.Json.Tests.ps1 => Json.Tests.ps1} (99%) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Pester.Commands.Cmdlets.Json.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Json.Tests.ps1 similarity index 99% rename from test/powershell/Modules/Microsoft.PowerShell.Utility/Pester.Commands.Cmdlets.Json.Tests.ps1 rename to test/powershell/Modules/Microsoft.PowerShell.Utility/Json.Tests.ps1 index 35d3bc68ba2..da7c67f875b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Pester.Commands.Cmdlets.Json.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Json.Tests.ps1 @@ -1210,13 +1210,13 @@ Describe "Validate Json serialization" -Tags "CI" { # Single @{ TestInput = '[single]::MaxValue' - FromJson = "3.40282347E+38" - ToJson = "3.40282347E+38" + FromJson = "3.4028235E+38" + ToJson = "3.4028235E+38" } @{ TestInput = '[single]::MinValue' - FromJson = "-3.40282347E+38" - ToJson = "-3.40282347E+38" + FromJson = "-3.4028235E+38" + ToJson = "-3.4028235E+38" } # Double diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 index 4f363fe972b..55ddd830671 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 @@ -182,7 +182,7 @@ Describe "Measure-Object" -Tags "CI" { $result.Sum | Should -Be 55 $result.Minimum | Should -Be 1 $result.Maximum | Should -Be 10 - ($result.StandardDeviation).ToString() | Should -Be '3.02765035409749' + ($result.StandardDeviation).ToString() | Should -Be '3.0276503540974917' } } From f15430e5132e48c73a49b55354ffe4fe2a910459 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 22 Apr 2019 17:37:59 -0700 Subject: [PATCH 070/103] fix tests where the cmdlet returns longpath fix symlink test on windows where Target is no longer an array update loaded assemblies list --- test/powershell/Host/Startup.Tests.ps1 | 2 +- .../{TestGetCommand.Tests.ps1 => Get-Command.Tests.ps1} | 2 +- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Core/Import-Module.Tests.ps1 | 6 +++--- .../Convert-Path.Tests.ps1 | 2 +- .../Microsoft.PowerShell.Management/FileSystem.Tests.ps1 | 3 +-- test/tools/Modules/HelpersCommon/HelpersCommon.psm1 | 9 +++++++++ 7 files changed, 18 insertions(+), 10 deletions(-) rename test/powershell/Modules/Microsoft.PowerShell.Core/{TestGetCommand.Tests.ps1 => Get-Command.Tests.ps1} (99%) diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index 16648a585d8..af8936411bc 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -72,6 +72,7 @@ Describe "Validate start of console host" -Tag CI { 'System.Threading.Tasks.dll' 'System.Threading.Tasks.Parallel.dll' 'System.Threading.Thread.dll' + 'System.Threading.ThreadPool.dll' 'System.Threading.Timer.dll' 'System.Xml.ReaderWriter.dll' 'System.Xml.XDocument.dll' @@ -92,7 +93,6 @@ Describe "Validate start of console host" -Tag CI { 'System.IO.MemoryMappedFiles.dll' 'System.Net.Sockets.dll' 'System.Reflection.Metadata.dll' - 'System.Threading.ThreadPool.dll' ) } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/TestGetCommand.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 similarity index 99% rename from test/powershell/Modules/Microsoft.PowerShell.Core/TestGetCommand.Tests.ps1 rename to test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 index 2a34c3aad7e..749615d76ee 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/TestGetCommand.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 @@ -228,7 +228,7 @@ Describe "Get-Command Tests" -Tags "CI" { $results = Get-Command $fullPath $results.Name | Should -BeExactly $tempFile - $results.Definition | Should -BeExactly $fullPath + $results.Definition | Should -BeExactly (Resolve-FilePath $fullPath) } It "Two dynamic parameters are created properly" { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 8d851643785..1d7ec03eba0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -248,10 +248,10 @@ Describe 'Get-Module -ListAvailable with path' -Tags "CI" { $modules | Should -HaveCount 2 $modules[0].Name | Should -BeExactly $moduleName - $modules[0].Path | Should -BeExactly $manifestV1Path + $modules[0].Path | Should -BeExactly (Resolve-FilePath $manifestV1Path) $modules[0].Version | Should -Be $v1 $modules[1].Name | Should -BeExactly $moduleName - $modules[1].Path | Should -BeExactly $manifestV2Path + $modules[1].Path | Should -BeExactly (Resolve-FilePath $manifestV2Path) $modules[1].Version | Should -Be $v2 } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 index 218e62098c7..7969c734f7f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 @@ -173,7 +173,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { $job | Remove-Job -ErrorAction Ignore } - $assemblyLocation | Should -BeExactly $TestModulePath + $assemblyLocation | Should -BeExactly (Resolve-FilePath $TestModulePath) $cmdletOutput | Should -BeExactly "BinaryModuleCmdlet1 exported by the ModuleCmdlets module." } @@ -218,7 +218,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { $module.ModuleType.ToString() | Should -Be 'Manifest' $module.ExportedCmdlets['Test-BinaryModuleCmdlet1'] | Should -Be 'Test-BinaryModuleCmdlet1' $module.NestedModules | Should -Not -BeNullOrEmpty - $location | Should -Be $exe + $location | Should -Be (Resolve-FilePath $exe) } It "PS should try to load the assembly from assembly name if file path doesn't exist" { @@ -258,7 +258,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { # Use a different pwsh so that we do not have the PSScheduledJob module already loaded. $loadedAssemblyLocation = pwsh -noprofile -c "Import-Module $destPath -Force; [Microsoft.PowerShell.ScheduledJob.AddJobTriggerCommand].Assembly.Location" - $loadedAssemblyLocation | Should -BeLike "$TestDrive*\Microsoft.PowerShell.ScheduledJob.dll" + $loadedAssemblyLocation | Should -BeLike "$(Resolve-FilePath $TestDrive)*\Microsoft.PowerShell.ScheduledJob.dll" } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 index 6205d70229a..c2add8bc2fa 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 @@ -14,7 +14,7 @@ Describe "Convert-Path tests" -Tag CI { } It "Convert-Path supports pipelined input by property name" { - Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly "$TestDrive" + Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly (Resolve-FilePath $TestDrive) } It "Convert-Path without arguments is an error" { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 29d6551421f..379e14ba631 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -479,8 +479,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" $link = Get-Item -Path $symLinkToDir $link | Should -BeOfType System.IO.DirectoryInfo $link.LinkType | Should -BeExactly "SymbolicLink" - $link.Target.Count | Should -Be 1 - $link.Target[0] | Should -BeExactly $real.ToString() + $link.Target | Should -BeExactly $real.ToString() } It "New-Item can create a directory junction to a directory" -Skip:(-Not $IsWindows) { New-Item -ItemType Junction -Path $junctionToDir -Value $realDir > $null diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index 7a3b5e9089d..fece7c47bc8 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -344,3 +344,12 @@ function Test-CanWriteToPsHome $script:CanWriteToPsHome } + +# This resolves a short path on Windows to the long path +function Resolve-FilePath($path) { + if (!$IsWindows) { + return $path + } + + ([System.IO.FileInfo]::new($path)).FullName +} From c9be025c3183092ed48ac0a912d2cf39c913824e Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 22 Apr 2019 18:58:03 -0700 Subject: [PATCH 071/103] add Resolve-FilePath to module manifest --- test/tools/Modules/HelpersCommon/HelpersCommon.psd1 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 index c217dc6e72a..93a9b35ca38 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 @@ -23,6 +23,7 @@ FunctionsToExport = @( 'Enable-Testhook' 'Get-RandomFileName' 'New-RandomHexString' + 'Resolve-FilePath' 'Send-VstsLogFile' 'Set-TesthookResult' 'Start-NativeExecution' From 205815463afce567fcfc72ee58e54a82ba16bf4b Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 11:05:29 +1000 Subject: [PATCH 072/103] Fix testdrive paths in requires and module tests --- .../Language/Scripting/Requires.Tests.ps1 | 6 +- .../Get-Module.Tests.ps1 | 95 ++++++++++--------- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/test/powershell/Language/Scripting/Requires.Tests.ps1 b/test/powershell/Language/Scripting/Requires.Tests.ps1 index d86e683e26c..2288be03415 100644 --- a/test/powershell/Language/Scripting/Requires.Tests.ps1 +++ b/test/powershell/Language/Scripting/Requires.Tests.ps1 @@ -45,11 +45,11 @@ Describe "#requires -Modules" -Tags "CI" { $sep = [System.IO.Path]::DirectorySeparatorChar $altSep = [System.IO.Path]::AltDirectorySeparatorChar - $scriptPath = Join-Path $TestDrive 'script.ps1' + $scriptPath = Join-Path (Resolve-FilePath $TestDrive) 'script.ps1' $moduleName = 'Banana' $moduleVersion = '0.12.1' - $moduleDirPath = Join-Path $TestDrive 'modules' + $moduleDirPath = Join-Path (Resolve-FilePath $TestDrive) 'modules' New-Item -Path $moduleDirPath -ItemType Directory $modulePath = "$moduleDirPath${sep}$moduleName" New-Item -Path $modulePath -ItemType Directory @@ -62,7 +62,7 @@ Describe "#requires -Modules" -Tags "CI" { Context "Requiring non-existent modules" { BeforeAll { $badName = 'ModuleThatDoesNotExist' - $badPath = Join-Path $TestDrive 'ModuleThatDoesNotExist' + $badPath = Join-Path (Resolve-FilePath $TestDrive) 'ModuleThatDoesNotExist' $version = '1.0' $testCases = @( @{ ModuleRequirement = "'$badName'"; Scenario = 'name' } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 1d7ec03eba0..ea5b0eb79ba 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -6,34 +6,36 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { BeforeAll { $originalPSModulePath = $env:PSModulePath - New-Item -ItemType Directory -Path "$testdrive\Modules\Foo\1.1" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\Foo\2.0" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\Bar\Download" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\Zoo\Too" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\Az" -Force > $null - - New-ModuleManifest -Path "$testdrive\Modules\Foo\1.1\Foo.psd1" -ModuleVersion 1.1 - New-ModuleManifest -Path "$testdrive\Modules\Foo\2.0\Foo.psd1" -ModuleVersion 2.0 - New-ModuleManifest -Path "$testdrive\Modules\Bar\Bar.psd1" - New-ModuleManifest -Path "$testdrive\Modules\Zoo\Zoo.psd1" - New-ModuleManifest -Path "$testdrive\Modules\Az\Az.psd1" -ModuleVersion 1.1 - - New-Item -ItemType File -Path "$testdrive\Modules\Foo\1.1\Foo.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Foo\2.0\Foo.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Bar\Bar.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Bar\Download\Download.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Zoo\Zoo.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Zoo\Too\Zoo.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Az\Az.psm1" > $null + $resolvedTestDrive = Resolve-FilePath $TestDrive + + New-Item -ItemType Directory -Path "$resolveTestPath\Modules\Foo\1.1" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\2.0" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Bar\Download" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Zoo\Too" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Az" -Force > $null + + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Foo\1.1\Foo.psd1" -ModuleVersion 1.1 + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Foo\2.0\Foo.psd1" -ModuleVersion 2.0 + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Bar\Bar.psd1" + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1" + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Az\Az.psd1" -ModuleVersion 1.1 + + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Foo\1.1\Foo.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Foo\2.0\Foo.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Bar\Bar.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Bar\Download\Download.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Az\Az.psm1" > $null $fullyQualifiedPathTestCases = @( - @{ ModPath = "$TestDrive/Modules\Foo"; Name = 'Foo'; Version = '2.0'; Count = 1 } - @{ ModPath = "$TestDrive\Modules/Foo\1.1/Foo.psd1"; Name = 'Foo'; Version = '1.1'; Count = 1 } - @{ ModPath = "$TestDrive\Modules/Bar.psd1"; Name = 'Bar'; Version = '0.0'; Count = 1 } - @{ ModPath = "$TestDrive\Modules\Zoo\Too\Zoo.psm1"; Name = 'Zoo'; Version = '0.0'; Count = 1 } + @{ ModPath = "$resolvedTestDrive/Modules\Foo"; Name = 'Foo'; Version = '2.0'; Count = 1 } + @{ ModPath = "$resolvedTestDrive\Modules/Foo\1.1/Foo.psd1"; Name = 'Foo'; Version = '1.1'; Count = 1 } + @{ ModPath = "$resolvedTestDrive\Modules/Bar.psd1"; Name = 'Bar'; Version = '0.0'; Count = 1 } + @{ ModPath = "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1"; Name = 'Zoo'; Version = '0.0'; Count = 1 } ) - $env:PSModulePath = Join-Path $testdrive "Modules" + $env:PSModulePath = Join-Path $resolvedTestDrive "Modules" } AfterAll { @@ -78,11 +80,11 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules[7].Version | Should -Be "2.0" $modules[8].ModuleType | Should -BeExactly "Script" $modules[9].ModuleType | Should -BeExactly "Script" - $modules[9].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[9].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path $modules[10].ModuleType | Should -BeExactly "Manifest" - $modules[10].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psd1").Path + $modules[10].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1").Path $modules[11].ModuleType | Should -BeExactly "Script" - $modules[11].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psm1").Path + $modules[11].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1").Path } It "Get-Module -ListAvailable -All" { @@ -91,14 +93,14 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules = $modules | Sort-Object -Property Name, Path $modules.Name -join "," | Should -BeExactly "Download,Zoo,Zoo,Zoo" - $modules[0].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Bar\Download\Download.psm1").Path - $modules[1].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path - $modules[2].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psd1").Path - $modules[3].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psm1").Path + $modules[0].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Bar\Download\Download.psm1").Path + $modules[1].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[2].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1").Path + $modules[3].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1").Path } It "Get-Module -ListAvailable" { - $modules = Get-Module "$testdrive\Modules\*" -ListAvailable + $modules = Get-Module "$resolvedTestDrive\Modules\*" -ListAvailable $modules.Count | Should -Be 5 $modules = $modules | Sort-Object -Property Name, Version $modules.Name -join "," | Should -BeExactly "Az,Bar,Foo,Foo,Zoo" @@ -107,11 +109,11 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } It "Get-Module -ListAvailable -All" { - $modules = Get-Module "$testdrive\Modules\*" -ListAvailable -All + $modules = Get-Module "$resolvedTestDrive\Modules\*" -ListAvailable -All $modules.Count | Should -Be 6 $modules = $modules | Sort-Object -Property Name, Path $modules.Name -join "," | Should -BeExactly "Az,Bar,Foo,Foo,Zoo,Zoo" - $modules[4].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[4].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path } It "Get-Module -FullyQualifiedName -ListAvailable" { @@ -128,7 +130,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules.Name | Should -BeExactly "Zoo" $modules.ExportedFunctions.Count | Should -Be 0 -Because 'No exports were defined' - New-ModuleManifest -Path "$testdrive\Modules\Zoo\Zoo.psd1" -FunctionsToExport 'Test-ZooFunction' + New-ModuleManifest -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1" -FunctionsToExport 'Test-ZooFunction' $modules = Get-Module -Name 'Zoo' -ListAvailable -Refresh $modules | Should -HaveCount 1 @@ -153,17 +155,17 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Context "PSEdition" { BeforeAll { - New-Item -ItemType Directory -Path "$testdrive\Modules\DesktopOnlyModule" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\CoreOnlyModule" -Force > $null - New-Item -ItemType Directory -Path "$testdrive\Modules\CoreAndDesktopModule" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\DesktopOnlyModule" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\CoreOnlyModule" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule" -Force > $null - New-ModuleManifest -Path "$testdrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psd1" -CompatiblePSEditions Desktop - New-ModuleManifest -Path "$testdrive\Modules\CoreOnlyModule\CoreOnlyModule.psd1" -CompatiblePSEditions Core - New-ModuleManifest -Path "$testdrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psd1" -CompatiblePSEditions Core, Desktop + New-ModuleManifest -Path "$resolvedTestDrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psd1" -CompatiblePSEditions Desktop + New-ModuleManifest -Path "$resolvedTestDrive\Modules\CoreOnlyModule\CoreOnlyModule.psd1" -CompatiblePSEditions Core + New-ModuleManifest -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psd1" -CompatiblePSEditions Core, Desktop - New-Item -ItemType File -Path "$testdrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\CoreOnlyModule\CoreOnlyModule.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\CoreOnlyModule\CoreOnlyModule.psm1" > $null + New-Item -ItemType File -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psm1" > $null } It "Get-Module -PSEdition -ListAvailable" -TestCases @( @@ -179,7 +181,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Context "Module analysis shouldn't load assembly" { BeforeAll { - $tempModulePath = Join-Path $TestDrive "TempModules" + $tempModulePath = Join-Path $resolvedTestDrive "TempModules" $testModuleDir = Join-Path $tempModulePath "MyModuelTest" $moduleManifest = Join-Path $testModuleDir "MyModuelTest.psd1" $assemblyPath = Join-Path $testModuleDir "MyModuelTestCommandAssembly.dll" @@ -228,7 +230,8 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Describe 'Get-Module -ListAvailable with path' -Tags "CI" { BeforeAll { $moduleName = 'Banana' - $modulePath = Join-Path $TestDrive $moduleName + $resolvedTestDrive = Resolve-FilePath $TestDrive + $modulePath = Join-Path $resolvedTestDrive $moduleName $v1 = '1.2.3' $v2 = '4.8.3' $v1DirPath = Join-Path $modulePath $v1 From 722408f081e6ee803f6b7c6a849ed6570786875b Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 11:14:39 +1000 Subject: [PATCH 073/103] [feature] Resolve CompatiblePSEditions test drive paths --- .../CompatiblePSEditions.Module.Tests.ps1 | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 767679c82e2..fd367364011 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -149,7 +149,7 @@ Describe "Get-Module with CompatiblePSEditions-checked paths" -Tag "CI" { @{ Editions = $null; ModuleName = "NeitherModule" } ) - $basePath = Join-Path $TestDrive "EditionCompatibleModules" + $basePath = Join-Path (Resolve-FilePath $TestDrive) "EditionCompatibleModules" New-TestModules -TestCases $successCases -BaseDir $basePath New-TestModules -TestCases $failCases -BaseDir $basePath @@ -242,7 +242,7 @@ Describe "Import-Module from CompatiblePSEditions-checked paths" -Tag "CI" { @{ Editions = $null; ModuleName = "NeitherModule"; Result = $true } ) - $basePath = Join-Path $TestDrive "EditionCompatibleModules" + $basePath = Join-Path (Resolve-FilePath $TestDrive) "EditionCompatibleModules" New-TestModules -TestCases $successCases -BaseDir $basePath New-TestModules -TestCases $failCases -BaseDir $basePath @@ -387,6 +387,8 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur $testCases = $list } + $resolvedTestDrive = Resolve-FilePath $TestDrive + # Define nested script module $scriptModuleName = "NestedScriptModule" $scriptModuleFile = "$scriptModuleName.psm1" @@ -396,7 +398,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur $binaryModuleName = "NestedBinaryModule" $binaryModuleFile = "$binaryModuleName.dll" $binaryModuleContent = 'public static class TestBinaryModuleClass { public static bool Test() { return true; } }' - $binaryModuleSourcePath = Join-Path $TestDrive $binaryModuleFile + $binaryModuleSourcePath = Join-Path $resolvedTestDrive $binaryModuleFile Add-Type -OutputAssembly $binaryModuleSourcePath -TypeDefinition $binaryModuleContent # Define root module definition @@ -407,8 +409,8 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Module directory structure: $TestDrive/$compatibility/$guid/$moduleName/{module parts} $compatibleDir = "Compatible" $incompatibleDir = "Incompatible" - $compatiblePath = Join-Path $TestDrive $compatibleDir - $incompatiblePath = Join-Path $TestDrive $incompatibleDir + $compatiblePath = Join-Path $resolvedTestDrive $compatibleDir + $incompatiblePath = Join-Path $resolvedTestDrive $incompatibleDir foreach ($basePath in $compatiblePath,$incompatiblePath) { @@ -429,7 +431,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Create the module directory $guid = New-Guid $compatibilityDir = $incompatibleDir - $containingDir = Join-Path $TestDrive $compatibilityDir $guid + $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -559,7 +561,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Create the module directory $guid = New-Guid $compatibilityDir = $compatibleDir - $containingDir = Join-Path $TestDrive $compatibilityDir $guid + $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -690,6 +692,8 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea $testCases = $list } + $resolvedTestDrive = Resolve-FilePath $TestDrive + # Define nested script module $scriptModuleName = "NestedScriptModule" $scriptModuleFile = "$scriptModuleName.psm1" @@ -703,8 +707,8 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Module directory structure: $TestDrive/$compatibility/$guid/$moduleName/{module parts} $compatibleDir = "Compatible" $incompatibleDir = "Incompatible" - $compatiblePath = Join-Path $TestDrive $compatibleDir - $incompatiblePath = Join-Path $TestDrive $incompatibleDir + $compatiblePath = Join-Path $resolvedTestDrive $compatibleDir + $incompatiblePath = Join-Path $resolvedTestDrive $incompatibleDir foreach ($basePath in $compatiblePath,$incompatiblePath) { @@ -725,7 +729,7 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Create the module directory $guid = New-Guid $compatibilityDir = $incompatibleDir - $containingDir = Join-Path $TestDrive $compatibilityDir $guid + $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -815,7 +819,7 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Create the module directory $guid = New-Guid $compatibilityDir = $compatibleDir - $containingDir = Join-Path $TestDrive $compatibilityDir $guid + $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory From ec4fb6dc2fb5c0d390435b33950924217f8176fc Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 12:28:17 +1000 Subject: [PATCH 074/103] [feature] fix typo --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index ea5b0eb79ba..2c88bef2413 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $resolvedTestDrive = Resolve-FilePath $TestDrive - New-Item -ItemType Directory -Path "$resolveTestPath\Modules\Foo\1.1" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestPath\Modules\Foo\1.1" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\2.0" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Bar\Download" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Zoo\Too" -Force > $null From e3f3217122edd658c6a4bddf9bf009fc40820b4f Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 12:36:07 +1000 Subject: [PATCH 075/103] [feature] Fix typo --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 2c88bef2413..656ea902c27 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $resolvedTestDrive = Resolve-FilePath $TestDrive - New-Item -ItemType Directory -Path "$resolvedTestPath\Modules\Foo\1.1" -Force > $null + New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\1.1" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\2.0" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Bar\Download" -Force > $null New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Zoo\Too" -Force > $null From a38ef6eed43ee112e919a7de57c78b3bec3c2dfc Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 13:23:16 +1000 Subject: [PATCH 076/103] [feature] Fix module manifest tests --- .../ModuleManifest.Tests.ps1 | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 index 504984dfe32..40f3516a7da 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 @@ -57,12 +57,13 @@ function New-ModuleFromLayout Describe "Manifest required module autoloading from module path with simple names" -Tags "CI" { BeforeAll { $prevModulePath = $env:PSModulePath - $env:PSModulePath = ($TestDrive -as [string]) + [System.IO.Path]::PathSeparator + $env:PSModulePath + $resolvedTestDrive = Resolve-FilePath $TestDrive + $env:PSModulePath = $resolvedTestDrive + [System.IO.Path]::PathSeparator + $env:PSModulePath $mainModule = 'mainmod' $requiredModule = 'reqmod' - New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = $requiredModule @@ -94,12 +95,14 @@ Describe "Manifest required module autoloading with relative path to dir" -Tags $mainModule = 'mainmod' $requiredModule = 'reqmod' - $mainModPath = Join-Path $TestDrive $mainModule + $resolvedTestDrive = Resolve-FilePath $TestDrive + + $mainModPath = Join-Path $resolvedTestDrive $mainModule # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar - New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = "..${altSep}$requiredModule" @@ -130,13 +133,15 @@ Describe "Manifest required module autoloading with relative path to manifest" - $mainModule = 'mainmod' $requiredModule = 'reqmod' - $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" + $resolvedTestDrive = Resolve-FilePath $TestDrive + + $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = "..${altSep}$requiredModule${sep}$requiredModule.psd1" @@ -167,16 +172,18 @@ Describe "Manifest required module autoloading with absolute path to dir" -Tags $mainModule = 'mainmod' $requiredModule = 'reqmod' - $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" + $resolvedTestDrive = Resolve-FilePath $TestDrive + + $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ - RequiredModules = "$TestDrive${altSep}$requiredModule${sep}" + RequiredModules = "$resolvedTestDrive${altSep}$requiredModule${sep}" } } $requiredModule = @{ @@ -204,16 +211,18 @@ Describe "Manifest required module autoloading with absolute path to manifest" - $mainModule = 'mainmod' $requiredModule = 'reqmod' - $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" + $resolvedTestDrive = Resolve-FilePath $TestDrive + + $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ - RequiredModules = "$TestDrive${altSep}$requiredModule${sep}$requiredModule.psd1" + RequiredModules = "$resolvedTestDrive${altSep}$requiredModule${sep}$requiredModule.psd1" } } $requiredModule = @{ From fa98e15e74df11046b77d70fde0c6f645b0b6e04 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 24 Apr 2019 14:56:16 +1000 Subject: [PATCH 077/103] Fix module cleanup --- .../Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 index 40f3516a7da..d586b2d52c2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 @@ -77,7 +77,7 @@ Describe "Manifest required module autoloading from module path with simple name AfterAll { $env:PSModulePath = $prevModulePath - Get-Module $mainModule,$requiredModule | Remove-Module + Remove-Module $mainModule,$requiredModule -ErrorAction SilentlyContinue } It "Importing main module loads required modules successfully" { From 9d4c0a881edffdf55b40c7c90906b4e260716658 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 30 Apr 2019 17:41:45 -0700 Subject: [PATCH 078/103] use FileInfo to resolve path on non-Windows as `$TestDrive` is actually an array --- test/tools/Modules/HelpersCommon/HelpersCommon.psm1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index fece7c47bc8..1626fc8ee67 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -347,9 +347,5 @@ function Test-CanWriteToPsHome # This resolves a short path on Windows to the long path function Resolve-FilePath($path) { - if (!$IsWindows) { - return $path - } - ([System.IO.FileInfo]::new($path)).FullName } From ebb20c09047b5a8b4d8bd4d56ea282bc1afecb04 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 30 Apr 2019 21:10:42 -0700 Subject: [PATCH 079/103] if the module is already loaded, don't try to create it and load it again --- .../Remove-Module.Tests.ps1 | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 index 37739cdb7ad..a869391a119 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 @@ -216,42 +216,42 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" { New-ModuleManifest -Path "$testdrive\Modules\Foo\Foo_ro.psd1" New-ModuleManifest -Path "$testdrive\Modules\Foo\Foo_rw.psd1" New-ModuleManifest -Path "$testdrive\Modules\Bar\Bar_rw.psd1" - New-ModuleManifest -Path "$testdrive\Modules\Baz\Baz_const.psd1" + New-ModuleManifest -Path "$testdrive\Modules\Baz\Const_module.psd1" New-Item -ItemType File -Path "$testdrive\Modules\Foo\Foo_ro.psm1" > $null New-Item -ItemType File -Path "$testdrive\Modules\Foo\Foo_rw.psm1" > $null New-Item -ItemType File -Path "$testdrive\Modules\Bar\Bar_rw.psm1" > $null - New-Item -ItemType File -Path "$testdrive\Modules\Baz\Baz_const.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Baz\Const_module.psm1" > $null $removeReadOnlyModulesTestCases = @( # Simple patterns - @{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw"} - @{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro"} - @{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Baz_const", "Foo_ro"} + @{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro", "Foo_rw"} + @{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro"} + @{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Const_module", "Foo_ro"} # Regex patterns - @{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro"} - @{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Baz_const", "Foo_ro"} + @{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro"} + @{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_rw"; ShouldBePresent = "Const_module", "Foo_ro"} ) $removeForceReadOnlyModulesTestCases = @( # Simple patterns - @{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = "Foo_ro"; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_rw"} - @{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"} - @{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"} + @{ NamesToRemove = "Foo_ro"; ShouldBeRemoved = "Foo_ro"; ShouldBePresent = "Bar_rw", "Const_module", "Foo_rw"} + @{ NamesToRemove = "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"} + @{ NamesToRemove = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"} # Regex patterns - @{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"} - @{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"} + @{ NamesToRemove = "Foo_*"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"} + @{ NamesToRemove = "Foo_*", "Bar_*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"} ) $removeConstantModulesTestCases = @( # Simple patterns - @{ NamesToRemove = "Baz_const"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw"} - @{ NamesToRemove = "Baz_const", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Baz_const"} + @{ NamesToRemove = "Const_module"; ShouldBeRemoved = ""; ShouldBePresent = "Bar_rw", "Const_module", "Foo_ro", "Foo_rw"} + @{ NamesToRemove = "Const_module", "Foo_ro", "Foo_rw"; ShouldBeRemoved = "Foo_ro", "Foo_rw"; ShouldBePresent = "Bar_rw", "Const_module"} # Regex patterns - @{ NamesToRemove = "Foo_*", "Ba*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Baz_const"} + @{ NamesToRemove = "Foo_*", "Ba*", "Const*"; ShouldBeRemoved = "Bar_rw", "Foo_ro", "Foo_rw"; ShouldBePresent = "Const_module"} ) } @@ -264,8 +264,11 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" { (Get-Module -Name "Foo_ro").AccessMode = "readOnly" Import-Module -Name "$testdrive\Modules\Foo\Foo_rw.psd1" -Force Import-Module -Name "$testdrive\Modules\Bar\Bar_rw.psd1" -Force - Import-Module -Name "$testdrive\Modules\Baz\Baz_const.psd1" -Force - (Get-Module -Name "Baz_const").AccessMode = "Constant" + + if ($null -eq (Get-Module "Const_module")) { + Import-Module -Name "$testdrive\Modules\Baz\Const_module.psd1" -Force + (Get-Module -Name "Const_module").AccessMode = "Constant" + } } It "Remove-Module (ReadOnly modules): " -TestCases $removeReadOnlyModulesTestCases { @@ -304,7 +307,7 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" { It "Remove-Module -Force (Constant modules): " -TestCases $removeConstantModulesTestCases { param([string[]]$NamesToRemove, [string[]]$ShouldBeRemoved, [string[]]$ShouldBePresent) - (Get-Module -Name "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw").Name | Should -BeExactly "Bar_rw", "Baz_const", "Foo_ro", "Foo_rw" + (Get-Module -Name "Bar_rw", "Const_module", "Foo_ro", "Foo_rw").Name | Should -BeExactly "Bar_rw", "Const_module", "Foo_ro", "Foo_rw" { Remove-Module -Force -Name $NamesToRemove -ErrorAction Stop } | Should -Throw -ErrorId "Modules_ModuleIsConstant,Microsoft.PowerShell.Commands.RemoveModuleCommand" { Remove-Module -Force -Name $NamesToRemove -ErrorAction SilentlyContinue } | Should -Not -Throw From 476d27fa5b20cd3f2e586de74413de5dc3400e4e Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Tue, 30 Apr 2019 22:25:37 -0700 Subject: [PATCH 080/103] add comment --- .../Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 index a869391a119..7928bd1a9bb 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 @@ -265,6 +265,10 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" { Import-Module -Name "$testdrive\Modules\Foo\Foo_rw.psd1" -Force Import-Module -Name "$testdrive\Modules\Bar\Bar_rw.psd1" -Force + # If this test is run again in the same session, this test module + # will already be loaded and can't be removed because it sets + # AccessMode to Constant, so only import this test module and + # set AccessMode if it isn't already loaded if ($null -eq (Get-Module "Const_module")) { Import-Module -Name "$testdrive\Modules\Baz\Const_module.psd1" -Force (Get-Module -Name "Const_module").AccessMode = "Constant" From bc32fc89c2f03b5a8b2cbf494e312e8333a8c9d5 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 1 May 2019 07:23:13 -0700 Subject: [PATCH 081/103] Update test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 Co-Authored-By: SteveL-MSFT --- .../Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 index 7928bd1a9bb..a12c1e45115 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1 @@ -269,7 +269,7 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" { # will already be loaded and can't be removed because it sets # AccessMode to Constant, so only import this test module and # set AccessMode if it isn't already loaded - if ($null -eq (Get-Module "Const_module")) { + if ($null -eq (Get-Module -Name "Const_module")) { Import-Module -Name "$testdrive\Modules\Baz\Const_module.psd1" -Force (Get-Module -Name "Const_module").AccessMode = "Constant" } From 4535f35dc505570b2e0a5ee1fc8e5b6b4dc676c9 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 1 May 2019 12:37:53 -0700 Subject: [PATCH 082/103] Update to Pester 4.8.0 --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 46804bc0f45..4ce7d8e8a6e 100644 --- a/build.psm1 +++ b/build.psm1 @@ -566,7 +566,7 @@ function Restore-PSPester [ValidateNotNullOrEmpty()] [string] $Destination = ([IO.Path]::Combine((Split-Path (Get-PSOptions -DefaultToNew).Output), "Modules")) ) - Save-Module -Name Pester -Path $Destination -Repository PSGallery -RequiredVersion "4.4.4" + Save-Module -Name Pester -Path $Destination -Repository PSGallery -RequiredVersion "4.8.0" } function Compress-TestContent { From b108f935486e06f457bae72c2bac167715d7f6fd Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 1 May 2019 14:32:39 -0700 Subject: [PATCH 083/103] Revert "Merge pull request #9453 from rjmholt/fix-testdrive-paths" This reverts commit 21cf4fbf814c5fd331f4270caecef26690227d93, reversing changes made to c4031f1670f6e0a324712efe84b45293d91da8e8. --- .../Language/Scripting/Requires.Tests.ps1 | 6 +- .../CompatiblePSEditions.Module.Tests.ps1 | 26 +++-- .../Get-Module.Tests.ps1 | 95 +++++++++---------- .../ModuleManifest.Tests.ps1 | 35 +++---- 4 files changed, 73 insertions(+), 89 deletions(-) diff --git a/test/powershell/Language/Scripting/Requires.Tests.ps1 b/test/powershell/Language/Scripting/Requires.Tests.ps1 index 2288be03415..d86e683e26c 100644 --- a/test/powershell/Language/Scripting/Requires.Tests.ps1 +++ b/test/powershell/Language/Scripting/Requires.Tests.ps1 @@ -45,11 +45,11 @@ Describe "#requires -Modules" -Tags "CI" { $sep = [System.IO.Path]::DirectorySeparatorChar $altSep = [System.IO.Path]::AltDirectorySeparatorChar - $scriptPath = Join-Path (Resolve-FilePath $TestDrive) 'script.ps1' + $scriptPath = Join-Path $TestDrive 'script.ps1' $moduleName = 'Banana' $moduleVersion = '0.12.1' - $moduleDirPath = Join-Path (Resolve-FilePath $TestDrive) 'modules' + $moduleDirPath = Join-Path $TestDrive 'modules' New-Item -Path $moduleDirPath -ItemType Directory $modulePath = "$moduleDirPath${sep}$moduleName" New-Item -Path $modulePath -ItemType Directory @@ -62,7 +62,7 @@ Describe "#requires -Modules" -Tags "CI" { Context "Requiring non-existent modules" { BeforeAll { $badName = 'ModuleThatDoesNotExist' - $badPath = Join-Path (Resolve-FilePath $TestDrive) 'ModuleThatDoesNotExist' + $badPath = Join-Path $TestDrive 'ModuleThatDoesNotExist' $version = '1.0' $testCases = @( @{ ModuleRequirement = "'$badName'"; Scenario = 'name' } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index fd367364011..767679c82e2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -149,7 +149,7 @@ Describe "Get-Module with CompatiblePSEditions-checked paths" -Tag "CI" { @{ Editions = $null; ModuleName = "NeitherModule" } ) - $basePath = Join-Path (Resolve-FilePath $TestDrive) "EditionCompatibleModules" + $basePath = Join-Path $TestDrive "EditionCompatibleModules" New-TestModules -TestCases $successCases -BaseDir $basePath New-TestModules -TestCases $failCases -BaseDir $basePath @@ -242,7 +242,7 @@ Describe "Import-Module from CompatiblePSEditions-checked paths" -Tag "CI" { @{ Editions = $null; ModuleName = "NeitherModule"; Result = $true } ) - $basePath = Join-Path (Resolve-FilePath $TestDrive) "EditionCompatibleModules" + $basePath = Join-Path $TestDrive "EditionCompatibleModules" New-TestModules -TestCases $successCases -BaseDir $basePath New-TestModules -TestCases $failCases -BaseDir $basePath @@ -387,8 +387,6 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur $testCases = $list } - $resolvedTestDrive = Resolve-FilePath $TestDrive - # Define nested script module $scriptModuleName = "NestedScriptModule" $scriptModuleFile = "$scriptModuleName.psm1" @@ -398,7 +396,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur $binaryModuleName = "NestedBinaryModule" $binaryModuleFile = "$binaryModuleName.dll" $binaryModuleContent = 'public static class TestBinaryModuleClass { public static bool Test() { return true; } }' - $binaryModuleSourcePath = Join-Path $resolvedTestDrive $binaryModuleFile + $binaryModuleSourcePath = Join-Path $TestDrive $binaryModuleFile Add-Type -OutputAssembly $binaryModuleSourcePath -TypeDefinition $binaryModuleContent # Define root module definition @@ -409,8 +407,8 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Module directory structure: $TestDrive/$compatibility/$guid/$moduleName/{module parts} $compatibleDir = "Compatible" $incompatibleDir = "Incompatible" - $compatiblePath = Join-Path $resolvedTestDrive $compatibleDir - $incompatiblePath = Join-Path $resolvedTestDrive $incompatibleDir + $compatiblePath = Join-Path $TestDrive $compatibleDir + $incompatiblePath = Join-Path $TestDrive $incompatibleDir foreach ($basePath in $compatiblePath,$incompatiblePath) { @@ -431,7 +429,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Create the module directory $guid = New-Guid $compatibilityDir = $incompatibleDir - $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid + $containingDir = Join-Path $TestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -561,7 +559,7 @@ Describe "Get-Module nested module behaviour with Edition checking" -Tag "Featur # Create the module directory $guid = New-Guid $compatibilityDir = $compatibleDir - $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid + $containingDir = Join-Path $TestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -692,8 +690,6 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea $testCases = $list } - $resolvedTestDrive = Resolve-FilePath $TestDrive - # Define nested script module $scriptModuleName = "NestedScriptModule" $scriptModuleFile = "$scriptModuleName.psm1" @@ -707,8 +703,8 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Module directory structure: $TestDrive/$compatibility/$guid/$moduleName/{module parts} $compatibleDir = "Compatible" $incompatibleDir = "Incompatible" - $compatiblePath = Join-Path $resolvedTestDrive $compatibleDir - $incompatiblePath = Join-Path $resolvedTestDrive $incompatibleDir + $compatiblePath = Join-Path $TestDrive $compatibleDir + $incompatiblePath = Join-Path $TestDrive $incompatibleDir foreach ($basePath in $compatiblePath,$incompatiblePath) { @@ -729,7 +725,7 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Create the module directory $guid = New-Guid $compatibilityDir = $incompatibleDir - $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid + $containingDir = Join-Path $TestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory @@ -819,7 +815,7 @@ Describe "Import-Module nested module behaviour with Edition checking" -Tag "Fea # Create the module directory $guid = New-Guid $compatibilityDir = $compatibleDir - $containingDir = Join-Path $resolvedTestDrive $compatibilityDir $guid + $containingDir = Join-Path $TestDrive $compatibilityDir $guid $moduleName = "CpseTestModule" $moduleBase = Join-Path $containingDir $moduleName New-Item -Path $moduleBase -ItemType Directory diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 656ea902c27..1d7ec03eba0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -6,36 +6,34 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { BeforeAll { $originalPSModulePath = $env:PSModulePath - $resolvedTestDrive = Resolve-FilePath $TestDrive - - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\1.1" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Foo\2.0" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Bar\Download" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Zoo\Too" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\Az" -Force > $null - - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Foo\1.1\Foo.psd1" -ModuleVersion 1.1 - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Foo\2.0\Foo.psd1" -ModuleVersion 2.0 - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Bar\Bar.psd1" - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1" - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Az\Az.psd1" -ModuleVersion 1.1 - - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Foo\1.1\Foo.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Foo\2.0\Foo.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Bar\Bar.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Bar\Download\Download.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\Az\Az.psm1" > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\Foo\1.1" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\Foo\2.0" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\Bar\Download" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\Zoo\Too" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\Az" -Force > $null + + New-ModuleManifest -Path "$testdrive\Modules\Foo\1.1\Foo.psd1" -ModuleVersion 1.1 + New-ModuleManifest -Path "$testdrive\Modules\Foo\2.0\Foo.psd1" -ModuleVersion 2.0 + New-ModuleManifest -Path "$testdrive\Modules\Bar\Bar.psd1" + New-ModuleManifest -Path "$testdrive\Modules\Zoo\Zoo.psd1" + New-ModuleManifest -Path "$testdrive\Modules\Az\Az.psd1" -ModuleVersion 1.1 + + New-Item -ItemType File -Path "$testdrive\Modules\Foo\1.1\Foo.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Foo\2.0\Foo.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Bar\Bar.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Bar\Download\Download.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Zoo\Zoo.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Zoo\Too\Zoo.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\Az\Az.psm1" > $null $fullyQualifiedPathTestCases = @( - @{ ModPath = "$resolvedTestDrive/Modules\Foo"; Name = 'Foo'; Version = '2.0'; Count = 1 } - @{ ModPath = "$resolvedTestDrive\Modules/Foo\1.1/Foo.psd1"; Name = 'Foo'; Version = '1.1'; Count = 1 } - @{ ModPath = "$resolvedTestDrive\Modules/Bar.psd1"; Name = 'Bar'; Version = '0.0'; Count = 1 } - @{ ModPath = "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1"; Name = 'Zoo'; Version = '0.0'; Count = 1 } + @{ ModPath = "$TestDrive/Modules\Foo"; Name = 'Foo'; Version = '2.0'; Count = 1 } + @{ ModPath = "$TestDrive\Modules/Foo\1.1/Foo.psd1"; Name = 'Foo'; Version = '1.1'; Count = 1 } + @{ ModPath = "$TestDrive\Modules/Bar.psd1"; Name = 'Bar'; Version = '0.0'; Count = 1 } + @{ ModPath = "$TestDrive\Modules\Zoo\Too\Zoo.psm1"; Name = 'Zoo'; Version = '0.0'; Count = 1 } ) - $env:PSModulePath = Join-Path $resolvedTestDrive "Modules" + $env:PSModulePath = Join-Path $testdrive "Modules" } AfterAll { @@ -80,11 +78,11 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules[7].Version | Should -Be "2.0" $modules[8].ModuleType | Should -BeExactly "Script" $modules[9].ModuleType | Should -BeExactly "Script" - $modules[9].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[9].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path $modules[10].ModuleType | Should -BeExactly "Manifest" - $modules[10].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1").Path + $modules[10].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psd1").Path $modules[11].ModuleType | Should -BeExactly "Script" - $modules[11].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1").Path + $modules[11].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psm1").Path } It "Get-Module -ListAvailable -All" { @@ -93,14 +91,14 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules = $modules | Sort-Object -Property Name, Path $modules.Name -join "," | Should -BeExactly "Download,Zoo,Zoo,Zoo" - $modules[0].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Bar\Download\Download.psm1").Path - $modules[1].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path - $modules[2].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1").Path - $modules[3].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Zoo.psm1").Path + $modules[0].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Bar\Download\Download.psm1").Path + $modules[1].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[2].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psd1").Path + $modules[3].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Zoo.psm1").Path } It "Get-Module -ListAvailable" { - $modules = Get-Module "$resolvedTestDrive\Modules\*" -ListAvailable + $modules = Get-Module "$testdrive\Modules\*" -ListAvailable $modules.Count | Should -Be 5 $modules = $modules | Sort-Object -Property Name, Version $modules.Name -join "," | Should -BeExactly "Az,Bar,Foo,Foo,Zoo" @@ -109,11 +107,11 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } It "Get-Module -ListAvailable -All" { - $modules = Get-Module "$resolvedTestDrive\Modules\*" -ListAvailable -All + $modules = Get-Module "$testdrive\Modules\*" -ListAvailable -All $modules.Count | Should -Be 6 $modules = $modules | Sort-Object -Property Name, Path $modules.Name -join "," | Should -BeExactly "Az,Bar,Foo,Foo,Zoo,Zoo" - $modules[4].Path | Should -BeExactly (Resolve-Path "$resolvedTestDrive\Modules\Zoo\Too\Zoo.psm1").Path + $modules[4].Path | Should -BeExactly (Resolve-Path "$testdrive\Modules\Zoo\Too\Zoo.psm1").Path } It "Get-Module -FullyQualifiedName -ListAvailable" { @@ -130,7 +128,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { $modules.Name | Should -BeExactly "Zoo" $modules.ExportedFunctions.Count | Should -Be 0 -Because 'No exports were defined' - New-ModuleManifest -Path "$resolvedTestDrive\Modules\Zoo\Zoo.psd1" -FunctionsToExport 'Test-ZooFunction' + New-ModuleManifest -Path "$testdrive\Modules\Zoo\Zoo.psd1" -FunctionsToExport 'Test-ZooFunction' $modules = Get-Module -Name 'Zoo' -ListAvailable -Refresh $modules | Should -HaveCount 1 @@ -155,17 +153,17 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Context "PSEdition" { BeforeAll { - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\DesktopOnlyModule" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\CoreOnlyModule" -Force > $null - New-Item -ItemType Directory -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\DesktopOnlyModule" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\CoreOnlyModule" -Force > $null + New-Item -ItemType Directory -Path "$testdrive\Modules\CoreAndDesktopModule" -Force > $null - New-ModuleManifest -Path "$resolvedTestDrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psd1" -CompatiblePSEditions Desktop - New-ModuleManifest -Path "$resolvedTestDrive\Modules\CoreOnlyModule\CoreOnlyModule.psd1" -CompatiblePSEditions Core - New-ModuleManifest -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psd1" -CompatiblePSEditions Core, Desktop + New-ModuleManifest -Path "$testdrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psd1" -CompatiblePSEditions Desktop + New-ModuleManifest -Path "$testdrive\Modules\CoreOnlyModule\CoreOnlyModule.psd1" -CompatiblePSEditions Core + New-ModuleManifest -Path "$testdrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psd1" -CompatiblePSEditions Core, Desktop - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\CoreOnlyModule\CoreOnlyModule.psm1" > $null - New-Item -ItemType File -Path "$resolvedTestDrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\DesktopOnlyModule\DesktopOnlyModule.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\CoreOnlyModule\CoreOnlyModule.psm1" > $null + New-Item -ItemType File -Path "$testdrive\Modules\CoreAndDesktopModule\CoreAndDesktopModule.psm1" > $null } It "Get-Module -PSEdition -ListAvailable" -TestCases @( @@ -181,7 +179,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Context "Module analysis shouldn't load assembly" { BeforeAll { - $tempModulePath = Join-Path $resolvedTestDrive "TempModules" + $tempModulePath = Join-Path $TestDrive "TempModules" $testModuleDir = Join-Path $tempModulePath "MyModuelTest" $moduleManifest = Join-Path $testModuleDir "MyModuelTest.psd1" $assemblyPath = Join-Path $testModuleDir "MyModuelTestCommandAssembly.dll" @@ -230,8 +228,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Describe 'Get-Module -ListAvailable with path' -Tags "CI" { BeforeAll { $moduleName = 'Banana' - $resolvedTestDrive = Resolve-FilePath $TestDrive - $modulePath = Join-Path $resolvedTestDrive $moduleName + $modulePath = Join-Path $TestDrive $moduleName $v1 = '1.2.3' $v2 = '4.8.3' $v1DirPath = Join-Path $modulePath $v1 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 index d586b2d52c2..504984dfe32 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/ModuleManifest.Tests.ps1 @@ -57,13 +57,12 @@ function New-ModuleFromLayout Describe "Manifest required module autoloading from module path with simple names" -Tags "CI" { BeforeAll { $prevModulePath = $env:PSModulePath - $resolvedTestDrive = Resolve-FilePath $TestDrive - $env:PSModulePath = $resolvedTestDrive + [System.IO.Path]::PathSeparator + $env:PSModulePath + $env:PSModulePath = ($TestDrive -as [string]) + [System.IO.Path]::PathSeparator + $env:PSModulePath $mainModule = 'mainmod' $requiredModule = 'reqmod' - New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = $requiredModule @@ -77,7 +76,7 @@ Describe "Manifest required module autoloading from module path with simple name AfterAll { $env:PSModulePath = $prevModulePath - Remove-Module $mainModule,$requiredModule -ErrorAction SilentlyContinue + Get-Module $mainModule,$requiredModule | Remove-Module } It "Importing main module loads required modules successfully" { @@ -95,14 +94,12 @@ Describe "Manifest required module autoloading with relative path to dir" -Tags $mainModule = 'mainmod' $requiredModule = 'reqmod' - $resolvedTestDrive = Resolve-FilePath $TestDrive - - $mainModPath = Join-Path $resolvedTestDrive $mainModule + $mainModPath = Join-Path $TestDrive $mainModule # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar - New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = "..${altSep}$requiredModule" @@ -133,15 +130,13 @@ Describe "Manifest required module autoloading with relative path to manifest" - $mainModule = 'mainmod' $requiredModule = 'reqmod' - $resolvedTestDrive = Resolve-FilePath $TestDrive - - $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" + $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ RequiredModules = "..${altSep}$requiredModule${sep}$requiredModule.psd1" @@ -172,18 +167,16 @@ Describe "Manifest required module autoloading with absolute path to dir" -Tags $mainModule = 'mainmod' $requiredModule = 'reqmod' - $resolvedTestDrive = Resolve-FilePath $TestDrive - - $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" + $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ - RequiredModules = "$resolvedTestDrive${altSep}$requiredModule${sep}" + RequiredModules = "$TestDrive${altSep}$requiredModule${sep}" } } $requiredModule = @{ @@ -211,18 +204,16 @@ Describe "Manifest required module autoloading with absolute path to manifest" - $mainModule = 'mainmod' $requiredModule = 'reqmod' - $resolvedTestDrive = Resolve-FilePath $TestDrive - - $mainModPath = Join-Path $resolvedTestDrive $mainModule "$mainModule.psd1" + $mainModPath = Join-Path $TestDrive $mainModule "$mainModule.psd1" # Test to ensure that we treat backslashes as path separators on UNIX and vice-versa $altSep = [System.IO.Path]::AltDirectorySeparatorChar $sep = [System.IO.Path]::DirectorySeparatorChar - New-ModuleFromLayout -BaseDir $resolvedTestDrive -Layout @{ + New-ModuleFromLayout -BaseDir $TestDrive -Layout @{ $mainModule = @{ "$mainModule.psd1" = @{ - RequiredModules = "$resolvedTestDrive${altSep}$requiredModule${sep}$requiredModule.psd1" + RequiredModules = "$TestDrive${altSep}$requiredModule${sep}$requiredModule.psd1" } } $requiredModule = @{ From d45a28c8a2dd98443a07402a41c43f0525cbf8d4 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 1 May 2019 14:35:52 -0700 Subject: [PATCH 084/103] revert workaround for Resolve-FilePath and use Pester 4.8.0 --- .../Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 | 2 +- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 4 ++-- .../Microsoft.PowerShell.Core/Import-Module.Tests.ps1 | 6 +++--- .../Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 | 2 +- test/tools/Modules/HelpersCommon/HelpersCommon.psm1 | 5 ----- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 index 749615d76ee..2a34c3aad7e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 @@ -228,7 +228,7 @@ Describe "Get-Command Tests" -Tags "CI" { $results = Get-Command $fullPath $results.Name | Should -BeExactly $tempFile - $results.Definition | Should -BeExactly (Resolve-FilePath $fullPath) + $results.Definition | Should -BeExactly $fullPath } It "Two dynamic parameters are created properly" { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 1d7ec03eba0..8d851643785 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -248,10 +248,10 @@ Describe 'Get-Module -ListAvailable with path' -Tags "CI" { $modules | Should -HaveCount 2 $modules[0].Name | Should -BeExactly $moduleName - $modules[0].Path | Should -BeExactly (Resolve-FilePath $manifestV1Path) + $modules[0].Path | Should -BeExactly $manifestV1Path $modules[0].Version | Should -Be $v1 $modules[1].Name | Should -BeExactly $moduleName - $modules[1].Path | Should -BeExactly (Resolve-FilePath $manifestV2Path) + $modules[1].Path | Should -BeExactly $manifestV2Path $modules[1].Version | Should -Be $v2 } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 index 7969c734f7f..218e62098c7 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Import-Module.Tests.ps1 @@ -173,7 +173,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { $job | Remove-Job -ErrorAction Ignore } - $assemblyLocation | Should -BeExactly (Resolve-FilePath $TestModulePath) + $assemblyLocation | Should -BeExactly $TestModulePath $cmdletOutput | Should -BeExactly "BinaryModuleCmdlet1 exported by the ModuleCmdlets module." } @@ -218,7 +218,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { $module.ModuleType.ToString() | Should -Be 'Manifest' $module.ExportedCmdlets['Test-BinaryModuleCmdlet1'] | Should -Be 'Test-BinaryModuleCmdlet1' $module.NestedModules | Should -Not -BeNullOrEmpty - $location | Should -Be (Resolve-FilePath $exe) + $location | Should -Be $exe } It "PS should try to load the assembly from assembly name if file path doesn't exist" { @@ -258,7 +258,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' { # Use a different pwsh so that we do not have the PSScheduledJob module already loaded. $loadedAssemblyLocation = pwsh -noprofile -c "Import-Module $destPath -Force; [Microsoft.PowerShell.ScheduledJob.AddJobTriggerCommand].Assembly.Location" - $loadedAssemblyLocation | Should -BeLike "$(Resolve-FilePath $TestDrive)*\Microsoft.PowerShell.ScheduledJob.dll" + $loadedAssemblyLocation | Should -BeLike "$TestDrive*\Microsoft.PowerShell.ScheduledJob.dll" } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 index c2add8bc2fa..bf9837969a0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 @@ -14,7 +14,7 @@ Describe "Convert-Path tests" -Tag CI { } It "Convert-Path supports pipelined input by property name" { - Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly (Resolve-FilePath $TestDrive) + Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly $TestDrive } It "Convert-Path without arguments is an error" { diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index 1626fc8ee67..7a3b5e9089d 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -344,8 +344,3 @@ function Test-CanWriteToPsHome $script:CanWriteToPsHome } - -# This resolves a short path on Windows to the long path -function Resolve-FilePath($path) { - ([System.IO.FileInfo]::new($path)).FullName -} From 10e2028fae165aefc1b807fd9302aacf23abb305 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Wed, 1 May 2019 15:58:13 -0700 Subject: [PATCH 085/103] update Convert-Path tests so the comparison to $TestDrive is a string --- .../Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 index bf9837969a0..6205d70229a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Convert-Path.Tests.ps1 @@ -14,7 +14,7 @@ Describe "Convert-Path tests" -Tag CI { } It "Convert-Path supports pipelined input by property name" { - Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly $TestDrive + Get-Item -Path $TestDrive | Convert-Path | Should -BeExactly "$TestDrive" } It "Convert-Path without arguments is an error" { From b7fbcb59666aceece9a396f2a1c134e32aa5a3f1 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 6 May 2019 09:25:11 -0700 Subject: [PATCH 086/103] Move to .NET Core 3.0 preview 5 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index ba439e3c473..7ffac575022 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100-preview4-011223" + "version": "3.0.100-preview5-011568" } } From d0305cdea480c6986be0b997f2c42d792b213456 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 6 May 2019 11:04:24 -0700 Subject: [PATCH 087/103] update files.wxs --- assets/files.wxs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/files.wxs b/assets/files.wxs index 47f3776fd2b..0baff346096 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -2332,11 +2332,11 @@ - - + + - - + + @@ -3060,10 +3060,8 @@ - - @@ -3086,6 +3084,8 @@ + + From 7cde195d6e213e8bc7e532fa189bef51ffa0bfdc Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 7 May 2019 16:52:38 -0700 Subject: [PATCH 088/103] use PkgMgmt 1.3.2 which has fix for NetCore30 --- src/Modules/PSGalleryModules.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modules/PSGalleryModules.csproj b/src/Modules/PSGalleryModules.csproj index 470bdd6160e..372ab57519f 100644 --- a/src/Modules/PSGalleryModules.csproj +++ b/src/Modules/PSGalleryModules.csproj @@ -4,7 +4,7 @@ - + From ed731a75e3bbc26a9a761bd69d3ec23bdc0476a5 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 13 May 2019 17:32:35 -0700 Subject: [PATCH 089/103] update to PSGet2.1.3 which has fix for .NET Core 3.0 --- src/Modules/PSGalleryModules.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modules/PSGalleryModules.csproj b/src/Modules/PSGalleryModules.csproj index 372ab57519f..37fe8a9d45f 100644 --- a/src/Modules/PSGalleryModules.csproj +++ b/src/Modules/PSGalleryModules.csproj @@ -3,7 +3,7 @@ - + From 7b1ff74becaef517a4e9cca6ae9d86591270d477 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 13 May 2019 18:42:34 -0700 Subject: [PATCH 090/103] update test --- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 309972d60ff..0a81f0ac64c 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -831,7 +831,7 @@ Describe "Pwsh exe resources tests" -Tag CI { } else { $productVersion | Should -Match $PSVersionTable.GitCommitId } - $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell 7" + $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell" } It "Manifest contains compatibility section" -Skip:(!$IsWindows) { From 3c2032b6b15cb3b2ec9e895f16b41d75a9171931 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 13 May 2019 19:04:14 -0700 Subject: [PATCH 091/103] fix removing use of rcedit --- build.psm1 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/build.psm1 b/build.psm1 index 3059b62296b..0981887cd84 100644 --- a/build.psm1 +++ b/build.psm1 @@ -469,20 +469,6 @@ Fix steps: if (!$pwshPath.EndsWith("pwsh.exe")) { $pwshPath = Join-Path $Options.Output "pwsh.exe" } - - if (Test-IsPreview $ReleaseVersion) { - $iconPath = "$PSScriptRoot\assets\Powershell_av_colors.ico" - } else { - $iconPath = "$PSScriptRoot\assets\Powershell_black.ico" - } - - # fxdependent package does not have an executable to set iconPath etc. - if ($Options.Runtime -ne 'fxdependent') { - Start-NativeExecution { & $rcedit $pwshPath --set-icon $iconPath ` - --set-file-version $fileVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell 7" ` - --set-version-string "LegalCopyright" "(C) Microsoft Corporation. All Rights Reserved." ` - --application-manifest "$PSScriptRoot\assets\pwsh.manifest" } | Write-Verbose - } } # download modules from powershell gallery. From f263c6dc8c8dd2f8315b3b80a8a77fa8fa873338 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 13 May 2019 19:43:07 -0700 Subject: [PATCH 092/103] remove some remaining workarounds put for longpath resolution that has been fixed in Pester --- src/powershell-win-core/powershell-win-core.csproj | 3 --- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- test/powershell/Language/Parser/Conversions.Tests.ps1 | 3 +-- .../Microsoft.PowerShell.Management/Set-Location.Tests.ps1 | 3 +-- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 2 +- .../engine/ParameterBinding/ParameterBinding.Tests.ps1 | 2 +- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index c98bed5da53..c10cfb55586 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -15,9 +15,6 @@ ..\..\assets\pwsh.manifest - - - diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 0a81f0ac64c..1e967dfa50e 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -683,7 +683,7 @@ namespace StackTest { $out = pwsh -workingdirectory ~ -c '(Get-Location).Path' $out | Should -HaveCount 2 $out[0] | Should -BeExactly (Get-Item ~).FullName - $out[1] | Should -BeExactly ([System.IO.Path]::GetFullPath($testdrive)) + $out[1] | Should -BeExactly "$testdrive" } finally { if ($currentProfile) { diff --git a/test/powershell/Language/Parser/Conversions.Tests.ps1 b/test/powershell/Language/Parser/Conversions.Tests.ps1 index 6344dedfe15..efe016c7d8b 100644 --- a/test/powershell/Language/Parser/Conversions.Tests.ps1 +++ b/test/powershell/Language/Parser/Conversions.Tests.ps1 @@ -126,8 +126,7 @@ namespace TestTypeResolution { [TestTypeResolution.TestTypeFoo].Assembly.Location "@ $location = & $powershell -noprofile -command $command - # need to resolve short filename to long filename using FileInfo - $location | Should -Be ([System.IO.Path]::GetFullPath($cmdletDllPath)) + $location | Should -Be $cmdletDllPath } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 index 3613b8a5093..06be4473706 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 @@ -189,8 +189,7 @@ Describe "Set-Location" -Tags "CI" { param($path) Set-Location $TestDrive - # use FileInfo to get the long name if $TestDrive is using 8.3 path - $literalPath = [System.IO.FileInfo]::new((Join-Path $TestDrive $path)).FullName + $literalPath = Join-Path $TestDrive $path New-Item -ItemType Directory -Path $literalPath Set-Location -LiteralPath $path (Get-Location).Path | Should -BeExactly $literalPath diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index 677d7db6bf8..be5aaca1b1e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -3,7 +3,7 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { BeforeAll { $scriptFileName = "GetTryCatchCallStack.ps1" - $scriptFilePath = [System.IO.FileInfo]::new((Join-Path $TestDrive -ChildPath $scriptFileName)).FullName + $scriptFilePath = Join-Path $TestDrive -ChildPath $scriptFileName } It "Verifies that the script block of a catch clause does not show up on the call stack" { $fileStream = @" diff --git a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 index f0ed4d1c09c..a3a51831e41 100644 --- a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 @@ -272,7 +272,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { ) "[$Root]" '@ - $tempDir = [System.IO.FileInfo]::new((Join-Path -Path $TestDrive -ChildPath "DefaultValueTest")).FullName + $tempDir = Join-Path -Path $TestDrive -ChildPath "DefaultValueTest" $test1File = Join-Path -Path $tempDir -ChildPath "test1.ps1" $test2File = Join-Path -Path $tempDir -ChildPath "test2.ps1" From 033437b6cab913ef2f122b638c0dadf8cca5fcff Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 13 May 2019 20:42:00 -0700 Subject: [PATCH 093/103] cleanup, put back accidental remove of targets in csproj --- build.psm1 | 23 +------------------ .../powershell-win-core.csproj | 3 +++ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/build.psm1 b/build.psm1 index 0981887cd84..e545bdf9759 100644 --- a/build.psm1 +++ b/build.psm1 @@ -449,28 +449,6 @@ Fix steps: } } - if ($Environment.IsWindows) { - $ReleaseVersion = "" - if ($ReleaseTagToUse) { - $ReleaseVersion = $ReleaseTagToUse - } else { - $ReleaseVersion = (Get-PSCommitId -WarningAction SilentlyContinue) -replace '^v' - } - # in VSCode, depending on where you started it from, the git commit id may be empty so provide a default value - if (!$ReleaseVersion) { - $ReleaseVersion = "6.0.0" - $fileVersion = "6.0.0" - } else { - $fileVersion = $ReleaseVersion.Split("-")[0] - } - - # in VSCode, the build output folder doesn't include the name of the exe so we have to add it for rcedit - $pwshPath = $Options.Output - if (!$pwshPath.EndsWith("pwsh.exe")) { - $pwshPath = Join-Path $Options.Output "pwsh.exe" - } - } - # download modules from powershell gallery. # - PowerShellGet, PackageManagement, Microsoft.PowerShell.Archive if ($PSModuleRestore) { @@ -1828,6 +1806,7 @@ function Start-TypeGen '@ + New-Item -ItemType Directory -Path (Split-Path -Path $GetDependenciesTargetPath -Parent) -Force > $null Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK" diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index c10cfb55586..c98bed5da53 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -15,6 +15,9 @@ ..\..\assets\pwsh.manifest + + + From bfe6931d86310a5ee7488040af47bbaf18209f01 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 13 May 2019 21:07:22 -0700 Subject: [PATCH 094/103] [package] remove `Resolve-FilePath` exported function as it's no longer used --- test/tools/Modules/HelpersCommon/HelpersCommon.psd1 | 1 - 1 file changed, 1 deletion(-) diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 index 93a9b35ca38..c217dc6e72a 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 @@ -23,7 +23,6 @@ FunctionsToExport = @( 'Enable-Testhook' 'Get-RandomFileName' 'New-RandomHexString' - 'Resolve-FilePath' 'Send-VstsLogFile' 'Set-TesthookResult' 'Start-NativeExecution' From 3b5c3b2ee9bdb8455da69a6a176adba0d073a2ba Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 16:52:45 -0700 Subject: [PATCH 095/103] [package] address feedback enable quickjit for all projects --- build.psm1 | 4 ++++ src/ResGen/ResGen.csproj | 1 + src/TypeCatalogGen/TypeCatalogGen.csproj | 1 + src/powershell-unix/powershell-unix.csproj | 1 + src/powershell-win-core/powershell-win-core.csproj | 1 + .../Basic/Assembly.LoadWithPartialName.Tests.ps1 | 4 ++++ test/tools/TestExe/TestExe.csproj | 1 + test/tools/TestService/TestService.csproj | 1 + test/tools/WebListener/WebListener.csproj | 2 +- tools/packaging/packaging.psm1 | 12 ++++++------ 10 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build.psm1 b/build.psm1 index e545bdf9759..ec66f174015 100644 --- a/build.psm1 +++ b/build.psm1 @@ -612,6 +612,10 @@ function New-PSOptions { Write-Verbose "Using configuration '$Configuration'" if (-not $Framework) { + [xml]$projCommons = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "PowerSHell.Common.props") + $xmlns = [System.Xml.XmlNamespaceManager]::new($projCommons.NameTable) + $xmlns.AddNamespace("x","http://schemas.microsoft.com/developer/msbuild/2003") + $Framework = $projCommons.SelectSingleNode("//x:TargetFramework", $xmlns)."#text" $Framework = "netcoreapp3.0" Write-Verbose "Using framework '$Framework'" } diff --git a/src/ResGen/ResGen.csproj b/src/ResGen/ResGen.csproj index 95b09fe2ba7..fc0dcd7c6a0 100644 --- a/src/ResGen/ResGen.csproj +++ b/src/ResGen/ResGen.csproj @@ -6,6 +6,7 @@ resgen Exe true + true win7-x86;win7-x64;osx-x64;linux-x64 diff --git a/src/TypeCatalogGen/TypeCatalogGen.csproj b/src/TypeCatalogGen/TypeCatalogGen.csproj index 957375d5121..7b963b907c4 100644 --- a/src/TypeCatalogGen/TypeCatalogGen.csproj +++ b/src/TypeCatalogGen/TypeCatalogGen.csproj @@ -6,6 +6,7 @@ TypeCatalogGen Exe true + true win7-x86;win7-x64;osx-x64;linux-x64 diff --git a/src/powershell-unix/powershell-unix.csproj b/src/powershell-unix/powershell-unix.csproj index d2619f9990a..0da368c68bf 100644 --- a/src/powershell-unix/powershell-unix.csproj +++ b/src/powershell-unix/powershell-unix.csproj @@ -7,6 +7,7 @@ pwsh Exe true + true linux-x64;osx-x64; diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index c98bed5da53..d641205ba8e 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -8,6 +8,7 @@ pwsh Exe true + true true true win7-x86;win7-x64 diff --git a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 index cd0765ceddf..027a3f3d9e3 100644 --- a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 @@ -21,6 +21,10 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" { # All existing cases should fail on all platforms either because it doesn't exist or # because the assembly is blacklisted + + # This test is currently being skipped because there are no assemblies being blacklisted for .NET Core 3.0 + # keeping this test in case that changes in the future. + It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: " -Skip -TestCases $testcases { param( [Parameter(Mandatory)] diff --git a/test/tools/TestExe/TestExe.csproj b/test/tools/TestExe/TestExe.csproj index d1e58bb8534..a57ff9b8e9d 100644 --- a/test/tools/TestExe/TestExe.csproj +++ b/test/tools/TestExe/TestExe.csproj @@ -7,6 +7,7 @@ testexe Exe true + true win7-x86;win7-x64;osx-x64;linux-x64 diff --git a/test/tools/TestService/TestService.csproj b/test/tools/TestService/TestService.csproj index f414855d473..3da35830db7 100644 --- a/test/tools/TestService/TestService.csproj +++ b/test/tools/TestService/TestService.csproj @@ -7,6 +7,7 @@ TestService Exe true + true win7-x86;win7-x64 diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index b25eac44693..4836fa84b4d 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,7 +7,7 @@ - + diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index de528d25f3a..3cba50d5fdb 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -1437,7 +1437,7 @@ function CreateNugetPlatformFolder [string] $PlatformBinPath ) - $destPath = New-Item -ItemType Directory -Path (Join-Path $PackageRuntimesFolder "$Platform/lib/netcoreapp2.1") + $destPath = New-Item -ItemType Directory -Path (Join-Path $PackageRuntimesFolder "$Platform/lib/netcoreapp3.0") $fullPath = Join-Path $PlatformBinPath $file if (-not(Test-Path $fullPath)) { @@ -1535,7 +1535,7 @@ function New-ILNugetPackage $packageRuntimesFolder = New-Item (Join-Path $filePackageFolder.FullName 'runtimes') -ItemType Directory #region ref - $refFolder = New-Item (Join-Path $filePackageFolder.FullName 'ref/netcoreapp2.1') -ItemType Directory -Force + $refFolder = New-Item (Join-Path $filePackageFolder.FullName 'ref/netcoreapp3.0') -ItemType Directory -Force CopyReferenceAssemblies -assemblyName $fileBaseName -refBinPath $refBinPath -refNugetPath $refFolder -assemblyFileList $fileList #endregion ref @@ -1655,7 +1655,7 @@ function New-ILNugetPackage } <# - Copy the generated reference assemblies to the 'ref/netcoreapp2.1' folder properly. + Copy the generated reference assemblies to the 'ref/netcoreapp3.0' folder properly. This is a helper function used by 'New-ILNugetPackage' #> function CopyReferenceAssemblies @@ -1892,7 +1892,7 @@ function New-ReferenceAssembly Write-Log "Running: dotnet $arguments" Start-NativeExecution -sb {dotnet $arguments} - $refBinPath = Join-Path $projectFolder "bin/Release/netcoreapp2.1/$assemblyName.dll" + $refBinPath = Join-Path $projectFolder "bin/Release/netcoreapp3.0/$assemblyName.dll" if ($null -eq $refBinPath) { throw "Reference assembly was not built." } @@ -2746,7 +2746,7 @@ function New-MSIPackage # This example shows how to produce a Debug-x64 installer for development purposes. cd $RootPathOfPowerShellRepo Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1 - New-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' + New-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp3.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3' #> function New-MSIXPackage { @@ -3262,7 +3262,7 @@ function New-GlobalToolNupkg } $packageInfo | ForEach-Object { - $ridFolder = New-Item -Path (Join-Path $_.RootFolder "tools/netcoreapp2.1/any") -ItemType Directory + $ridFolder = New-Item -Path (Join-Path $_.RootFolder "tools/netcoreapp3.0/any") -ItemType Directory $packageType = $_.Type From dcd09861879a9c624e2a85bbacdc45a247749bec Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 16:58:42 -0700 Subject: [PATCH 096/103] [package] fix casing --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index ec66f174015..d265c00ac42 100644 --- a/build.psm1 +++ b/build.psm1 @@ -612,7 +612,7 @@ function New-PSOptions { Write-Verbose "Using configuration '$Configuration'" if (-not $Framework) { - [xml]$projCommons = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "PowerSHell.Common.props") + [xml]$projCommons = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "PowerShell.Common.props") $xmlns = [System.Xml.XmlNamespaceManager]::new($projCommons.NameTable) $xmlns.AddNamespace("x","http://schemas.microsoft.com/developer/msbuild/2003") $Framework = $projCommons.SelectSingleNode("//x:TargetFramework", $xmlns)."#text" From 75cedbfbd50bb0df9d968ba71d208d158b573649 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 17:11:49 -0700 Subject: [PATCH 097/103] [package] address Dongbo's feedback --- build.psm1 | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/build.psm1 b/build.psm1 index d265c00ac42..3f66cc3020a 100644 --- a/build.psm1 +++ b/build.psm1 @@ -413,7 +413,7 @@ Fix steps: # publish reference assemblies try { Push-Location "$PSScriptRoot/src/TypeCatalogGen" - $refAssemblies = Get-Content -Path $incFileName | ForEach-Object { $_.TrimEnd(';') } | Where-Object { $_ -ne "" } + $refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') } $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" if (Test-Path $refDestFolder -PathType Container) { @@ -573,7 +573,7 @@ function New-PSOptions { [string]$Configuration, [ValidateSet("netcoreapp3.0")] - [string]$Framework, + [string]$Framework = "netcoreapp3.0", # These are duplicated from Start-PSBuild # We do not use ValidateScript since we want tab completion @@ -609,16 +609,9 @@ function New-PSOptions { if (-not $Configuration) { $Configuration = 'Debug' } - Write-Verbose "Using configuration '$Configuration'" - if (-not $Framework) { - [xml]$projCommons = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "PowerShell.Common.props") - $xmlns = [System.Xml.XmlNamespaceManager]::new($projCommons.NameTable) - $xmlns.AddNamespace("x","http://schemas.microsoft.com/developer/msbuild/2003") - $Framework = $projCommons.SelectSingleNode("//x:TargetFramework", $xmlns)."#text" - $Framework = "netcoreapp3.0" - Write-Verbose "Using framework '$Framework'" - } + Write-Verbose "Using configuration '$Configuration'" + Write-Verbose "Using framework '$Framework'" if (-not $Runtime) { if ($Environment.IsLinux) { @@ -1804,7 +1797,7 @@ function Start-TypeGen - <_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.IsSystemReference)' == 'true' and '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> + <_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> From 270afe52a2b331b7bf29f5744993c58df5340083 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 17:32:10 -0700 Subject: [PATCH 098/103] [package] add type resolution tests --- .../engine/Basic/TypeResolution.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/powershell/engine/Basic/TypeResolution.Tests.ps1 diff --git a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 new file mode 100644 index 00000000000..3942d3b7469 --- /dev/null +++ b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 @@ -0,0 +1,13 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +Describe "Resolve types in additional referenced assemblies" { + It "Will resolve DirectoryServices type " -TestCases @( + @{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" } + @{ typename = "[Markdig.Markdown]"; name = "Markdown"} + ){ + param ($typename, $name) + $type = Invoke-Expression $typename + $type.Name | Should -BeExactly $name + } +} From 390d706a7675da2ec83bcd917201414514b163fc Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 17:58:52 -0700 Subject: [PATCH 099/103] [package] add tag to test --- test/powershell/engine/Basic/TypeResolution.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 index 3942d3b7469..1a957ab425b 100644 --- a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 +++ b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe "Resolve types in additional referenced assemblies" { +Describe "Resolve types in additional referenced assemblies" -Tag CI { It "Will resolve DirectoryServices type " -TestCases @( @{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" } @{ typename = "[Markdig.Markdown]"; name = "Markdown"} From 80ed5095c4d475d50a7f6fcfc6d00eb718add74f Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 May 2019 18:24:55 -0700 Subject: [PATCH 100/103] [package] remove use of invoke-expression --- test/powershell/engine/Basic/TypeResolution.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 index 1a957ab425b..0eba3094dbd 100644 --- a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 +++ b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 @@ -7,7 +7,7 @@ Describe "Resolve types in additional referenced assemblies" -Tag CI { @{ typename = "[Markdig.Markdown]"; name = "Markdown"} ){ param ($typename, $name) - $type = Invoke-Expression $typename + $type = & ([scriptblock]::Create($typename)) $type.Name | Should -BeExactly $name } } From 44e43b1f521b4b4e8106f7ee0f469fc4ad0f4104 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 17 May 2019 17:42:48 -0700 Subject: [PATCH 101/103] [package] address Dongbo's feedback --- .../CoreCLR/CorePsAssemblyLoadContext.cs | 4 ++- .../engine/Utils.cs | 8 +++--- .../powershell-win-core.csproj | 10 +++---- test/Test.Common.props | 2 +- .../FileSystem.Tests.ps1 | 27 +++++++++++++++++-- .../engine/Basic/TypeResolution.Tests.ps1 | 4 +-- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs index 051026236ff..d1687ff6ab1 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs @@ -109,7 +109,9 @@ private PowerShellAssemblyLoadContext(string basePaths) // - Value: strong name of the TPA that contains the type represented by Key. private readonly Dictionary _coreClrTypeCatalog; private readonly Lazy> _availableDotNetAssemblyNames; - private readonly HashSet _blackListedAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase){}; + private readonly HashSet _blackListedAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase){ + "System.Windows.Forms" + }; #if !UNIX private string _winDir; diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index b30c2ec5a14..bda39429fdc 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1176,12 +1176,14 @@ internal static bool IsAdministrator() internal static bool IsReservedDeviceName(string destinationPath) { #if !UNIX - string[] reservedDeviceNames = { "CLOCK$" }; + string[] reservedDeviceNames = { "CON", "PRN", "AUX", "CLOCK$", "NUL", + "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; string compareName = Path.GetFileName(destinationPath); string noExtensionCompareName = Path.GetFileNameWithoutExtension(destinationPath); - // If it's longer than 'CLOCK$', it can't be a device name. - if (compareName.Length > 6 && noExtensionCompareName.Length > 6) + if (((compareName.Length < 3) || (compareName.Length > 6)) && + ((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 6))) { return false; } diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index d641205ba8e..5a9bbb50499 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -1,6 +1,9 @@  + + + @@ -9,16 +12,13 @@ Exe true true - true - true + false + false win7-x86;win7-x64 Microsoft.PowerShell ..\..\assets\pwsh.manifest - - - diff --git a/test/Test.Common.props b/test/Test.Common.props index f9b2f9b6733..ea20813e328 100644 --- a/test/Test.Common.props +++ b/test/Test.Common.props @@ -5,7 +5,7 @@ (c) Microsoft Corporation. All rights reserved. netcoreapp3.0 - Preview + 8.0 true true diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 index 00dac0a84e2..01f866aaaa0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 @@ -23,8 +23,31 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" { $testContent = "Some Content" $testContent2 = "More Content" $reservedNamesTests = @( - # other formally reserved names work with .Net Core 3.0 - @{ deviceName = "CLOCK$" } + @{ deviceName = 'CON' } + @{ deviceName = 'PRN' } + @{ deviceName = 'AUX' } + @{ deviceName = 'CLOCK$' } + @{ deviceName = 'NUL' } + @{ deviceName = 'COM0' } + @{ deviceName = 'COM1' } + @{ deviceName = 'COM2' } + @{ deviceName = 'COM3' } + @{ deviceName = 'COM4' } + @{ deviceName = 'COM5' } + @{ deviceName = 'COM6' } + @{ deviceName = 'COM7' } + @{ deviceName = 'COM8' } + @{ deviceName = 'COM9' } + @{ deviceName = 'LPT0' } + @{ deviceName = 'LPT1' } + @{ deviceName = 'LPT2' } + @{ deviceName = 'LPT3' } + @{ deviceName = 'LPT4' } + @{ deviceName = 'LPT5' } + @{ deviceName = 'LPT6' } + @{ deviceName = 'LPT7' } + @{ deviceName = 'LPT8' } + @{ deviceName = 'LPT9' } ) } diff --git a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 index 0eba3094dbd..c192622868a 100644 --- a/test/powershell/engine/Basic/TypeResolution.Tests.ps1 +++ b/test/powershell/engine/Basic/TypeResolution.Tests.ps1 @@ -4,10 +4,8 @@ Describe "Resolve types in additional referenced assemblies" -Tag CI { It "Will resolve DirectoryServices type " -TestCases @( @{ typename = "[System.DirectoryServices.AccountManagement.AdvancedFilters]"; name = "AdvancedFilters" } - @{ typename = "[Markdig.Markdown]"; name = "Markdown"} ){ param ($typename, $name) - $type = & ([scriptblock]::Create($typename)) - $type.Name | Should -BeExactly $name + pwsh -noprofile -command "$typename.Name" | Should -BeExactly $name } } From 1f3f93c0df4372e8b07864100403ff255654c028 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 17 May 2019 19:15:00 -0700 Subject: [PATCH 102/103] [package] move props and targets to after propertygroup so it builds correctly --- src/powershell-win-core/powershell-win-core.csproj | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 5a9bbb50499..0b73c30fc0a 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -1,11 +1,6 @@  - - - - - - + PowerShell on Windows top-level project pwsh @@ -19,6 +14,12 @@ ..\..\assets\pwsh.manifest + + + + + + From 13f33472898bedef53080077fa03eab0aa335504 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 20 May 2019 13:18:44 -0700 Subject: [PATCH 103/103] [package] address Dongbo and Aditya's feedback --- src/powershell-native/Install-PowerShellRemoting.ps1 | 2 +- src/powershell-win-core/powershell-win-core.csproj | 2 -- .../engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/powershell-native/Install-PowerShellRemoting.ps1 b/src/powershell-native/Install-PowerShellRemoting.ps1 index c143127c008..19a80fdc8a1 100644 --- a/src/powershell-native/Install-PowerShellRemoting.ps1 +++ b/src/powershell-native/Install-PowerShellRemoting.ps1 @@ -67,7 +67,7 @@ function Register-WinRmPlugin SDKVersion="2" XmlRenderingType="text" Enabled="True" OutputBufferingMode="Block" ProcessIdleTimeoutSec="0" Architecture="{2}" UseSharedProcess="false" RunAsUser="" RunAsPassword="" AutoRestart="false"> - + diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 0b73c30fc0a..66f248ae69d 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -7,8 +7,6 @@ Exe true true - false - false win7-x86;win7-x64 Microsoft.PowerShell ..\..\assets\pwsh.manifest diff --git a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 index 027a3f3d9e3..8d618d21c6f 100644 --- a/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadWithPartialName.Tests.ps1 @@ -22,10 +22,10 @@ Describe "Assembly::LoadWithPartialName Validation Test" -Tags "CI" { # All existing cases should fail on all platforms either because it doesn't exist or # because the assembly is blacklisted - # This test is currently being skipped because there are no assemblies being blacklisted for .NET Core 3.0 - # keeping this test in case that changes in the future. + # This test is currently being skipped because System.Windows.Forms is part of .NET Core 3.0 so it gets + # load and thus no exception is thrown failing this test. - It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: " -Skip -TestCases $testcases { + It "Assembly::LoadWithPartialName should fail to load blacklisted assembly: " -Pending -TestCases $testcases { param( [Parameter(Mandatory)] [string]