Fix: reordered import in temporary project to ensure correct property… #11151
+4
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… override
Fixes #11150
Description
Properties explicitly set in the temporary project file are incorrectly override by Directory.Build.props.
This pull request addresses an issue where properties explicitly defined in temporary project files were unintentionally overridden by values from Directory.Build.props.
This fix will cause the import element for SDK.props to be written to the temporary project file before PropertyGroup elements.
Customer Impact
The build cannot be completed successfully.
Known workarounds are incompatible with the code generator.
This fix improves reliability in build environments that rely on temporary project files, such as automated tooling or SDK-generated projects.
Regression
This may be a regression that occurred in .NET 9, according to #10068.
Testing
I placed the built PresentationBuildTasks.dll in C:\Program Files\dotnet\sdk\9.0.304\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472 and confirmed that I can build WPF project from Visual Studio and msbuid.exe .
Sample repository
Risk
Build behavior breaks only if the old code author intended to pass a properties (IntermediateOutputPath, BaseIntermediateOutputPath, MSBuildProjectExtensionsPath, and _TargetAssemblyProjectName) to the Sdk.props.
Microsoft Reviewers: Open in CodeFlow