maxp
maxp

Reputation: 25161

Superfluous 'runtimes' folder created in output directory for .NET 5 project

I've just migrated a (WPF) .NET 4.6 project to .NET 5.

I've noticed it is now creating a folder called 'runtimes' in the output directory with lots of platform-dependent dlls.

Since this app will only run on Windows machines, is there anyway of preventing these folders being created during a build in Visual Studio?

Upvotes: 21

Views: 11980

Answers (2)

user128440
user128440

Reputation: 386

That's pretty easy to change: In your csproj file, inside the PropertyGroup, set the SelfContained property to "false" and specify a RuntimeIdentifier; like this:

<PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
    <SelfContained>false</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

Upvotes: 26

Yennefer
Yennefer

Reputation: 6234

The runtime folder contains all the necessary files to run your application regardless your target platform. You can specify to publish a single file, but this is the way the new framework works.

This new way of producing the build artifact may seem counter intuitive. You may have a look at 'runtimes' Folder after Publishing a .Net Core App to Azure Publish Via VS Online

Upvotes: 1

Related Questions