Wednesday, 1 January 2025

Types of publish dotnet core

Publish the app as a framework-dependent deployment

 dotnet publish -c Release -o publish-fd

In the preceding command:

  • -c Release specifies that the app should be built in release mode. This optimizes the app for performance.
  • -o specifies the name of the output directory. In this case, the output directory will be named publish-fd.

This command publishes the app as a framework-dependent deployment to the publish-fd directory.


Publish for self-contained deployment

Self-contained deployments include the app and its dependencies, as well as the .NET runtime. Since the .NET runtime is included with the app, the target machine doesn't need to have the .NET runtime installed in order to run the app. This makes self-contained deployments larger than framework-dependent deployments. Self-contained apps must also handle deploying .NET runtime updates to receive the latest patches.

publish the app as a self-contained deployment for 64-bit Windows:

.NET CLI
dotnet publish -c Release -r win-x64 -o publish-scd-win64 --self-contained

In the previous command:

  • -c Release specifies that the app should be built in release mode. This optimizes the app for performance.
  • -r win-x64 specifies that the app should be published for 64-bit Windows. win-x64 is the runtime identifier (RID) for 64-bit Windows, so the app is published as a self-contained deployment for 64-bit Windows.
  • -o publish-scd-win64 specifies the output directory for the published app.
  • --self-contained specifies that the app should be published as a self-contained deployment.

publish the app as a self-contained deployment for 64-bit Linux:

.NET CLI
dotnet publish -c Release -r linux-x64 -o publish-scd-linux64 --self-contained

This time, the -r linux-x64 option specifies that the app should be published for 64-bit Linux.


No comments:

Post a Comment