CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Disable NAOT native exports for non-publish builds

Open Sergio0694 opened this issue 1 year ago • 7 comments

Fixes #1546

This PR disables the NAOT native exports and restores the bundled native host for non-publish builds.

Sergio0694 avatar Mar 21 '24 04:03 Sergio0694

This looks good to me in the sense that I don't think there's any other way to do what you need. _IsPublishing is obviously an internal implementation detail of the SDK, but the SDK doesn't provide any other way to do this so...

Cc @baronfel @nagilson

MichalStrehovsky avatar Apr 29 '24 11:04 MichalStrehovsky

Yes, keep in mind this will not work for ms build t publish, only when running dotnet publish on CLI (and eventually VS publish, but not at the moment.)

nagilson avatar Apr 29 '24 16:04 nagilson

Mmh when it "doesn't work", does that mean that _IsPublishing would just not be set to anything? Because I'm wondering if that's the case, perhaps would it be better for us to check for '$(_IsPublishing)' != 'false'" rather than '$(_IsPublishing)' == 'true'"? The rationale being that with the former, dotnet publish would work the same, but msbuild -t:publish would then also work (as the property would just not be set to anything). Basically it'd be the same as today, except we'd get the small improvement that dotnet build would correctly no longer generate those exports (as _IsPublish would presumably be false then?). Thinking that might be better than just outright breaking consumers using msbuild to publish, since that's relatively common. Does that make sense? 🤔

Sergio0694 avatar Apr 29 '24 16:04 Sergio0694

I don't think you'll ever see _IsPublishing == false.

dotnet publish sets the property to true. Publish in VS currently doesn't. They're working on making it set it. dotnet build /t:Publish would not have it either and will still do a publish (with some extra hurdles, but it will do a publish too).

MichalStrehovsky avatar Apr 29 '24 21:04 MichalStrehovsky

I don't think you'll ever see _IsPublishing == false.

dotnet publish sets the property to true. Publish in VS currently doesn't. They're working on making it set it. dotnet build /t:Publish would not have it either and will still do a publish (with some extra hurdles, but it will do a publish too).

It's a good thought, but @MichalStrehovsky is right, currently thats pretty much never false.

nagilson avatar Apr 29 '24 21:04 nagilson

I see. Thank you both for the additional info! I'll revert this to draft. Seems like we just can't do it for now 😅

Sergio0694 avatar Apr 29 '24 22:04 Sergio0694

Thank you for checking in with us! I think its a good idea. If youre ok with it not being the same in msbuild t publish, then I dont see why we wouldnt merge this once vs has the behavior, which id expect sooner rather than later.

@agocke is tracking that.

nagilson avatar Apr 29 '24 22:04 nagilson