Post

Second Update on Offline Publishing ASP.NET Core Apps

A third post about offline publishing ASP.NET Core apps.

Second Update on Offline Publishing ASP.NET Core Apps

I posted about offline publishing ASP.NET Core web apps earlier. It was a migration from 2.0.5 to 2.0.6. And now we need a new post, to upgrade from 2.0.6 to 2.1.0.

Microsoft has a very long article on the migration steps in general. But you might find I didn’t follow all their steps.

Project File Changes

I only changed TargetFramework and PackageReference parts, so the project file looks like this,

1
2
3
4
5
6
7
8
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
</Project>

It is quite simple to follow.

Publishing Command

This time RuntimeFrameworkVersion is no longer needed,

1
$ dotnet publish -r win-x64 --self-contained

NuGet Packages

Of course, it asks for new version 2.1.0 of the following,

  • runtime.win-x64.Microsoft.NETCore.App
  • runtime.win-x64.Microsoft.NETCore.DotNetHostPolicy
  • runtime.win-x64.Microsoft.NETCore.DotNetHostResolver
  • runtime.win-x64.Microsoft.NETCore.DotNetAppHost

You should notice that even if the ASP.NET Core MVC sample was created in 2.0 time frame, compiling and running it using 2.1 toolchain changes the behaviors. For example, now this app listens on both http://localhost:5000 and https://localhost:5001. And that’s why when you first compile it, the dotnet command would display the following message,

ASP.NET Core

Successfully installed the ASP.NET Core HTTPS Development Certificate.

To trust the certificate run dotnet dev-certs https --trust (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.

For more information on configuring HTTPS see this article.

© Lex Li. All rights reserved. The code included is licensed under CC BY 4.0 unless otherwise noted.
Advertisement