PowerShell / PowerShell/PowerShell

PowerShell 7.4.6 fails to build with compiler mismatch error

Open
#24,641 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs-Triage
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the v7.4.6 build in the Ubuntu 24.04 Docker environment using the commands in the issue. Start with src/System.Management.Automation/System.Management.Automation.csproj and the PSVersionInfoGenerator under src/System.Management.Automation/SourceGenerators, then trace the compiler versions used by the build; done means dotnet publish completes without CS9057.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.