NuGet Package Restore Not Working

后端 未结 20 2052
情书的邮戳
情书的邮戳 2020-12-02 04:06

I checked in a project on one computer, checked out on another, and find that the binaries installed by NuGet are missing. I could check them in to source control as well,

20条回答
  •  伪装坚强ぢ
    2020-12-02 05:03

    I have run into this problem in two scenarios.

    First, when I attempt to build my solution from the command line using msbuild.exe. Secondly, when I attempt to build the sln and the containing projects on my build server using TFS and CI.

    I get errors claiming that references are missing. When inspecting both my local build directory and the TFS server's I see that the /packages folder is not created, and the nuget packages are not copied over. Following the instructions listed in Alexandre's answer http://nuget.codeplex.com/workitem/1879 also did not work for me.

    I've enabled Restore Packages via VS2010 and I have seen builds only work from within VS2010. Again, using msbuild fails.My workaround is probably totally invalid, but for my environment this got everything working from a command line build locally, as well as from a CI build in TFS.

    I went into .\nuget and changed this line in the .nuget\NuGet.targets file:

    from:

    $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" -o "$(PackagesDir)"
    

    to: (notice, without the quotes around the variables)

    $(NuGetCommand) install $(PackagesConfig) -source $(PackageSources) -o $(PackagesDir)
    

    I understand that if my directories have spaces in them, this will fail, but I don't have spaces in my directories and so this workaround got my builds to complete successfully...for the time being.

    I will say that turning on diagnostic level logging in your build will help show what commands are being executed by msbuild. This is what led me to hacking the targets file temporarily.

提交回复
热议问题