Skip to content

dotnet publish --no-build surprising behavior #10608

@swaroop-sridhar

Description

@swaroop-sridhar

Trying the following sequence:

dotnet new console
dotnet build -r win-x64 
dotnet publish --no-build -r win-x64 --self-contained=false

Will generate an inconsistent app. The published output only contains the files for a fw-dependent build, but contains the deps.json and runtimeconfig.json from the self-contained build step. This causes the app to fail at runtime.

This can lead to surprising failures for customers (reported by @ryknuth), especially because:

  • Mentioning the RID implicitly generates a self-contained build
  • There's no --self-contained=false option on the build step
  • Some of the properties may be imported from various csproj files, and the distinction may not be obvious to the customer.
  • The failure mode is not intuitive. The app fails with:
    Message: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.

In this case, I think the publish step should fail with an error, rather than generating a wrong app.

@nguerrera @jeffschwMSFT

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions