When I run the command:
dotnet build -c Release
I get the program and necessary dlls of my project, however for the program to work on another computer I have to install computer to computer the .NET Core Runtime:
Would it be possible to create a standalone program for Windows?
To create a self-contained executable, you should use dotnet publish. For example:
dotnet publish -r win-x64 -c release
If you are using .NET Core 3, you can also trim a lot of these libraries out by adding the PublishTrimmed property to your csproj file, for example:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
</Project>
Provided your app doesn't call any of the framework libraries using reflection (i.e. the dotnet command is unable to figure out you need one of the libraries it trims out), your output will be much smaller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With