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

[Bug Bash] Only one error NU1004 displays in Error List window with the solution contains multiple non-SDK projects after restoring with enabled “RestoreLockedMode” #13754

Open
v-luzh opened this issue Aug 30, 2024 · 2 comments
Labels
Area:RestoreRepeatableBuild The lock file features Found:ManualTests Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:VS.Client Style:PackageReference Type:Bug

Comments

@v-luzh
Copy link

v-luzh commented Aug 30, 2024

NuGet Product Used

Visual Studio Package Management UI

Product Version

Dev\6.12.0.87

Worked before?

It’s not a regression since it reproduced on both D16.11\34601.136 and D17.11\35208.52.

Impact

It bothers me. A fix would be nice

Repro Steps & Context

Repro Steps:      

  1. Create a solution with two C# Class Library (.Net Framework) projects in VS.
  2. Install a ‘PackageReference’ package into these projects.
  3. Set MSBuild property “RestorePackagesWithLockFile” to true in csproj file (Do the same setup for both programs).
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
  4. Do a solution restore from context menu of Solution Explorer window.
  5. Check it should have generated ‘packages.lock.json’ file alongside every *.csproj file.
  6. Set msbuild property “RestoreLockedMode” to “true”. (Do the same setup for both programs)
    <RestoreLockedMode>true</RestoreLockedMode>
  7. Install another package into these projects.
  8. It should still work fine and update every ‘packages.lock.json’ file.
  9. Manually add a new PackageReference item into every csproj file (under the with other installed package).
    <PackageReference Include="NUnit"> 
      <Version>3.12.0</Version> 
    </PackageReference> 
  1. Perform solution restore from context menu of Solution Explorer window again.

Expected:

Error NU1004 should displays for every project because the same action is performed for every project.

Actual:       

Only one error NU1004 displays as below:
image

Notes:  

  1. The repro rate is 100%.
  2. The missing error of another project will display after restoring the solution again as below:
    MissingErrorShows
  3.  It doesn't repro when running the command "msbuild /t:restore /v:d", two errors will show.
    
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Sep 8, 2024

I am able to reproduce the issue. Package manager output window has NU1004 errors for both the projects.

NU1004: The package references have changed for net48. Lock file's package references: Newtonsoft.Json:[13.0.3, ), Serilog:[4.0.2-dev-02226, ), project's package references: Newtonsoft.Json:[13.0.3, ), NUnit:[3.12.0, ), Serilog:[4.0.2-dev-02226, ).The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.
NU1004: The package references have changed for net48. Lock file's package references: Newtonsoft.Json:[13.0.3, ), Serilog:[4.0.2-dev-02226, ), project's package references: Newtonsoft.Json:[13.0.3, ), NUnit:[3.12.0, ), Serilog:[4.0.2-dev-02226, ).The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.
Failed to restore C:\Users\USERID\source\repos\ConsoleApp16\ConsoleApp1\ConsoleApp1.csproj (in 22 ms).
Failed to restore C:\Users\USERID\source\repos\ConsoleApp16\ConsoleApp16\ConsoleApp16.csproj (in 22 ms).
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Time Elapsed: 00:00:00.3905513
========== Finished ==========

I also noticed that project.assets.json file for both the projects have NU1004 error.

  "logs": [
    {
      "code": "NU1004",
      "level": "Error",
      "message": "The package references have changed for net48. Lock file's package references: Newtonsoft.Json:[13.0.3, ), Serilog:[4.0.2-dev-02226, ), project's package references: Newtonsoft.Json:[13.0.3, ), NUnit:[3.12.0, ), Serilog:[4.0.2-dev-02226, ).The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file."
    }

AFAIK, it is the project system responsibility to display log messages from project.assets.json file in Visual Studio error list window for CpsPackageReferenceProject. I am unsure if that's the case for LegacyPackageReferenceProject because the project types mentioned in this repro steps are legacy PR projects.

@nkolev92
Copy link
Member

For non-SDK style projects, ensuring the warnings are in the error list is our responsibility.

@nkolev92 nkolev92 added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreRepeatableBuild The lock file features Found:ManualTests Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:VS.Client Style:PackageReference Type:Bug
Projects
None yet
Development

No branches or pull requests

3 participants