Skip to content
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

msbuild restore followed by a msbuild RestoreLockedMode=true always fails #8247

Closed
rainersigwald opened this issue Jun 20, 2019 · 1 comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue

Comments

@rainersigwald
Copy link

From @jabbera on Thursday, June 20, 2019 3:51:25 PM

I would expect the following to always succeed.

msbuild test.sln /t:restore
msbuild test.sln /t:restore /p:RestoreLockedMode=true

On my machine it always fails with:
error NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Please disable RestoreLockedMode MSBuild property or pass explicit --force-evaluate flag to run restore to update the lock file.

Steps to reproduce

$nugetconfig = @"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>
"@

$dirprops = @"
<Project>
  <PropertyGroup>
    <!--NUGET RESTORE SETTINGS -->
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
    <!--NUGET RESTORE SETTINGS -->
  </PropertyGroup>
</Project>
"@

mkdir test
cd test
mkdir ".nuget"
$nugetconfig | Out-File ".nuget\nuget.config"

$dirprops | Out-File "Directory.Build.props"

dotnet new sln
mkdir Fabric.Classlib
mkdir Fabric.Base.ClassLib
cd Fabric.Classlib
dotnet new classlib
cd ..
cd Fabric.Base.Classlib
dotnet new classlib
cd ..
cd Fabric.Classlib
dotnet add reference ..\Fabric.Base.Classlib\Fabric.Base.Classlib.csproj
cd ..
dotnet sln add Fabric.Base.Classlib\Fabric.Base.Classlib.csproj
dotnet sln add Fabric.Classlib\Fabric.Classlib.csproj
msbuild test.sln /t:restore
msbuild test.sln /t:restore /p:RestoreLockedMode=true

Expected behavior

msbuild test.sln /t:restore /p:RestoreLockedMode=true should succeed.

Actual behavior

Fails with the below error.

error NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Please disable RestoreLockedMode MSBuild property or pass explicit --force-evaluate flag to run restore to update the lock file. [C:\Temp\test\test\test.sln]

Environment data

msbuild /version output:

C:\Temp\test\test>msbuild /version
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.1.76.45076

OS info:
Windows 10 1903

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):

C:\Temp\test\test>dotnet --version
3.0.100-preview6-012264

Copied from original issue: dotnet/msbuild#4455

@heng-liu
Copy link
Contributor

Thanks. This is a duplicate of #8187. It's already fixed and should be released in preview3 soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants