Skip to content

Lock files prevent publishing when <RuntimeIdentifiers> is set #8287

@bergbria

Description

@bergbria

Details about Problem

dotnet.exe --version (if appropriate): 2.2.300 and 3.0.100-preview5-011568

Automated repro

Download/unzip restore_multi_RID_repro.zip and run repro.bat

Detailed repro steps so we can see the same problem

  1. Create a csproj with multiple RIDs specified in <RuntimeIdentifiers> (e.g. <RuntimeIdentifiers>osx-x64;win-x64</RuntimeIdentifiers>)

  2. dotnet restore --use-lock-file

At this point, simply running dotnet publish won't actually create self-contained applications (e.g. a .exe file for windows). This is annoying, but not really Nuget's fault.

Normally, this would be resolved by running dotnet publish -r win-x64. However, this will actually mutate the lock file that was just generated.

If I enable locked mode in the publish command (this really should be a top-level flag, btw) via dotnet publish -p:RestoreWithLockFile=true -p:RestoreLockedMode=true -r win-x64, this will fail with error NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode

Effectively, publishing doesn't play nicely with lock files when multiple RuntimeIdentifiers are in the csproj.

Presumably there's something in the restore target that looks at the <RuntimeIdentifier> property and discards <RuntimeIdentifiers> if it's set.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions