diff --git a/.vsts-ci/templates/windows-test.yml b/.vsts-ci/templates/windows-test.yml index b021e45f000..b316f8f360e 100644 --- a/.vsts-ci/templates/windows-test.yml +++ b/.vsts-ci/templates/windows-test.yml @@ -51,6 +51,8 @@ jobs: displayName: Bootstrap - pwsh: | + Import-Module .\build.psm1 -force + Start-PSBootstrap Import-Module .\tools\ci.psm1 Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' $options = (Get-PSOptions) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index cbfc342851b..45e1f2788c1 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -138,7 +138,6 @@ net6.0 9.0 true - false true true diff --git a/assets/wix/files.wxs b/assets/wix/files.wxs index e6dc09ea608..f205226a49d 100644 --- a/assets/wix/files.wxs +++ b/assets/wix/files.wxs @@ -1620,6 +1620,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -3033,8 +3054,8 @@ - - + + @@ -4013,7 +4034,14 @@ - + + + + + + + + diff --git a/build.psm1 b/build.psm1 index db3bdb5fae7..8cfd5299c94 100644 --- a/build.psm1 +++ b/build.psm1 @@ -124,7 +124,7 @@ function Get-EnvironmentInformation if ($environment.IsWindows) { $environment += @{'IsAdmin' = (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)} - $environment += @{'nugetPackagesRoot' = "${env:USERPROFILE}\.nuget\packages"} + $environment += @{'nugetPackagesRoot' = "${env:USERPROFILE}\.nuget\packages", "${env:NUGET_PACKAGES}"} } else { @@ -419,7 +419,9 @@ Fix steps: # setup arguments # adding ErrorOnDuplicatePublishOutputFiles=false due to .NET SDk issue: https://github.com/dotnet/sdk/issues/15748 - $Arguments = @("publish","--no-restore","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") + # removing --no-restore due to .NET SDK issue: https://github.com/dotnet/sdk/issues/18999 + # $Arguments = @("publish","--no-restore","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") + $Arguments = @("publish","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") if ($Output -or $SMAOnly) { $Arguments += "--output", (Split-Path $Options.Output) } @@ -2323,78 +2325,85 @@ function Start-CrossGen { function New-CrossGenAssembly { param ( - [Parameter(Mandatory= $true)] + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] - [String] + [String[]] $AssemblyPath, - [Parameter(Mandatory= $true)] + + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] - $CrossgenPath + $CrossgenPath, + + [Parameter(Mandatory = $true)] + [ValidateSet("alpine-x64", + "linux-arm", + "linux-arm64", + "linux-x64", + "osx-arm64", + "osx-x64", + "win-arm", + "win-arm64", + "win7-x64", + "win7-x86")] + [string] + $Runtime ) - $outputAssembly = $AssemblyPath.Replace(".dll", ".ni.dll") - $platformAssembliesPath = Split-Path $AssemblyPath -Parent - $crossgenFolder = Split-Path $CrossgenPath - $niAssemblyName = Split-Path $outputAssembly -Leaf + $platformAssembliesPath = Split-Path $AssemblyPath[0] -Parent - try { - Push-Location $crossgenFolder + $targetOS, $targetArch = $Runtime -split '-' - # Generate the ngen assembly - Write-Verbose "Generating assembly $niAssemblyName" - Start-NativeExecution { - & $CrossgenPath /ReadyToRun /MissingDependenciesOK /in $AssemblyPath /out $outputAssembly /Platform_Assemblies_Paths $platformAssembliesPath - } | Write-Verbose - } finally { - Pop-Location + # Special cases where OS / Arch does not conform with runtime names + switch ($Runtime) { + 'alpine-x64' { + $targetOS = 'linux' + $targetArch = 'x64' + } + 'win-arm' { + $targetOS = 'windows' + $targetArch = 'arm' + } + 'win-arm64' { + $targetOS = 'windows' + $targetArch = 'arm64' + } + 'win7-x64' { + $targetOS = 'windows' + $targetArch = 'x64' + } + 'win7-x86' { + $targetOS = 'windows' + $targetArch = 'x86' + } } - } - function New-CrossGenSymbol { - param ( - [Parameter(Mandatory= $true)] - [ValidateNotNullOrEmpty()] - [String] - $AssemblyPath, - [Parameter(Mandatory= $true)] - [ValidateNotNullOrEmpty()] - [String] - $CrossgenPath - ) + $generatePdb = $targetos -eq 'windows' + # The path to folder must end with directory separator + $dirSep = [System.IO.Path]::DirectorySeparatorChar + $platformAssembliesPath = if (-not $platformAssembliesPath.EndsWith($dirSep)) { $platformAssembliesPath + $dirSep } - $platformAssembliesPath = Split-Path $AssemblyPath -Parent - $crossgenFolder = Split-Path $CrossgenPath - - try { - Push-Location $crossgenFolder - - $symbolsPath = [System.IO.Path]::ChangeExtension($assemblyPath, ".pdb") - - $createSymbolOptionName = $null - if($Environment.IsWindows) - { - $createSymbolOptionName = '-CreatePDB' + Start-NativeExecution { + $crossgen2Params = @( + "-r" + $platformAssembliesPath + "--out-near-input" + "--single-file-compilation" + "-O" + "--targetos" + $targetOS + "--targetarch" + $targetArch + ) - } - elseif ($Environment.IsLinux) - { - $createSymbolOptionName = '-CreatePerfMap' + if ($generatePdb) { + $crossgen2Params += "--pdb" } - if($createSymbolOptionName) - { - Start-NativeExecution { - & $CrossgenPath -readytorun -platform_assemblies_paths $platformAssembliesPath $createSymbolOptionName $platformAssembliesPath $AssemblyPath - } | Write-Verbose - } + $crossgen2Params += $AssemblyPath - # Rename the corresponding ni.dll assembly to be the same as the IL assembly - $niSymbolsPath = [System.IO.Path]::ChangeExtension($symbolsPath, "ni.pdb") - Rename-Item $niSymbolsPath $symbolsPath -Force -ErrorAction Stop - } finally { - Pop-Location + & $CrossgenPath $crossgen2Params } } @@ -2403,24 +2412,13 @@ function Start-CrossGen { } # Get the path to crossgen - $crossGenExe = if ($environment.IsWindows) { "crossgen.exe" } else { "crossgen" } - $generateSymbols = $false + $crossGenExe = if ($environment.IsWindows) { "crossgen2.exe" } else { "crossgen2" } # The crossgen tool is only published for these particular runtimes $crossGenRuntime = if ($environment.IsWindows) { - if ($Runtime -match "-x86") { - "win-x86" - } elseif ($Runtime -match "-x64") { - "win-x64" - $generateSymbols = $true - } elseif (!($env:PROCESSOR_ARCHITECTURE -match "arm")) { - throw "crossgen for 'win-arm' and 'win-arm64' must be run on that platform" - } - } elseif ($Runtime -eq "linux-arm") { - throw "crossgen is not available for 'linux-arm'" - } elseif ($Runtime -eq "linux-x64") { - $Runtime - # We should set $generateSymbols = $true, but the code needs to be adjusted for different extension on Linux + # for windows the tool architecture is the host machine architecture, so it is always x64. + # we can cross compile for x86, arm and arm64 + "win-x64" } else { $Runtime } @@ -2440,31 +2438,9 @@ function Start-CrossGen { Select-Object -First 1 | ` ForEach-Object { $_.FullName } if (-not $crossGenPath) { - throw "Unable to find latest version of crossgen.exe. 'Please run Start-PSBuild -Clean' first, and then try again." - } - Write-Verbose "Matched CrossGen.exe: $crossGenPath" -Verbose - - # Crossgen.exe requires the following assemblies: - # mscorlib.dll - # System.Private.CoreLib.dll - # clrjit.dll on Windows or libclrjit.so/dylib on Linux/OS X - $crossGenRequiredAssemblies = @("mscorlib.dll", "System.Private.CoreLib.dll") - - $crossGenRequiredAssemblies += if ($environment.IsWindows) { - "clrjit.dll" - } elseif ($environment.IsLinux) { - "libclrjit.so" - } elseif ($environment.IsMacOS) { - "libclrjit.dylib" - } - - # Make sure that all dependencies required by crossgen are at the directory. - $crossGenFolder = Split-Path $crossGenPath - foreach ($assemblyName in $crossGenRequiredAssemblies) { - if (-not (Test-Path "$crossGenFolder\$assemblyName")) { - Copy-Item -Path "$PublishPath\$assemblyName" -Destination $crossGenFolder -Force -ErrorAction Stop - } + throw "Unable to find latest version of crossgen2.exe. 'Please run Start-PSBuild -Clean' first, and then try again." } + Write-Verbose "Matched CrossGen2.exe: $crossGenPath" -Verbose # Common assemblies used by Add-Type or assemblies with high JIT and no pdbs to crossgen $commonAssembliesForAddType = @( @@ -2495,11 +2471,13 @@ function Start-CrossGen { $fullAssemblyList = $commonAssembliesForAddType - foreach ($assemblyName in $fullAssemblyList) { - $assemblyPath = Join-Path $PublishPath $assemblyName - New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyPath + $assemblyFullPaths = @() + $assemblyFullPaths += foreach ($assemblyName in $fullAssemblyList) { + Join-Path $PublishPath $assemblyName } + New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyFullPaths -Runtime $Runtime + # # With the latest dotnet.exe, the default load context is only able to load TPAs, and TPA # only contains IL assembly names. In order to make the default load context able to load @@ -2523,12 +2501,6 @@ function Start-CrossGen { # Microsoft.CodeAnalysis.VisualBasic.dll, and Microsoft.CSharp.dll. if ($commonAssembliesForAddType -notcontains $assemblyName) { Remove-Item $symbolsPath -Force -ErrorAction Stop - - if($generateSymbols) - { - Write-Verbose "Generating Symbols for $assemblyPath" - New-CrossGenSymbol -CrossgenPath $crossGenPath -AssemblyPath $assemblyPath - } } } } diff --git a/global.json b/global.json index c36bb3376e9..26b49e6e30a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.100-preview.4.21255.9" + "version": "6.0.100-preview.6.21355.2" } } diff --git a/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj b/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj index d74f77126a7..1fb088cfdd7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj +++ b/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj @@ -47,7 +47,7 @@ - + diff --git a/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj b/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj index 86f7a8ded3a..823d99e5b84 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj +++ b/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj @@ -31,9 +31,9 @@ - - - + + + diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/Microsoft.PowerShell.CoreCLR.Eventing.csproj b/src/Microsoft.PowerShell.CoreCLR.Eventing/Microsoft.PowerShell.CoreCLR.Eventing.csproj index 3e20f19b03a..fc257238436 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/Microsoft.PowerShell.CoreCLR.Eventing.csproj +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/Microsoft.PowerShell.CoreCLR.Eventing.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj b/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj index 4f24cdcbbca..0907eaa3736 100644 --- a/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj +++ b/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj @@ -18,16 +18,16 @@ - - - + + + - - - - - - + + + + + + diff --git a/src/Microsoft.WSMan.Management/Microsoft.WSMan.Management.csproj b/src/Microsoft.WSMan.Management/Microsoft.WSMan.Management.csproj index 2bd11329423..d32fb47a456 100644 --- a/src/Microsoft.WSMan.Management/Microsoft.WSMan.Management.csproj +++ b/src/Microsoft.WSMan.Management/Microsoft.WSMan.Management.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/System.Management.Automation/System.Management.Automation.csproj b/src/System.Management.Automation/System.Management.Automation.csproj index b7b407b167c..f11ab82db0d 100644 --- a/src/System.Management.Automation/System.Management.Automation.csproj +++ b/src/System.Management.Automation/System.Management.Automation.csproj @@ -16,16 +16,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs index 462eee91e6d..35c956e2802 100644 --- a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs +++ b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs @@ -427,7 +427,7 @@ private void PossiblyGlobArg(string arg, CommandParameterInternal parameter, Str } else if (arg.StartsWith("~/", StringComparison.OrdinalIgnoreCase)) { - var replacementString = home + arg.Substring(1); + string replacementString = string.Concat(home, arg.AsSpan(1)); _arguments.Append(replacementString); AddToArgumentList(parameter, replacementString); argExpanded = true; diff --git a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs index 5be1cbf673a..2c154f79990 100644 --- a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs +++ b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs @@ -110,7 +110,7 @@ internal static string CreateProcessPipeName( // There is a limit of 104 characters in total including the temp path to the named pipe file // on non-Windows systems, so we'll convert the starttime to hex and just take the first 8 characters. #if UNIX - .Append(proc.StartTime.ToFileTime().ToString("X8").Substring(1, 8)) + .Append(proc.StartTime.ToFileTime().ToString("X8").AsSpan(1, 8)) #else .Append(proc.StartTime.ToFileTime().ToString(CultureInfo.InvariantCulture)) #endif diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index 34a298beff9..bb775d0ca2f 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -26,7 +26,6 @@ Describe "Validate start of console host" -Tag CI { 'System.Diagnostics.TraceSource.dll' 'System.Diagnostics.Tracing.dll' 'System.IO.FileSystem.AccessControl.dll' - 'System.IO.FileSystem.dll' 'System.IO.FileSystem.DriveInfo.dll' 'System.IO.Pipes.dll' 'System.Linq.dll' diff --git a/test/powershell/Language/Parser/Parser.Tests.ps1 b/test/powershell/Language/Parser/Parser.Tests.ps1 index b3163ba2f27..0f8a6c74726 100644 --- a/test/powershell/Language/Parser/Parser.Tests.ps1 +++ b/test/powershell/Language/Parser/Parser.Tests.ps1 @@ -864,7 +864,10 @@ foo``u{2195}abc @{ Script = "0x0"; ExpectedValue = "0"; ExpectedType = [int] } @{ Script = "0x12"; ExpectedValue = "18"; ExpectedType = [int] } @{ Script = "-0x12"; ExpectedValue = "-18"; ExpectedType = [int] } - @{ Script = "0x80000000"; ExpectedValue = $([int32]::MinValue); ExpectedType = [int] } + + # Disabling this because https://github.com/dotnet/runtime/issues/54251 + # @{ Script = "0x80000000"; ExpectedValue = $([int32]::MinValue); ExpectedType = [int] } + @{ Script = "0x7fffffff"; ExpectedValue = $([int32]::MaxValue); ExpectedType = [int] } @{ Script = "0x100000000"; ExpectedValue = [int64]0x100000000; ExpectedType = [long] } @{ Script = "0xFF"; ExpectedValue = "255"; ExpectedType = [int] } @@ -1047,7 +1050,10 @@ foo``u{2195}abc @{ Script = "0xFFu"; ExpectedValue = "255"; ExpectedType = [uint] } @{ Script = "0xFFFFu"; ExpectedValue = "65535"; ExpectedType = [uint] } @{ Script = "0xFFFFFFu"; ExpectedValue = "16777215"; ExpectedType = [uint] } - @{ Script = "0xFFFFFFFFu"; ExpectedValue = "$([uint]::MaxValue)"; ExpectedType = [uint] } + + # Disabling this because https://github.com/dotnet/runtime/issues/54251 + # @{ Script = "0xFFFFFFFFu"; ExpectedValue = "$([uint]::MaxValue)"; ExpectedType = [uint] } + @{ Script = "0xFFFFFFFFFFu"; ExpectedValue = "1099511627775"; ExpectedType = [ulong] } @{ Script = "0xFFFFFFFFFFFFu"; ExpectedValue = "281474976710655"; ExpectedType = [ulong] } @{ Script = "0xFFFFFFFFFFFFFFu"; ExpectedValue = "72057594037927935"; ExpectedType = [ulong] } @@ -1057,7 +1063,10 @@ foo``u{2195}abc @{ Script = "0b10u"; ExpectedValue = "2"; ExpectedType = [uint] } @{ Script = "0b11111111u"; ExpectedValue = "255"; ExpectedType = [uint] } @{ Script = "0b1111111111111111u"; ExpectedValue = "65535"; ExpectedType = [uint] } - @{ Script = "0b11111111111111111111111111111111u"; ExpectedValue = "4294967295"; ExpectedType = [uint] } + + # Disabling this because https://github.com/dotnet/runtime/issues/54251 + # @{ Script = "0b11111111111111111111111111111111u"; ExpectedValue = "4294967295"; ExpectedType = [uint] } + @{ Script = "0b1111111111111111111111111111111111111111111111111111111111111111u"; ExpectedValue = "18446744073709551615"; ExpectedType = [ulong] } #Multipliers @{ Script = "1ukb"; ExpectedValue = "1024"; ExpectedType = [uint] } 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 10f39bca320..fc5cf7a69d4 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -261,7 +261,8 @@ Describe "Test-Connection" -tags "CI" { Context "MTUSizeDetect" { # We skip the MtuSize detection tests when in containers, as the environments throw raw exceptions # instead of returning a PacketTooBig response cleanly. - It "MTUSizeDetect works" -Pending:($env:__INCONTAINER -eq 1) { + # Test disabled due to .NET runtime issue: https://github.com/dotnet/runtime/issues/55961 + It "MTUSizeDetect works" -Pending:(($env:__INCONTAINER -eq 1) -or $IsMacOS) { $result = Test-Connection $testAddress -MtuSize $result | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingMtuStatus @@ -270,7 +271,8 @@ Describe "Test-Connection" -tags "CI" { $result.MtuSize | Should -BeGreaterThan 0 } - It "Quiet works" -Pending:($env:__INCONTAINER -eq 1) { + # Test disabled due to .NET runtime issue: https://github.com/dotnet/runtime/issues/55961 + It "Quiet works" -Pending:(($env:__INCONTAINER -eq 1) -or $IsMacOS) { $result = Test-Connection $gatewayAddress -MtuSize -Quiet $result | Should -BeOfType Int32 diff --git a/test/tools/WebListener/WebListener.csproj b/test/tools/WebListener/WebListener.csproj index 02cf0993928..4217232a67d 100644 --- a/test/tools/WebListener/WebListener.csproj +++ b/test/tools/WebListener/WebListener.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/tools/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj b/tools/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj index b9ffef2c91b..189fab2c02e 100644 --- a/tools/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj +++ b/tools/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj b/tools/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj index 2228c06a4cc..406fea6d78b 100644 --- a/tools/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj +++ b/tools/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj @@ -9,7 +9,7 @@ - - + +