Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent .NET Core 3.0 from building an EXE file by default

With .NET Core 3.0, a little feature was added to the build process. According to Microsoft:

.NET Core now builds framework-dependent executables by default. This behavior is new for applications that use a globally installed version of .NET Core.

I have searched, but I cannot find a way to prevent this. Unfortunately, this executable causes me issues when pushing my application to Cloud Foundry because it now thinks it's a stand-alone EXE file when it should run it with dotnet cli using the DLL file built for my application.

Is there a way to prevent this default EXE from being built?

I can always add a final step to my build process to remove it, but it seems like there should be a way to prevent it in the first place.

like image 470
BrianM Avatar asked Oct 21 '19 17:10

BrianM


People also ask

What is a self contained exe?

Publishing your app as self-contained produces a platform-specific executable. The output publishing folder contains all components of the app, including the . NET libraries and target runtime. The app is isolated from other . NET apps and doesn't use a locally installed shared runtime.

What is self contained deployment .NET core?

Self-Contained deployment is a new deployment option that was added in . NET Core. In this mode, you compile platform specific code that is ready to run standalone in a specific target environment.


1 Answers

@PeterHuene and @vcsjones answered the question perfectly in their comments above:

The UseAppHost property can be set to false (e.g. /p:UseAppHost=false on the command line) and that will disable the creation of the executable.

  • Peter Huene Oct 21 '19 at 18:21 from comments

or

As an alternative to a command line change, you can also set <UseAppHost>false</UseAppHost> in the .csproj's <PropertyGroup> as well.

  • vcsjones Oct 21 '19 at 18:25 from comments
like image 158
BrianM Avatar answered Oct 21 '22 08:10

BrianM