Is there any option to disable 'default executables' feature? dotent build and dotnet publish produces an executable that matches the platform of the SDK. But I build projects on Windows and run on Linux, thus such executables are useless and quite large.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Thanks for your question, @marian-margeta. You'll find the information that you need to target Linux only in the .NET Core application deployment article.
But I don't want to target Linux only. I want to keep it cross-platform but publish it without additional executable. In this documentation, there is a following paragraph:
During
dotnet buildordotnet publish, an executable is created that matches the environment and platform of the SDK you're using. You can expect the same things with these executables as you would other native executables,
I'd like to keep previous behavior, especially for dotnet publish. Because now - in dotnet core 3.0, two executables are generated - dll that is cross platform and have to be run using dotnet utility. And the second one that can be executed without that utility. But the second executable is useless for me. For example if I run it inside a docker container. It just increases a size of an image.
So, is there any way how to suppress this new behavior?
Just ran into that myself too. Took a bit of sleuthing to figure it out. Add the following property to your .csproj and it should do the trick:
<ComputeNETCoreBuildOutputFiles>false</ComputeNETCoreBuildOutputFiles>
Note that the above property should be enclosed within some <PropertyGroup>. HTH.
@usysware Thank you for that info! We're looking at redoing the deployment article set and I'll add this information to that bug.
Sure. A caveat I've discovered is that VS wouldn't debug/run .NET Core 3.x projects with that setting turned off. It complains about missing executable, which is understandable. So I ended up setting it with Condition tied to Debug configuration only, implying that I didn't care about Debug builds and just wanted for the framework dependent default executables not to be generated for Release builds.