You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression for custom AssemblyName in WPF apps #5711
@benvillalobos It was 16.9.0, but .NET 5.0 SDK on my CI system was not up to date, so I guess that 16.11.0 is also ok. With msbuild 17.0.0 I am not able to build my WPF projects for net5-windows nor net6-windows :(
I can confirm that custom assembly names with macros were still working with 16.11.0, but stopped working with 17.0.0.
Custom assembly names without macros do work correctly with 17.0.0.
MSBuild Team Triage: We think this a WPF issue. It looks like the property AssemblyName is no longer being passed as a global property. See the picture below:
left side is a failed build (SDK 6.0.100), right side is a successful build (SDK 5.0.403)
This sounds very similar to an issue (#5576) I've been having with both VS 2019 and VS 2022, it was only affecting .net 5 on 2019 before but it's affecting .net 4x on 2022 now, and somehow having both installed as made the problem spread to 2019.
My setup is slightly different, I have a Directory.Build.props file which sets <AssemblyName>$(Product).$(MSBuildProjectName)</AssemblyName>
(this can be in the csproj too, makes no difference)
But I think the end result is the same, the 2-stage compilation process isn't using the same assembly name for both stages, so when it tries to resolve types it can't find them.
I urgently need a fix for this, because now my software won't compile without adding explicit AssemblyName overrides to all of my projects.
@las-nsc the root of the problem probably is the same. For this issue I've made minimal/simplified example. Originally I have *.props too. #5576 is for sure related, for my project I have some of mentioned errors too.
MSBuild Team Triage: We think this a WPF issue. It looks like the property AssemblyName is no longer being passed as a global property. See the picture below:
left side is a failed build (SDK 6.0.100), right side is a successful build (SDK 5.0.403)
@benvillalobos The image that you shared, helps in identifying the root cause.
As per the user, the issue can be observed, after upgrading the VS version.
Few questions:
Were there any changes in msbuild or prop file, defining or restricting the scope of properties or inheritance of those in child project?
Looked up the changes in Microsoft.WinFX.targets, There are no changes in the tasks or parameters.
@vishalmsft The issue is in src\Microsoft.DotNet.Wpf\src\PresentationBuildTasks\Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly.cs
There are 2 methods which handle generating the project in this step, and which one is determined by IncludePackageReferencesDuringMarkupCompilation. Both are similar, but some build properties are set via MSBuild params and some are set by writing them to the temporary project file. Either way it doesn't work properly, but using the workaround I mentioned before does fix the issue when IncludePackageReferencesDuringMarkupCompilation is false (the old mechanism).
Ultimately, the properties need to resolve to the same value for this temporary build as they do for the final build. In my example, that is because MSBuildProjectName is wrong because the Project name is derived from the file name, which has been changed by adding _random_wpftmp.
Reacted by Vishal Sharma and Maximilian Haru Raditya
It was suggested by someone in this thread that both issues have the same cause.
@HermanEldering - No it dosen't. The fix is intended to solve the problem originally reported in this issue i.e. AssemblyName cannot use $MSBuildProjectName.
This is not fixed in .NET 9.0. I'm using the shipped version of .NET 9.0, and this still happens. If anything sets "<AssemblyName>" I can't reference any of my classes in XAML files in the project.
This is very unfortunate, because I want the name of my executable to be short, useful, and memorable. But with WPF I just can't. If I try to change the name of the assembly, nothing loads.
Activity
jrboom commentedon Nov 9, 2021
I have the same issue since upgrading to VS2022.
[-]Regression for AssemblyName in WPF apps[/-][+]Regression for custom AssemblyName in WPF apps[/+]benvillalobos commentedon Nov 11, 2021
Team Triage: What msbuild version did this succeed on? We can't reproduce this with 16.11.0.
maciej-izak commentedon Nov 11, 2021
@benvillalobos It was 16.9.0, but .NET 5.0 SDK on my CI system was not up to date, so I guess that 16.11.0 is also ok. With msbuild 17.0.0 I am not able to build my WPF projects for
net5-windowsnornet6-windows:(jrboom commentedon Nov 15, 2021
I can confirm that custom assembly names with macros were still working with 16.11.0, but stopped working with 17.0.0.
Custom assembly names without macros do work correctly with 17.0.0.
benvillalobos commentedon Nov 18, 2021
MSBuild Team Triage: We think this a WPF issue. It looks like the property
AssemblyNameis no longer being passed as a global property. See the picture below:left side is a failed build (SDK 6.0.100), right side is a successful build (SDK 5.0.403)

las-nsc commentedon Nov 25, 2021
This sounds very similar to an issue (#5576) I've been having with both VS 2019 and VS 2022, it was only affecting .net 5 on 2019 before but it's affecting .net 4x on 2022 now, and somehow having both installed as made the problem spread to 2019.
My setup is slightly different, I have a Directory.Build.props file which sets
<AssemblyName>$(Product).$(MSBuildProjectName)</AssemblyName>(this can be in the csproj too, makes no difference)
But I think the end result is the same, the 2-stage compilation process isn't using the same assembly name for both stages, so when it tries to resolve types it can't find them.
I urgently need a fix for this, because now my software won't compile without adding explicit
AssemblyNameoverrides to all of my projects.maciej-izak commentedon Nov 25, 2021
@las-nsc the root of the problem probably is the same. For this issue I've made minimal/simplified example. Originally I have *.props too. #5576 is for sure related, for my project I have some of mentioned errors too.
las-nsc commentedon Nov 25, 2021
I had to revert back to 16.9.x to get it to compile again, 16.10.x, 16.11.x and 17.x all have the issue.
las-nsc commentedon Nov 25, 2021
I believe I have found a workaround, which might reveal the answer to whomever fixes this.
By adding:
It corrects the assembly name from being the Temporary one generated by the WPF compilation.
Note: this only works when
IncludePackageReferencesDuringMarkupCompilationis false.loicmorvan commentedon Dec 6, 2021
FYI Little repository to reproduce the issue: https://github.com/loicmorvan-ansys/XamlBugReproduction
vishalmsft commentedon Dec 7, 2021
@benvillalobos The image that you shared, helps in identifying the root cause.
As per the user, the issue can be observed, after upgrading the VS version.
Few questions:
las-nsc commentedon Dec 7, 2021
@vishalmsft The issue is in
src\Microsoft.DotNet.Wpf\src\PresentationBuildTasks\Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly.csThere are 2 methods which handle generating the project in this step, and which one is determined by
IncludePackageReferencesDuringMarkupCompilation. Both are similar, but some build properties are set via MSBuild params and some are set by writing them to the temporary project file. Either way it doesn't work properly, but using the workaround I mentioned before does fix the issue whenIncludePackageReferencesDuringMarkupCompilationisfalse(the old mechanism).Ultimately, the properties need to resolve to the same value for this temporary build as they do for the final build. In my example, that is because
MSBuildProjectNameis wrong because the Project name is derived from the file name, which has been changed by adding_random_wpftmp.anslmorvan commentedon Dec 10, 2021
Do you have sort of a planning for the publication of a fix?
12 remaining items
Kuldeep-MS commentedon Nov 24, 2023
Just to clarify - the fix for this has been merged for .NET9. Hence it will be available starting .NET9 Preview1.
HermanEldering commentedon Nov 24, 2023
@Kuldeep-MS does this also fix #2930?
It was suggested by someone in this thread that both issues have the same cause.
Kuldeep-MS commentedon Feb 21, 2024
@HermanEldering - No it dosen't. The fix is intended to solve the problem originally reported in this issue i.e.
AssemblyNamecannot use$MSBuildProjectName.ChadNedzlek commentedon Jan 26, 2025
This is not fixed in .NET 9.0. I'm using the shipped version of .NET 9.0, and this still happens. If anything sets "<AssemblyName>" I can't reference any of my classes in XAML files in the project.
ChadNedzlek commentedon Jan 26, 2025
This is very unfortunate, because I want the name of my executable to be short, useful, and memorable. But with WPF I just can't. If I try to change the name of the assembly, nothing loads.