0

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?

user5855178
  • 567
  • 1
  • 7
  • 17
  • Could you please post the whole error messages here? Does the " "Windows Forms Class Library" means Windows Forms applications project? – Tingting0929 Apr 12 '17 at 08:56
  • It is a class library that uses windows forms controls in it yes. The type or namespace name 'company' could not be found (are you missing a using directive or an assembly reference?). It looks to me like it cannot find the package with the assembly in it. How on earth do you debug when you have no idea where project.json looks for this? – user5855178 Apr 12 '17 at 12:06
  • I have updated my reply. It seems that you are using your custom nuget package not those from nuget org? Does this package could be restored in your local place? If you use custom nuget package, did you add the nuget server it the Nuget.config file on TFS build agent? – Tingting0929 Apr 13 '17 at 02:09
  • Did you run nuget restore command before build? Where do you see the packages on the build server? – Eddie Chen - MSFT Apr 14 '17 at 06:59

2 Answers2

0

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>
Community
  • 1
  • 1
Tingting0929
  • 4,142
  • 1
  • 14
  • 14
  • I cannot use package.config because that does not offer the features I am looking for. We need to configure our projects to always use the latest version of the package available. Package.config restricts you to use ONLY the explicit version. There is no transitive restore available for package.config is there? – user5855178 Apr 12 '17 at 11:48
  • That document link says quite clearly that project.json replaces package.config for win forms development. I am not using .net core no, this is a .net winforms project. What am I missing here? – user5855178 Apr 12 '17 at 11:54
  • @user5855178 Did you check the update and did your issue solved? – Tingting0929 Apr 17 '17 at 02:19
0

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

user5855178
  • 567
  • 1
  • 7
  • 17