liveBook · Manning

Dotnet publish

As explained in ASP.NET Core in Action, 3e

dotnet publish is a .NET CLI command that prepares an application and its dependencies for deployment to a target environment.

`dotnet publish` prepares an ASP.NET Core application for deployment. Unlike `dotnet run`, which uses files in the project directory, it builds the app and places its DLL, dependencies, and files such as `wwwroot` in a publish folder. Copy that folder to the target environment. section 27.1.1 section 27.5

dotnet publish --output publish --configuration Release

Run this command from the project directory. `--output` names the destination folder; `--configuration Release` produces optimized output for deployment. section 27.1.1

Run the published app

After publishing, open the output folder and run `dotnet ExampleApp.dll`. Do not use `dotnet run` there: that command expects a project. A published app does not need the .NET CLI to run, though a runtime-dependent deployment needs the appropriate .NET Runtime on the server. section 27.1.1 section 27.3.1 section 27.5

Publishing is one step in deployment; the destination still needs appropriate hosting setup:

  • For IIS, keep the generated `web.config` with the published files. If the project already contains one, publishing copies it instead. Let the CLI generate it unless customization is needed. section 27.2.2
  • For Linux, copy the output to the server, then configure how the app receives traffic and stays running. A reverse proxy and a separate process manager are common choices. section 27.3.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Shows a Release publish command and output, then distinguishes running the published DLL from running a project.
Examples
Uses a Release publish command, a published DLL run command, and IIS and Linux deployment paths.
What it assumes
Assumes an existing ASP.NET Core project and introduces the difference between running locally and publishing for deployment.
What you can do after
Operate/configure it to produce Release output, run the published DLL, and carry the output into server deployment.
How it connects
Connects publishing to `dotnet run`, the .NET Runtime, IIS, `web.config`, and Linux reverse proxies.

Also explained in

Compare how 2 books explain dotnet publish →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.