-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 9 SDK WPF build broken with AssemblyName in Directory.Build.props #10068
Comments
I can reproduce the same issue as well. We use WORKAROUND Instead of overriding the AssemblyName in the csproj file, create a Directory.Build.props inside the WPF project and set the AssemblyName there. <Project>
<PropertyGroup>
<AssemblyName>my-wpf-app</AssemblyName>
</PropertyGroup>
</Project> |
For the WPF team: The task |
<IncludePackageReferencesDuringMarkupCompilation>false</IncludePackageReferencesDuringMarkupCompilation> Also fixes the problem. Which means that something in The only real difference I see is how AssemblyName is passed to |
Thank you so much! Just wanted to confirm that this workaround also works for me. I refined the solution a bit with an important of the ancestor
|
Unfortunately this workaround does not work for me. It breaks other things in the build process.
Results in
|
Yeah, I know. I just noted that, so the code owners have a starting point when trying to find out the root cause. |
@candritzky - I have been able to replicate the issue with .NET 8.0 as well. Upon investigation, I discovered that the problem stems from an incorrect resultant DLL name for the TemporaryTargetAssembly task. I confirmed that we are sending the correct assembly name for the temporaryTargetAssembly csproj, and found that the issue does not occur if we use Additionally, regarding the use of |
@Kuldeep-MS As described, the problem occurs for us only since the upgrade to Visual Studio 17.12 (which includes .NET 9 SDK). I could not see it with .NET 8 SDK. Of course, I can see it also when I target net8.0-windows, but use .NET 9 SDK to build. You might be right that this is a MSBuild issue. I cannot tell. What else do you need from me? Why did you tag this issue with "waiting-author-feedback"? |
Maybe to make the problem more clear, here are the temporary projects that are created (left: .NET 8, right: .NET 9): With #7557 only the first My opinion on that, it's just luck that this worked in .NET 8. I don't really see a use case in setting the The main problem seems to be again, that If there is really need to use
So when you change the |
@rainersigwald - I would like to draw your attention to this issue. To give you more context, when building a WPF application, if we define the GenerateTemporaryTarget is an intermediate step for XAML compilation in WPF where a temporary project is created. However, the output DLL is expected to retain the original AssemblyName rather than using the temporary project's name. Could you please have a look at this and share your insights on whether this issue lies with MSBuild, or if there is something that can be adjusted on the WPF side? |
@MichaeIDietrich Thanks for your suggestion for stripping off the nasty Regarding this:
Our use case is the following:
Does this make sense? Is there a better way to achieve the same result (without renaming all .csproj files to contain the |
@candritzky In fact, I think your use case is actually reasonable, so I am wrong about this. But as a simple workaround we could introduce another property to the The implementation could look something like this: <PropertyGroup>
<BetterMSBuildProjectName>$(_TargetAssemblyProjectName)</BetterMSBuildProjectName>
<BetterMSBuildProjectName Condition=" '$(BetterMSBuildProjectName)' == '' ">$(MSBuildProjectName)</BetterMSBuildProjectName>
</PropertyGroup> This would work for all project types not only WPF. As a mid term / long term change we could think about no longer creating a customized temporary .csproj file, but instead do this with the current .csproj file and inject the logic using MSBuild, in a similar fashion like inner builds work when a project has multiple |
Description
We have a pretty complex solution with a central
Directory.Build.props
file.This
Directory.Build.props
file contains - among other stuff - aRootNamespace
property that sets a default root namespace according to our conventions.Something similar to this:
The goal of this is that our
.csproj
files have short names without aMyCompanyName.MyProductName.
prefix, but the namespaces and generated assemblies should have this prefix.This worked since years up to .NET SDK 8.0.403. But it's broken since 2024-11-13 when Visual Studio 17.12 (which brings .NET SDK 9.0.100) was installed. It breaks WPF builds if the
Directory.Build.props
file sets aRootNamespace
and/or a customAssemblyName
MSBuild property. It works if the property is moved to the WPF project's.csproj
file. But it really needs to be moved, i.e. removed from the centralDirectory.Build.props
file.Something seems to be broken in the WPF XAML compile process.
As a workaround, I would have to comment out the
<AssemblyName>
property inDirectory.Build.props
, but this would break (or at least change) the output of all our other projects.Reproduction Steps
Please see that attached ZIP file for a minimal repro.
Uncomment the
<AssemblyName>
tag inDirectory.Build.props
and the (clean) build will fail.MyWpfApp.zip
Expected behavior
WPF apps should build without errors in .NET SDK 9 as they did in .NET SDK 8.
Actual behavior
Building with .NET SDK 9 is broken if there is a
Directory.Build.props
file with a custom<AssemblyName>
property.Regression?
Yes, it worked up to .NET SDK 8.0.403. Broken since 9.0.100.
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: