Skip to content

PowerShell 7.4.6 fails to build with compiler mismatch error #24641

@mbrancato

Description

@mbrancato

Prerequisites

Steps to reproduce

Start a fresh docker Ubuntu container. Note: I reproduced this on multiple distribution types, not simply Ubuntu.

docker run -it ubuntu:24.04

Run the following steps to build:

cd
apt-get update && apt-get install -y dotnet-sdk-8.0 build-essential git

git clone https://github.com/powershell/powershell --single-branch --branch v7.4.6

rm -f global.json
rm -f nuget.config

dotnet restore src/powershell-unix /p NuGetAudit=false
dotnet restore src/ResGen
dotnet restore src/TypeCatalogGen

cat <<'EOF' > src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets
<Project>
    <Target Name="_GetDependencies"
            DependsOnTargets="ResolveAssemblyReferencesDesignTime">
        <ItemGroup>
            <_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B"  Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
        </ItemGroup>
        <WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
    </Target>
</Project>
EOF


dotnet msbuild src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj \
 /t:_GetDependencies \
 "/property:DesignTimeBuild=true;_DependencyFile=$PWD/src/TypeCatalogGen/powershell.inc" \
 /nologo

pushd src/ResGen
dotnet run
popd

pushd src/TypeCatalogGen
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs powershell.inc
popd

dotnet publish src/powershell-unix/ \
    --output bin \
    --no-self-contained \
    --runtime "$(dotnet --info | awk '$1=="RID:"{print $2}')" \
    -p:PublishReadyToRun=true /v:n \
    /consoleLoggerParameters:ShowTimestamp \
    -p:NuGetAudit=false

Expected behavior

The dotnet publish should complete successfully.

This is related to #24548, but this is not about the links to the private repository in nuget.config.

Actual behavior

The build fails with the following as the final error:

00:07:18.953     7>CSC : error CS9057: The analyzer assembly '/root/powershell/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/bin/Release/netstandard2.0/SMA.Generator.dll' references version '4.9.0.0' of the compiler, which is newer than the currently running version '4.8.0.0'. [/root/powershell/src/System.Management.Automation/System.Management.Automation.csproj]
                     CompilerServer: server - server processed compilation - 61cf027b-8fdf-4f6f-8688-30a6bf5f67ad
00:07:18.956     7>Done Building Project "/root/powershell/src/System.Management.Automation/System.Management.Automation.csproj" (default targets) -- FAILED.
00:07:18.961     4>Done Building Project "/root/powershell/src/Microsoft.PowerShell.ConsoleHost/Microsoft.PowerShell.ConsoleHost.csproj" (default targets) -- FAILED.
00:07:18.964     6>Done Building Project "/root/powershell/src/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.csproj" (default targets) -- FAILED.
00:07:18.966     5>Done Building Project "/root/powershell/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj" (default targets) -- FAILED.
00:07:18.967     3>Done Building Project "/root/powershell/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj" (default targets) -- FAILED.
00:07:18.970     2>Done Building Project "/root/powershell/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj" (default targets) -- FAILED.
00:07:18.971     1>Done Building Project "/root/powershell/src/powershell-unix/powershell-unix.csproj" (Publish target(s)) -- FAILED.

Build FAILED.

                   "/root/powershell/src/powershell-unix/powershell-unix.csproj" (Publish target) (1:7) ->
                   "/root/powershell/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj" (default target) (3:6) ->
                   "/root/powershell/src/System.Management.Automation/System.Management.Automation.csproj" (default target) (7:14) ->
                   (CoreCompile target) -> 
                     CSC : error CS9057: The analyzer assembly '/root/powershell/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/bin/Release/netstandard2.0/SMA.Generator.dll' references version '4.9.0.0' of the compiler, which is newer than the currently running version '4.8.0.0'. [/root/powershell/src/System.Management.Automation/System.Management.Automation.csproj]

    0 Warning(s)
    1 Error(s)

Error details

No response

Environment data

Ubuntu 24.04 LTS

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions