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

Nuget.exe can't restore packages from new csproj format #4809

Closed
Kralizek opened this issue Mar 15, 2017 · 14 comments
Closed

Nuget.exe can't restore packages from new csproj format #4809

Kralizek opened this issue Mar 15, 2017 · 14 comments

Comments

@Kralizek
Copy link

Kralizek commented Mar 15, 2017

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): nuget.exe

NuGet version (x.x.x.xxx): 4.0.0.2283

dotnet.exe --version (if appropriate): 1.0.1

OS version: Windows 10 14393.693

Worked before? If so, with which NuGet version:

Detailed repro steps so we can see the same problem

In the solution root folder

  1. dotnet restore ✔️ solution's packages are correctly restored
  2. msbuild /t:Restore ✔️ solution's packages are correctly restored
  3. .\nuget.exe restore .\Solution.sln => Nothing to do.
MSBuild auto-detection: using msbuild version '15.1.548.43366' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.

Verbose Logs

NuGet Version: 4.0.0.2283
MSBuild auto-detection: using msbuild version '15.1.548.43366' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\msbuild.exe /t:GenerateRestoreGraphFile /nologo /nr:false /p:RestoreUseCustomAfterTargets=true /p:BuildProjectReferences=false /v:q  /p:NuGetRestoreTargets="C:\Users\renato.golia\AppData\Local\Temp\NuGet-Scratch\nln511zi.pht.targets" /p:RestoreTaskAssemblyFile="C:\Development\nuget.exe" /p:RestoreGraphOutputPath="C:\Users\renato.golia\AppData\Local\Temp\NuGet-Scratch\ythtwe3i.p2s.result" /p:ExcludeRestorePackageImports=true  /p:RestoreRecursive=False  /p:RestoreProjectFilterMode=exclusionlist /p:RestoreContinueOnError=WarnAndContinue  /p:RestoreGraphProjectInput="C:\Development\EMGCommon\Authentication\JWT\src\EMG.AspNetCore.Authentication.JWT\EMG.AspNetCore.Authentication.JWT.csproj;C:\Development\EMGCommon\Authentication\JWT\src\EMG.Common.Authentication.JWT\EMG.Common.Authentication.JWT.csproj;C:\Development\EMGCommon\Authentication\JWT\tests\Tests.Common.Authentication.JWT\Tests.Common.Authentication.JWT.csproj;C:\Development\EMGCommon\Authentication\JWT\tests\Tests.AspNetCore.Authentication.JWT\Tests.AspNetCore.Authentication.JWT.csproj;" "C:\Users\renato.golia\AppData\Local\Temp\NuGet-Scratch\nln511zi.pht.targets"
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
@emgarten
Copy link
Member

@Kralizek can you share a solution that repros this? I'm not sure how this could happen.

@Kralizek
Copy link
Author

Kralizek commented Mar 16, 2017

Attached is a solution that I created via console. I also included the nuget.exe file I am using.

C:\Users\renato.golia\Desktop\test2> cp C:\Development\nuget.exe .

C:\Users\renato.golia\Desktop\test2> dotnet new sln
Content generation time: 25,3003 ms
The template "Solution File" created successfully.

C:\Users\renato.golia\Desktop\test2> dotnet new classlib -n TestClassLib
Content generation time: 27,299 ms
The template "Class library" created successfully.

C:\Users\renato.golia\Desktop\test2> dotnet sln add .\TestClassLib\TestClassLib.csproj
Project `TestClassLib\TestClassLib.csproj` added to the solution.

C:\Users\renato.golia\Desktop\test2> .\nuget.exe restore .\test2.sln
MSBuild auto-detection: using msbuild version '15.1.548.43366' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.

C:\Users\renato.golia\Desktop\test2> dotnet restore
  Restoring packages for C:\Users\renato.golia\Desktop\test2\TestClassLib\TestClassLib.csproj...
  Generating MSBuild file C:\Users\renato.golia\Desktop\test2\TestClassLib\obj\TestClassLib.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\renato.golia\Desktop\test2\TestClassLib\obj\TestClassLib.csproj.nuget.g.targets.
  Writing lock file to disk. Path: C:\Users\renato.golia\Desktop\test2\TestClassLib\obj\project.assets.json
  Restore completed in 1,7 sec for C:\Users\renato.golia\Desktop\test2\TestClassLib\TestClassLib.csproj.

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

  Feeds used:
      https://api.nuget.org/v3/index.json
      https://www.myget.org/F/emgprivate/auth/****/api/v2
      https://www.myget.org/F/emg/api/v2
      https://www.myget.org/F/aspnet-contrib/api/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

C:\Users\renato.golia\Desktop\test2> msbuild /t:restore
Microsoft (R) Build Engine version 15.1.548.43366
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 16/03/2017 11:23:25.
Project "C:\Users\renato.golia\Desktop\test2\test2.sln" on node 1 (restore target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Restore:
  Restoring packages for C:\Users\renato.golia\Desktop\test2\TestClassLib\TestClassLib.csproj...
  Committing restore...
  Lock file has not changed. Skipping lock file write. Path: C:\Users\renato.golia\Desktop\test2\TestClassLib\obj\pr
  oject.assets.json
  Restore completed in 649,23 ms for C:\Users\renato.golia\Desktop\test2\TestClassLib\TestClassLib.csproj.

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

  Feeds used:
      https://api.nuget.org/v3/index.json
      https://www.myget.org/F/emgprivate/auth/*****/api/v2
      https://www.myget.org/F/emg/api/v2
      https://www.myget.org/F/aspnet-contrib/api/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\Users\renato.golia\Desktop\test2\test2.sln" (restore target(s)).


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

Time Elapsed 00:00:02.56
C:\Users\renato.golia\Desktop\test2>

Issue4809.zip

Issue4809-with-deps.zip

@Kralizek
Copy link
Author

Am I the only one having this issue?

@jason-costello
Copy link

I'm seeing this as well on a project that was migrated. using Msbuild restore gives the same output you have above but no drop is created when the build is ran on TFS.

@emgarten
Copy link
Member

@Kralizek I'm not able to repro this. nuget.exe restore test2.sln restores the project correctly for me. Are you able to repro the same result on other machines?

@jrc60752 does restore create the obj\project.assets.json file for you?

@Kralizek
Copy link
Author

@emgarten I'll check during the weekend (just posted to avoid the issue to be closed due to inactivity)

@Kralizek
Copy link
Author

Kralizek commented Apr 1, 2017

@emgarten I can confirm it worked on my home computer.

Would you please guide me troubleshooting the issue on my office computer?

@Vertigo093i
Copy link

I suppose the problem is that NuGet uses MSBuild from Build Tools rather than any full VS edition. As the former doesn't have .NET Core SDK bundled within it.
As explained in #4280 (comment) the required property is not set.
Also tracked here: dotnet/msbuild#1697.

@emgarten
Copy link
Member

emgarten commented Jun 1, 2017

NuGet.exe should bring it's own targets needed for reading projects, but it is possible that the project relies on something else from the SDK that isn't being loaded by MSBuild.

@dannyrb
Copy link

dannyrb commented Jul 16, 2017

I was receiving the same error as @Kralizek on my build server (trying to setup TeamCity). Installing VS Community and restarting resolved the issue. Same build -- Just reran.

@anangaur
Copy link
Member

@emgarten is it possible to tell nuget.exe to pick up a specific msbuild using a environment variable if a that msbuild version works here?

@emgarten
Copy link
Member

NuGet.exe will use msbuild.exe from %PATH%, so in that way an env var can be used.

@bmmathe
Copy link

bmmathe commented Sep 6, 2017

This started happening to me when I installed the .Net Core 2.0 sdk and upgraded VS to 15.3. My current solution I'm trying to build targets .Net Core 1.1. The nuget restore command is not installing my nuget references from my projects with PackageReference(s) in them. However I can build the solution in Visual Studio with no issues. When I restore using VS I do see the obj/projects.assets.json file. However if I just run a nuget restore solution.sln I do not get an obj/projects.assets.json file and the message is "Nothing to do. None of the projects in this solution specify any packages for NuGet to restore."

@emgarten emgarten added this to the 4.3 milestone Sep 7, 2017
@emgarten
Copy link
Member

emgarten commented Sep 7, 2017

This issue should be resolved in nuget.exe 4.3.0
https://www.nuget.org/downloads

If anyone is still hitting this with the latest bits please open a new issue with details repro steps.

@emgarten emgarten closed this as completed Sep 7, 2017
shana added a commit to shana/DotNetZip.Semverd that referenced this issue May 2, 2018
The dotnet core update breaks nuget restores (as in, nuget doesn't know how
to restore PackageReference projects, see NuGet/Home#4809)
I tried newer versions of nuget but no luck, something is still really broken.
msbuild knows how, though, so use that to restore things.

Also, clean up some backup files that should not have been committed,
make sure all builds use VS2017 on appveyor, and make cloning faster there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants