Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing a Self-contained Console app fails

Tags:

.net-core

I installed the .NET SDK 2.1.301-win-x64.exe and afterwards updated all the nuget packages to 2.1.1.

In my WebApp I have the Nuget Package Microsoft.AspNetCore.All 2.1.1 and Microsft.NETCore.App 2.1.0. In the Nuget Window I see that there's also the Version 2.1.1, but I can't select it (Blocked by Project)

Same story in my Console App: Microsft.NETCore.App 2.1.0

My first question: Is here already something wrong? Or is this expected behavior?

If I build the WebApp as self contained App, that works well.

If I biuld the Console App as self contained App (Self-contained / win-x64). I get the follwoing Error:

The project was restored using Microsoft.NETCore.App version 2.1.1, but with current settings, version 2.1.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore."

The source of this error is a referenced project.

What do I do wrong? Let me know if you need additional information, then I will add it.

like image 542
gsharp Avatar asked Jun 28 '18 15:06

gsharp


1 Answers

This is a known issue for the moment. In your referenced project's csproj file, set the TargetLatestRuntimePatch property:

<PropertyGroup>
  <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>

This only happens when a .NET Core application references another .NET Core application and self-contained roll-forward only partially kicks in during publish.

For portable applications, it is enough to target 2.1.0 version of Microsoft.NETCore.App and when run on a target machine, the latest patch available on the machine will be used automatically. In recent tooling, a change was made so that the tooling would use the latest known patch version for self-contained applications so you automatically bundle the latest patch release with your application. However, this doesn't flow over project-to-project references.

See Self-contained deployment runtime roll forward for more information.

like image 195
Martin Ullrich Avatar answered Oct 07 '22 20:10

Martin Ullrich