question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarification on dotnet restore in solution with mixed old/new CSPROJ schema based projects

See original GitHub issue

dotnet restore in solution directory restores the dependencies of all the “.NET Core” projects in the solution. It does not restore the non-NetCore ones in the solution (the ones which are using old CSPROJ format with packages.config to enlist their dependencies).

nuget restore (where NUGET is v3.4, v3.5 or v4.0) in solution directory only restores the dependencies of non-NETCore projects, but does not understand the inline references in new CSPROJ schema (<PackageReference .. />).

After some experimentations, I have figured:

  • Although running both nuget restore && dotnet restore addresses the problem, but if we instead use nuget restore && dotnet restore --packages ./packages, dotnet-restore clears the packages directory first which was populated by dotnet restore.
  • Having packages.config for NETCore projects enlisting all the dependencies which we have in new CSPROJ (in the form of <PackageReference .. />); enables nuget restore to take care of restoration singlehandedly. Tested with NuGet v3.4, v3.5 and v4.0.

Can (/will) dotnet restore enumerate packages.configs in the projects, so we only need to use one tool to restore the packages in mixed solution scenarios?


dotnet --info

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
emgartencommented, Mar 15, 2017

@am11 you only need to run nuget.exe restore, it restores everything dotnet restore does and it also restores packages.config.

https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe

3reactions
am11commented, Mar 15, 2017

@emgarten, you are right, Just clicked on the link and tested it worked! 😮 I thought I have nuget 4 in path (aliased nuget40), but it was actually pointing to nuget 3.5 😢

cd c:\repos\project
:: clean repo, start over
git clean -xdf && git submodule foreach "git clean -xdf"

:: with the real nuget4.0
nuget restore

:: builds happily with MSBuild15
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild"

Thanks a lot! 👏

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet restore solution is restoring projects like they are . ...
and when dotnet restore is being run from the GitHub action, I am getting the following error error MSB4057: The target "Restore" does...
Read more >
dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
Read more >
Upgrading an existing .NET project files to the lean new ...
My approach is to first make a copy of the solution in Explorer, then replace the project you are upgrading with a brand...
Read more >
Software Modeling Fundamentals
NET, Mono, Java and Microsoft Native (C, C++ and Visual Basic). • applications. Design and execute Test suites based on Programming by Contract...
Read more >
Troubleshooting NuGet Package Restore in Visual Studio
Package Restore tries to install all package dependencies to the correct state matching the package references in your project file (.csproj) or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found