Skip to content
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

Open
Jeremy-Price opened this issue Mar 20, 2024 · 1 comment · May be fixed by #1547
Labels
bug Something isn't working

Comments

@Jeremy-Price
Copy link
Contributor

Microsoft.Windows.CsWinRT.targets defines a property CsWinRTAotExportsEnabled:

   <!--
      If the AOT optimizer is enabled, and we're publishing with NativeAOT, automatically set CsWinRTAotExportsEnabled as well.
      Only do this if the property is not already set by the user, so we respect any existing preference.
    -->
    <CsWinRTAotExportsEnabled Condition="'$(CsWinRTAotExportsEnabled)' == '' and '$(CsWinRTAotOptimizerEnabled)' == 'true' and '$(PublishAot)' == 'true'">true</CsWinRTAotExportsEnabled>
    <CsWinRTAotExportsEnabled Condition="'$(CsWinRTAotExportsEnabled)' != 'true'">false</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 on CsWinRTAotExportsEnabled 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 place PublishAot is checked is when that's set.

@Jeremy-Price Jeremy-Price added the bug Something isn't working label Mar 20, 2024
@Jeremy-Price
Copy link
Contributor Author

@manodasanW @Sergio0694

@Sergio0694 Sergio0694 linked a pull request Mar 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant