Disable NAOT native exports for non-publish builds
Fixes #1546
This PR disables the NAOT native exports and restores the bundled native host for non-publish builds.
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
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.)
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? 🤔
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).
I don't think you'll ever see
_IsPublishing == false.
dotnet publishsets the property to true. Publish in VS currently doesn't. They're working on making it set it.dotnet build /t:Publishwould 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.
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 😅
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.