Skip to content

VMR main builds broken: GenerateSdkRuntimeIdentifierChain MSB4216 task host failure since SDK code flow #7064 #7112

Description

@lewing

Summary

All main branch VMR official builds (dnceng/internal, pipeline 1330) have been failing since June 5 with MSB4216 when the GenerateSdkRuntimeIdentifierChain task attempts to launch via TaskHostFactory. The failure is on every platform (Linux x64/arm64/arm, Windows x64/x86/arm64, macOS arm64).

Error

src/sdk/src/Layout/redist/targets/GenerateLayout.targets(26,5): error MSB4216:
Could not run the "GenerateSdkRuntimeIdentifierChain" task because MSBuild could not
create or connect to a task host with runtime "NET" and architecture "x64".
Please ensure that (1) the requested runtime and/or architecture are available on the
machine, and (2) that the required executable
"/__w/1/s/.dotnet/sdk/11.0.100-preview.5.26227.104/MSBuild" exists and can be run.

Bisection

  • Last passing build: 2992950 (commit 025cac314d7, June 5 ~11:00 UTC)
  • First failing build: 2993147 (commit d233c67796b, June 5 ~16:00 UTC)

The introducing commit range includes SDK code flow dotnet/dotnet#7064 (44865609a40) as the prime suspect.

Key findings

1. redist.csproj was not previously built in VMR

In the passing build (2992950), searching the Linux_x64 log (59,294 lines) for GenerateSdkRuntimeIdentifierChain, RuntimeIdentifierChain, TaskHostFactory, or redist -> returns zero matches. The redist.csproj build target was not being reached.

In the failing build, the log shows:

redist -> /__w/1/s/src/sdk/artifacts/bin/redist/Release/net11.0/redist.dll
error MSB4216: ...

Something in SDK code flow #7064 changed the build graph so that redist.csproj is now actively built in the VMR where it wasn't before.

2. dotnetup runs in VMR despite from_vmr guard

configure-toolset.sh was updated to call InstallBootstrapSdkWithDotnetup at the top level. It has a guard:

if [[ "$restore" != true || "$from_vmr" == true || -z "$dotnet_sdk_version" ]]; then
    return
fi

However, the VMR build log shows dotnetup is running:

Installing SDK(s) '11.0.100-preview.5.26227.104' to '/__w/1/s/src/sdk/.dotnet' via dotnetup...
Downloading https://aka.ms/dotnet/dotnetup/daily/dotnetup-linux-x64
dotnetup installed successfully to /__w/1/s/src/sdk/eng/dotnetup

The VMR does pass --fromVMR (repo-projects/Directory.Build.props:128), and build.sh parses it before sourcing configure-toolset.sh, so from_vmr should be true. Unclear why the guard isn't catching it.

3. Task host handshake or launch failure

The GenerateSdkRuntimeIdentifierChain task is declared with TaskFactory="TaskHostFactory" Runtime="NET" in sdk-tasks.InTree.targets. This forces MSBuild to spawn an out-of-process task host using the MSBuild apphost at {sdkPath}/MSBuild.

The code path in NodeProviderOutOfProcTaskHost.ResolveAppHostOrFallback():

  • MSBuild apphost exists at .dotnet/sdk/11.0.100-preview.5.26227.104/MSBuild → useAppHost=true
  • DOTNET_HOST_PATH is set (/__w/1/s/.dotnet/dotnet) → DOTNET_ROOT should be derived correctly
  • The apphost is launched but the parent/child handshake fails → MSB4216

This may be related to dotnet/msbuild#13879 (task host handshake architecture mismatch).

Impact

  • All main branch builds are broken — 0% clean pass rate since June 5
  • Code flow PRs to main (aspnetcore, runtime, roslyn, efcore) are blocked from validation
  • No new BAR assets are being published from main

Affected builds

Build Date Commit
2994109 June 7 7150f20
2993907 June 6 01a993d
2993793 June 6 af0627d
2993688 June 6 af0627d
2993396 June 5 ba0c241
2993249 June 5 3ab08f7
2993147 June 5 d233c67

Suggested investigation

  1. Why is redist.csproj now being built in the VMR when it wasn't before? Check if the SDK code flow changed the traversal/graph build entry points.
  2. Why is InstallBootstrapSdkWithDotnetup executing despite the from_vmr guard?
  3. Consider whether GenerateSdkRuntimeIdentifierChain needs TaskHostFactory at all, or if it can run in-process.

/cc @dotnet/dotnet-cli

Activity

  1. lewing commented on Jun 7, 2026

    @lewing
    MemberAuthor

    see also #7105 which is being caused by dotnetup installed sdk

  2. ViktorHofer commented on Jun 8, 2026

    @ViktorHofer
    Member

    Root cause for finding (2): dotnetup runs via the Setup Internal Feeds step, not the main build

    I traced where the Installing SDK(s) '…' to '…/src/sdk/.dotnet' via dotnetup… line actually comes from, using the Linux_x64_BuildLogs artifact + raw console log of the first failing build (2993147).

    Key timing observation

    In the Linux_x64 job:

    • 16:06:22 — dotnetup installs the bootstrap SDK into src/sdk/.dotnet
    • 17:26:36 — the only orchestration Building sdk banner runs, and this one does pass --fromVMR (so its src/sdk/sdk.log contains no dotnetup line — the guard works there)

    So the dotnetup install happens ~80 min earlier, in a different step. The console shows it directly under Setting up internal NuGet feeds for sdk, i.e. the "Setup Internal Feeds" task.

    The invocation chain

    1. eng/pipelines/templates/jobs/vmr-build.yml (Setup Internal Feeds, ~L568) loops over every src/<repo> and runs eng/common/SetupNugetSources.ps1.
    2. SetupNugetSources.ps1:35 → . $PSScriptRoot\tools.ps1 (dot-sources tools.ps1).
    3. tools.ps1 dot-sources configure-toolset.ps1, whose top level calls InstallBootstrapSdkWithDotnetup.
    4. In this bare PowerShell task, the guard inputs come from tools.ps1 defaults:
      • tools.ps1:20 → $restore defaults to $true
      • tools.ps1:66 → $fromVMR defaults to $false
    5. Guard: (-not $true) -or $false -or [empty] = false → it does not return → dotnetup runs, dropping src/sdk/eng/dotnetup/dotnetup + src/sdk/artifacts/.dotnetup/... and a populated src/sdk/.dotnet into the tree (these show up in binary-report/NewBinaries.txt).

    Conclusion

    The from_vmr condition logic itself is correct — but it's bypassed by the entry path. configure-toolset runs InstallBootstrapSdkWithDotnetup unconditionally whenever tools.ps1 is merely sourced. SetupNugetSources.ps1 sources tools.ps1 purely to set up feeds, in a context with no -fromVMR and a default $restore=$true, so the guard sees fromVMR=false, restore=true and fires. (This would trigger anywhere SetupNugetSources.ps1 runs — it's not VMR-build-specific.)

    Suggested fix: gate InstallBootstrapSdkWithDotnetup so it only runs from an actual build.ps1/build.sh restore, not from a bare tools.ps1 dot-source (e.g. via SetupNugetSources.ps1). The from_vmr/restore defaults make the current top-level call fire in non-build contexts.

  3. ViktorHofer commented on Jun 8, 2026

    @ViktorHofer
    Member

    Took me ~45min to find this but that's the actual regression

  4. ViktorHofer commented on Jun 8, 2026

    @ViktorHofer
    Member

    Fix proposed in dotnet/arcade#16984 — SetupNugetSources now sets disableConfigureToolsetImport before sourcing tools, so the "Setup Internal Feeds" step no longer triggers the SDK's InstallBootstrapSdkWithDotnetup (dotnetup) as a side effect. Once it flows to the VMR, the bootstrap SDK will stop being dropped into src/sdk/.dotnet.

  5. ViktorHofer commented on Jun 9, 2026

    @ViktorHofer
    Member

    The fix unfortunately didn't work. Reopening.

  6. ViktorHofer commented on Jun 9, 2026

    @ViktorHofer
    Member

    OK I missed bringing this to the VMR root as well: #7145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions