dotnet:: c# publish option // -r RID, net8, singlefile

 

 

dotnet new console
dotnet build --output ./build_output
dotnet ./build_output/my_app.dll

 

dotnet build -c Release
dotnet build -p:Version=1.2.3.4

 

# single file exe with all dependancies
dotnet publish -c Release -r win-x64 --self-contained true /p:publishsinglefile=true


# framework-dependent executable
dotnet publish -c Release
dotnet publish -c Release -r <RID> --self-contained false


# self-contained 
dotnet publish -c Release -r <RID> --self-contained true
dotnet publish -r win-x64 --self-contained
dotnet publish -r osx-x64 --self-contained
dotnet publish -r linux-x64


# framework-dependent deployment
dotnet publish -c Release -p:UseAppHost=false

 

 

 

-----------------------------------------------------------

-r <RID>

 

Type Command
framework-dependent executable for the current platform. dotnet publish
framework-dependent executable for a specific platform. dotnet publish -r <RID>
self-contained executable. dotnet publish -r <RID> --self-contained

 

#dotnet8
dotnet publish -c Release -r win-x64 --self-contained true /p:publishsinglefile=true

#dotnet6
dotnet publish -c Release -r win10-x64 --self-contained true /p:publishsinglefile=true

 

 

Windows RIDs

  • win-x64
  • win-x86
  • win-arm64

Linux RIDs

  • linux-x64 (Most desktop distributions like CentOS, Debian, Fedora, Ubuntu, and derivatives)
  • linux-musl-x64 (Lightweight distributions using musl like Alpine Linux)
  • linux-musl-arm64 (Used to build Docker images for 64-bit Arm v8 and minimalistic base images)
  • linux-arm (Linux distributions running on Arm like Raspbian on Raspberry Pi Model 2+)
  • linux-arm64 (Linux distributions running on 64-bit Arm like Ubuntu Server 64-bit on Raspberry Pi Model 3+)
  • linux-bionic-arm64 (Distributions using Android's bionic libc, for example, Termux)

 

 

https://learn.microsoft.com/en-us/dotnet/core/rid-catalog

 

.NET Runtime Identifier (RID) catalog - .NET

Learn about the runtime identifier (RID) and how RIDs are used in .NET.

learn.microsoft.com

 

 

 

 

 

 


-Single file deployment and exe

 

<PublishSingleFile>true</PublishSingleFile>
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>

</Project>

 

https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli

 

Create a single file for application deployment - .NET

Learn what single file application is and why you should consider using this application deployment model.

learn.microsoft.com

 

 

 

 

 

 

 

 

_

반응형