NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Restore silently dedups projects that point to the same MSBuildProjectExtensionsPath #10689

Open nkolev92 opened 3 years ago

nkolev92 commented 3 years ago

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe): All

Product version: 5.9

Worked before? If so, with which NuGet version: No

Repro steps and/or sample project

  1. Create a solution with 2 PackageReference projects.
  2. In the root directory of the sln (higher than the 2 projects), add a directory.build.props and set MSBuildProjectExtensionsPath to an exact path.
  3. Restore

Observe that only 1 project got restored. If you restore again, you will notice that the 2nd project gets restored as well.

Verbose Logs

C:\Users\Nikolche\Code\stuff2 [master]> msbuild /t:restore
Microsoft (R) Build Engine version 16.10.0-preview-21118-01+f0eebf287 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 24-Mar-21 2:12:46 PM.
Project "C:\Users\Nikolche\Code\stuff2\solution.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
_GetAllRestoreProjectPathItems:
  Determining projects to restore...
Restore:
  Restoring packages for C:\Users\Nikolche\Code\stuff2\A\A.csproj...
  Committing restore...
  Generating MSBuild file C:\Users\Nikolche\Code\stuff2\objd\A.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\Nikolche\Code\stuff2\objd\A.csproj.nuget.g.targets.
  Writing assets file to disk. Path: C:\Users\Nikolche\Code\stuff2\objd\project.assets.json
  Restored C:\Users\Nikolche\Code\stuff2\A\A.csproj (in 162 ms).

  NuGet Config files used:
      C:\Users\Nikolche\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
      C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\Users\Nikolche\Code\stuff2\solution.sln" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.84
C:\Users\Nikolche\Code\stuff2 [master +1 ~0 -0 !]> msbuild /t:restore
Microsoft (R) Build Engine version 16.10.0-preview-21118-01+f0eebf287 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 24-Mar-21 2:12:54 PM.
Project "C:\Users\Nikolche\Code\stuff2\solution.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
_GetAllRestoreProjectPathItems:
  Determining projects to restore...
Restore:
  Restoring packages for C:\Users\Nikolche\Code\stuff2\B\B.csproj...
  Committing restore...
  Generating MSBuild file C:\Users\Nikolche\Code\stuff2\objd\B.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\Nikolche\Code\stuff2\objd\B.csproj.nuget.g.targets.
  Writing assets file to disk. Path: C:\Users\Nikolche\Code\stuff2\objd\project.assets.json
  Restored C:\Users\Nikolche\Code\stuff2\B\B.csproj (in 222 ms).

  NuGet Config files used:
      C:\Users\Nikolche\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
      C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\Users\Nikolche\Code\stuff2\solution.sln" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.87
C:\Users\Nikolche\Code\stuff2 [master +1 ~0 -0 !]>
rainersigwald commented 4 months ago

We should also consider making this an MSBuild BuildCheck--it may be covered by https://github.com/dotnet/msbuild/issues/9879.