How to debug project.json/nuget build issues?

121 views Asked by At

Visual Studio 2015 Enterprise

Nuget.exe 3.4.4.1321

Project: Windows Forms Class Library

OK I have project.json file setup in my solution and this builds fine. I have NO IDEA how msbuild finds the packages project.json asks for, but that's fine.

I check the files into TFS 2012 (ya I know, our company won't upgrade yet)

TFS fails to build. Says "type cannot be found..."

How on earth do you DEBUG these sorts of issues when you have NO IDEA where MSBuild even LOOKS for packages?

I can GUESS where MS Build may be looking, but how can I confirm this?

csproj hintpaths had their drawbacks, but at least you KNEW where msbuild would look for your package

with Project.Json I have no idea where msbuild is looking!

The package IS there on the build server, right where I expect it to be. How to tell msbuild.exe where to look for packages?

2

There are 2 answers

0
user5855178 On BEST ANSWER

project.lock.json will report the resolution path for nuget packages.

This will appear at the VERY BOTTOM of the project.lock.json file: sample:

 "packageFolders": {
    "c:\\nuget_packages": {}

Adding this key in nuget.config tells nuget where to restore packages:

  <config>
    <add key="globalPackagesFolder" value="c:\nuget_packages" />
  </config>

This ONLY works for nuget 3+ with project.json file, not with packages.config

3
Tingting0929 On

According to your error message, it seems that something wrong with the reference using. For trouble shooting your issue, please try the following.

  • Please use Package.config for your project to install packages in TFS build. Check if it works to make sure your assemblies and packages are fine.
  • If Package.config doesn't work. Please provide the detail steps for me to reproduce your issue.
  • If package.config works but project.json doesn't works. Look at this document: Converting a csproj from package.config to project.json

To debug a build: https://msdn.microsoft.com/en-us/library/jj635150.aspx?f=255&MSPPError=-2147217396

Note: To always use the latest version of the package available, you could add the following to Nuget.config file. So it will get the latest version when you use packages.config. The Nuget.config file is at: C:\Users\UserName\AppData\Roaming\NuGet (nuget spec dependencies, get latest version?)

<configuration>
    <config> 
        <add key="dependencyversion" value="Highest" /> 
    </config>
</configuration>