-
Notifications
You must be signed in to change notification settings - Fork 107
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
CsWinRTAotExportsEnabled
incorrectly assumes PublishAot == true
implies a publish is actually occurring
#1546
Comments
I propose the result of 'Build' is always both JIT and NAOT compatible, no matter if PublishAot is true. In other words, the result of Build, including what code CsWinRT generates, must not depend on PublishAot, _IsPublishing, etc. Any NAOT specific tweaks, such as omitting WinRT.Host.dll, should be achieved by modifying the behavior of the Publish target instead, to omit that DLL from the publish output folder only. Rationale is that in the .NET build/publish model, Publish is a step in addition to Build, producing outputs in a separate location, and does not affect the output of Build. |
We should probably update that condition to also be conditional on |
The issue if I recall with that property is it relies on dotnet publish and doesn't work with msbuild publish. |
There's a whole lot of discussion about this at dotnet/sdk#26324. The problem is that if you just force running the Publish target, you're not actually getting publish behaviors. The This leads to stuff like this https://github.com/MichalStrehovsky/rt-sz/blob/4c11e7fb4c40d294086ca541546278605eda01c7/src/winrt-component-full/winrt-component-full.csproj#L20-L21 (this is not a .NET 9 issue, the issue is that _IsPublishing is not set and Publish target is getting activated). Here you have an SDK owner saying it's okay to rely on _IsPublishing: #1547 (comment) |
Microsoft.Windows.CsWinRT.targets defines a property
CsWinRTAotExportsEnabled
:However,
PublishAot
being true does not indicate that a build was actually an NAOT build, instead it indicates that a publish build will produce NAOT’d assemblies. This results in build failures when expected artefacts don’t exist. For example, WinRT.Host.dll is outputted conditional onCsWinRTAotExportsEnabled
not being true.I'm not sure how often this idiom is used across the targets files, so I can't recommend a specific fix, but it's probably something like setting
CsWinRTAotExportsEnabled
to true in a target that runs only before the publish target and ensuring that the only placePublishAot
is checked is when that's set.The text was updated successfully, but these errors were encountered: