Skip to content

Don't change the namespace of an existing windowsSettings element when adding supportedArchitectures - #15712

Draft
OvesN wants to merge 1 commit into
dotnet:mainfrom
OvesN:fix-15543-windowssettings-namespace
Draft

OvesN wants to merge 1 commit into
dotnet:mainfrom
OvesN:fix-15543-windowssettings-namespace

Conversation

@OvesN

@OvesN OvesN commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Related issue(s):
Fixes #15543

Context

With PreferNativeArm64=true, AddToWin32Manifest added xmlns="http://schemas.microsoft.com/SMI/2024/WindowsSettings" to an existing windowsSettings element that had no xmlns attribute. When that element is unprefixed and inherits urn:schemas-microsoft-com:asm.v3 from <application> (the shape used by the VS app.manifest template), this moved windowsSettings into the wrong namespace. Windows then ignored both the new supportedArchitectures and existing settings such as dpiAwareness.

Changes Made

  • Stop adding xmlns to windowsSettings. supportedArchitectures is already created in the 2024 namespace, so the writer declares it on that element.
  • Update testManifestNoPrefixes.manifest to the shape from the issue (unprefixed windowsSettings without its own xmlns). Previously it already had the 2024 xmlns, so it did not cover this case.
  • Update expected outputs for newly created and prefixed asmv3:windowsSettings: xmlns now appears on supportedArchitectures instead of windowsSettings. The namespace of each element is unchanged.

Compatibility

For newly created or prefixed windowsSettings, the generated manifest is semantically identical; only where the 2024 namespace is declared changes. For an unprefixed windowsSettings that inherits asm.v3, the output is now valid.

Testing

  • .\build.cmd -v quiet — succeeded.
  • dotnet test src\Tasks.UnitTests\Microsoft.Build.Tasks.UnitTests.csproj --no-build --filter-class Microsoft.Build.Tasks.UnitTests.AddToWin32Manifest_Tests — passed, 26/26 (net11.0 and net481, including the Windows E2E tests that read the embedded manifest).
  • Manual: built a net48 project with PreferNativeArm64=true and the manifest from the issue using the bootstrapped MSBuild; the generated manifest matches the issue's expected output.

…AddToWin32Manifest

Adding xmlns to an unprefixed windowsSettings element moved it out of the
asm.v3 namespace, invalidating it and its existing settings. The 2024
namespace is now declared only on supportedArchitectures.

Fixes dotnet#15543

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2e2dfea7-0c44-4356-9857-85a4d3bb3626
Copilot AI balanced review requested due to automatic review settings November 28, 2026 06:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the change preserving existing windowsSettings namespaces.

No open issues 🎉

What changed in this PR

Fixes #15543 by preserving the namespace of existing windowsSettings elements when MSBuild adds supportedArchitectures for PreferNativeArm64=true.

Changes:

  • Removes the default namespace assignment that invalidated unprefixed windowsSettings.
  • Updates the regression fixture to cover namespace inheritance from application.
  • Updates expected outputs so the 2024 namespace is declared on supportedArchitectures.
File Description
src/​Tasks/​AddToWin32Manifest.cs Preserves the existing windowsSettings namespace.
src/​Tasks.UnitTests/​TestResources/​Manifests/​testManifestNoPrefixes.manifest_expected Expects inherited namespace preservation and a child-local namespace declaration.
src/​Tasks.UnitTests/​TestResources/​Manifests/​testManifestNoPrefixes.manifest Reproduces the unprefixed manifest shape from the issue.
src/​Tasks.UnitTests/​TestResources/​Manifests/​default.win32manifest_expected Updates namespace placement for newly created settings.
src/​Tasks.UnitTests/​TestResources/​Manifests/​buildIn.manifest_expected Updates namespace placement for prefixed settings.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

PreferNativeArm64 on .NET Framework breaks an existing unprefixed windowsSettings element in the application manifest

2 participants