The dotnet
compiler produces two copies of the same executable and my google skills are not good enough to figure out why.
E.g. in a simple Console project:
dotnet publish --configuration Release
produces bin/Release/net8.0/FizzBuzz and bin/Release/net8.0/publish/FizzBuzz, which are identical.
I want to build a most optimized and a cross-platform executable. How do I do that?
I know that there are different build targets (OS specific, dotnet SDK specific etc) but I’m confused by the many options.
If you link to https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish, please provide a description of the cons of the options, since I don’t get them.
My FizzBuzz.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>FizzBuzz</AssemblyName>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- I added ErrorOnDuplicatePublishOutputFiles -->
<ErrorOnDuplicatePublishOutputFiles>true</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
</Project>
I added <ErrorOnDuplicatePublishOutputFiles>
to see if that would change anything. It did not.
dotnet --version
8.0.301
uname -a
Linux kali 6.8.11-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.8.11-1kali2 (2024-05-30) x86_64 GNU/Linux