Skip to content

Publish a WebApplication project using dotnet publish will fail when it references a project with Exe outputtype #3307

Open
@kkwpsv

Description

@kkwpsv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions