liveBook · Manning

Application publishing

As explained in Building Web APIs with ASP.NET Core

The process of preparing application output and files for deployment to a target environment.

Application publishing prepares application artifacts for a target environment and may deploy them automatically. In Visual Studio, a publish profile stores the release and deployment settings for a selected target. section 12.4.1

Choose a publishing approach according to the hosting environment and deployment requirements:

  • Use an integrated publish-and-deploy target when the server supports the required deployment module, package, or service. section 12.4.1
  • Use a folder target to create local artifacts, then deploy them separately through another technique. section 12.4.1
  • For Windows hosting with Web Deploy installed, select a compatible Visual Studio target; Linux hosting typically uses a local folder or FTP server. section 12.4.1

Verify a published web API

After publishing, confirm the Publish Succeeded message and open the deployed site. A root-level HTTP 400 error can be normal when production disables Swagger UI. Test working GET endpoints such as /error/test and /cod/test instead. If /cod/test displays a blank page, inspect the browser developer console: a Content Security Policy may have blocked its inline script. A narrowly scoped nonce can permit that specific script without broadly enabling inline execution. section 12.4.4

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src ' self' ". Either the ‘unsafe-inline’ keyword, a hash (‘sha256-j3kW1ylRRXx1+pINyR/6EW435UHoxKSlU6fhd5xVSSk=‘), or a nonce (' nonce-...' ) is required to enable inline execution. Note also that ' script-src'  was not explicitly set, so ' default-src'  is used as a fallback.

Use the browser console's policy violation to diagnose why a published endpoint's inline script was refused. section 12.4.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains profile creation, target compatibility, deployment choices, and post-deployment verification, but not the complete publishing configuration.
Examples
Uses Visual Studio targets, a Windows Web Deploy host, local folders, FTP, deployed GET endpoints, and browser-console policy errors.
What it assumes
Assumes a Visual Studio project and a hosting server with a compatible deployment component or transfer method.
What you can do after
Operate Visual Studio publishing profiles, select compatible targets, deploy the application, and verify endpoints in production.
How it connects
Connects publishing with deployment, Visual Studio publish profiles, Web Deploy, Swagger UI, and Content Security Policy.

Also explained in

Compare how 2 books explain application publishing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.