New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock files prevent publishing when <RuntimeIdentifiers> is set #8287
Comments
Since packages can contain architecture and platform specific assemblies, rids affect restore and the packages downloaded. The self contained publish is effectively changing the restore inputs, and since the intermediates are shared, restore fails. Not sure what our long term strategy is, as that will involve SDK/CLI people (@livarcocc), but for now, as a workaround you can do the following;
|
@nkolev92 - this fails with the same error whether or not I pass --no-restore
|
edit: Not sure what that first sentence was, lol :D Does the 2nd step fail? That should not trigger restore at all. So I'd imagine there's something else going wrong. |
@nkolev92 - yes, I'm sure. I've captured a diagnostic .binlog of the failed build and am attaching it here. (Note that I had to change the extension to .zip to make github happy, You'll want to rename before opening). publish_multiRID.zip It's specifically failing in the ResolvePackageAssets target, which is run due to ResolveLockFileReferences, which gets hooked into the dependsontargets for ResolvePackageDependenciesForBuild, which is depended on by ResolveAssemblyReferences. None of those seem to be conditional. |
Due to legacy reasons the ResolveLockFileReferences target actually refers to the assets file. So as expected the restore operaton itself is not running, however the SDK error seems weird. Does dotnet build --no-restore work? |
It works if I run restore first; else not. |
oh, my bad, that was unclear. So you have to run 1 full restore with all the rids and then just publish for each rid individually. |
Summary of behavior:
#1 seems like a bug in the dotnet sdk. Logged dotnet/sdk#3383 for that. |
Btw some RuntimeIdentifiers guidance was removed from the docs due to issues with the different package references for FDD and SDD dotnet/docs#9239 |
@nkolev92 - Not sure what the scope of this work is. |
There are certain packages that are RID specific. Especially ones related to self contained publish. Publish usually tends to run a restore with a certain RuntimeIdentifier/s set. The action item here is to either
|
@nkolev92 Is the current recommendation to restore with |
We don't really have a well fleshed out recommendation at this point. I wouldn't recommend just running force-evaluate as then you're defeating the locking. |
Thanks for the guidance. I've added the following to my
Are there any risks with doing this that I am missing? |
As long as you make RuntimeIdentifier(s) defaults are not set, then I don't see any concerns. The biggest challenge is remember to regenerate all lock files before pushing. |
It's a pity that this is still an issue after being reported several years ago. Suggested workarounds and MSBuild configuration voodoos don't outweigh the underlying problem. They instead bring another bunch of headaches. A robust and viable solution is needed here; otherwise, package locking doesn't have much value with NuGet. |
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
Create a csproj with multiple RIDs specified in
<RuntimeIdentifiers>
(e.g.<RuntimeIdentifiers>osx-x64;win-x64</RuntimeIdentifiers>
)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 witherror 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.The text was updated successfully, but these errors were encountered: