Description
I have two projects. One is a ConsoleApp, the other is WebApplication. And the WebApplication has a ProjectReference
to reference the ConsoleApp.
When I publish the WebApplication with --runtime
, it has an error like below:
/home/lsj/test/ConsoleApp2/ConsoleApp2.csproj : error : NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.9, 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. For more information, see https://aka.ms/dotnet-runtime-patch-selection.
But when I remove the <OutputType>Exe</OutputType>
line from the csproj of ConsoleApp, it succeeds.
I have done many tests:
-
If I only publish the ConsoleApp with
--runtime
and<OutputType>Exe</OutputType>
, it will success. -
If I publish the WebApplication with
--runtime
and<OutputType>Exe</OutputType>
, it will fail, no matter on Linux or Windows, no matter with .net core 2.1 or 2.2. But it will succeed with .net core 3.0. (I think it's because that there's no any .net core 3.0.x) -
If I publish the WebApplication with
--runtime
and without<OutputType>Exe</OutputType>
, it will always succeed. -
If I publish the WebApplication without
--runtime
and with<OutputType>Exe</OutputType>
, it will always succeed.