-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Closed
Copy link
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
This is a regression between build 8.0.100-preview.5.23267.7 and 8.0.100-preview.5.23269.4. It was discovered when attempting to update the .NET Docker images to the latest build of Preview 5. You can see the CI results with this error here: dotnet/dotnet-docker#4628
This affects Windows only.
Build this Dockerfile:
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS installer
RUN powershell -Command " `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
`
# Retrieve .NET SDK
$sdk_version = '8.0.100-preview.5.23269.4'; `
Invoke-WebRequest -OutFile dotnet.zip https://dotnetbuilds.azureedge.net/public/Sdk/$sdk_version/dotnet-sdk-$sdk_version-win-x64.zip; `
mkdir $Env:ProgramFiles\dotnet; `
tar -oxzf dotnet.zip -C $Env:ProgramFiles\dotnet; `
Remove-Item -Force dotnet.zip;"
RUN powershell -Command " `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
`
# Install PowerShell global tool
$powershell_version = '7.4.0-preview.3'; `
Invoke-WebRequest -OutFile PowerShell.Windows.x64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Windows.x64.$powershell_version.nupkg; `
& $Env:ProgramFiles\dotnet\dotnet tool install --add-source . --tool-path $Env:ProgramFiles\powershell --version $powershell_version PowerShell.Windows.x64; `
& $Env:ProgramFiles\dotnet\dotnet nuget locals all --clear; `
Remove-Item -Force PowerShell.Windows.x64.$powershell_version.nupkg; `
Remove-Item -Path $Env:ProgramFiles\powershell\.store\powershell.windows.x64\$powershell_version\powershell.windows.x64\$powershell_version\powershell.windows.x64.$powershell_version.nupkg -Force;"
RUN setx /M PATH "%PATH%;C:\Program Files\powershell;C:\Program Files\dotnet"
RUN pwsh --versionExpected behavior
It should be able to run `pwsh` without failure.Actual behavior
Process terminated. The type initializer for 'System.Management.Automation.PSVersionInfo' threw an exception.
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSVersionInfo' threw an exception.
---> System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSObject' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.Management.Automation.PSObject..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.PSObject.get_Properties()
at System.Management.Automation.SemanticVersion.op_Implicit(SemanticVersion semver)
at System.Management.Automation.PSVersionInfo..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.PSVersionInfo.get_PSVersion()
at System.Management.Automation.PSSnapInReader.ReadRegistryInfo(Version& assemblyVersion, String& publicKeyToken, String& culture, String& applicationBase, Version& psVersion)
at System.Management.Automation.PSSnapInReader.ReadCoreEngineSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)The command 'cmd /S /C pwsh --version' returned a non-zero code: 2148734499
### Error details
_No response_
### Environment data
```powershell
Can't run it because pwsh fails to run.
Visuals
No response
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.