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

Viewed 1167

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.

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.

or

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

Related