Skip to content

Add Architecture="*" to Runtime="NET" UsingTask declarations to fix MSB4216 on x86 MSBuild - #16790

Merged
ViktorHofer merged 3 commits into
mainfrom
copilot/fix-msb4216-architecture-attribute
May 12, 2026
Merged

ViktorHofer merged 3 commits into
mainfrom
copilot/fix-msb4216-architecture-attribute

Conversation

Copilot AI commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

<UsingTask Runtime="NET"> without an Architecture attribute defaults to the host MSBuild's architecture. Under x86 Full Framework MSBuild (e.g. VS 18 Insiders' default MSBuild.exe), MSBuild then looks for an x86 MSBuild.exe in the .NET SDK, which doesn't exist (SDK ships x64/arm64 only), producing MSB4216.

Setting Architecture="*" lets MSBuild pick any available task host architecture.

  • Added Architecture="*" to all 129 <UsingTask> entries with Runtime="NET" across 31 .props/.targets files under src/ (including all files called out in the issue, plus other Arcade SDKs that share the same pattern: Microsoft.DotNet.Build.Tasks.Packaging, Microsoft.DotNet.Build.Tasks.Feed, Microsoft.DotNet.Build.Tasks.TargetFramework, Microsoft.DotNet.GenFacades, Microsoft.DotNet.GenAPI, Microsoft.DotNet.XliffTasks, Microsoft.DotNet.CMake.Sdk, Microsoft.DotNet.Baselines.Tasks, Microsoft.DotNet.SwaggerGenerator.MSBuild, and a few .targets under Microsoft.DotNet.Arcade.Sdk and Microsoft.DotNet.Build.Tasks.Installers).
  • Added a TODO comment above the first Runtime="NET" <UsingTask> in each of the 31 modified files referencing MSB4216 when x86 Full Framework MSBuild hosts Arcade SDK tasks with Runtime=NET msbuild#13739, so the Architecture="*" attribute can be removed once a fixed msbuild is consumed.
  • Comment lines mentioning Runtime="NET" were left untouched.

Example of the change:

+ <!-- TODO: Remove Architecture="*" on Runtime="NET" UsingTask declarations below when https://github.com/dotnet/msbuild/issues/13739 is fixed and a new msbuild is consumed with the fix. -->
- <UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.InstallDotNetCore" AssemblyFile="$(ArcadeSdkBuildTasksAssembly)" Runtime="NET" />
+ <UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.InstallDotNetCore" AssemblyFile="$(ArcadeSdkBuildTasksAssembly)" Runtime="NET" Architecture="*" />

To double check:

Copilot AI changed the title [WIP] Fix MSB4216 by adding Architecture attribute to UsingTask Add Architecture="*" to Runtime="NET" UsingTask declarations to fix MSB4216 on x86 MSBuild May 12, 2026
Copilot AI requested a review from ViktorHofer May 12, 2026 09:59
@ViktorHofer

Copy link
Copy Markdown
Member

@copilot add TODO markers to remove the Architecture attribute when dotnet/msbuild#13739 is fixed and a new msbuild is consumed with the fix.

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add TODO markers to remove the Architecture attribute when dotnet/msbuild#13739 is fixed and a new msbuild is consumed with the fix.

Added a TODO comment referencing dotnet/msbuild#13739 above the first Runtime="NET" UsingTask in each of the 31 modified files in 5800fc9.

@ViktorHofer
ViktorHofer marked this pull request as ready for review May 12, 2026 10:17
@ViktorHofer
ViktorHofer enabled auto-merge (squash) May 12, 2026 10:17
ViktorHofer added a commit to dotnet/sdk that referenced this pull request May 12, 2026
…#13739

Mirrors the marker requested on dotnet/arcade#16790 so the workaround can be
removed once MSBuild fixes its host-architecture default for Runtime="NET".

Co-authored-by: Copilot <[email protected]>
@ViktorHofer
ViktorHofer merged commit 117d9d5 into main May 12, 2026
12 of 13 checks passed
@ViktorHofer
ViktorHofer deleted the copilot/fix-msb4216-architecture-attribute branch May 12, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSB4216 when x86 Full Framework MSBuild hosts Arcade SDK tasks with Runtime=NET

3 participants