11

I have a project which works fine. This morning, I created a new TFS project and published all the code from Visual Studio 2015.

On another computer, also via VS2015, I've logged into Visual Studio Team Services to grab the same project and downloaded all the code

When I try to build, there are over 100 errors, but the cause appears to be the same. It can't find resources, and the error messages all appear to be

The type of namespace name 'some name' does not exist in '....' (are you missing an assembly reference?)

So, I expand the References and I'm missing pretty much all of them. In fact, other than the references within my own project, the rest are not there

Looking at the properties shows no path. Back on the original PC I see the path to any of the .dlls is similar too

C:\Users\Me\Documents\Visual Studio 2015\Projects\MyProj\ToT\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll

Is the issue that since this path doesn't match on the 'faulty' machine it can't show... Therefore what is the solution to this

enter image description here

I checked and noted that the files do appear to exist when I look at them in File Explorer.

All system references missing Visual Studio 2013 NuGet Async did not help

Please note, this happens with all projects in my solution, but not consitently. For example, EntityFramework is missing from all, but System is missing from my UI layer, but not from my BLL layer

Is there a way to fix this?

Community
  • 1
  • 1
MyDaftQuestions
  • 4,487
  • 17
  • 63
  • 120
  • Is your projects created in VS 2015? Are you using TFS TFVC or GIT? Do you queue a local build or TFS build when you find this issue? – Cece Dong - MSFT Nov 05 '15 at 06:33
  • @Cece, solution originally VS 2012 but migrated to VS 2015. Been fine with SVN. Now removed SVN to use TFS Express (not using GIT with it). I'm not aware I'm doing any queuing or building in TFS, the issue occurs when I build in VS – MyDaftQuestions Nov 05 '15 at 06:54
  • `nuget restore` as fist build step after loading solution – leppie May 05 '16 at 19:38

7 Answers7

13

You need to run the update-package -reinstall command to reinstall all referenced packages.

Vicky - MSFT
  • 4,970
  • 1
  • 14
  • 22
  • 1
    An other option for solving this would be (as Valeria described below) to delete the content of the packages folder. Isn´t it stupid that VS and TFS checkin the content of the packages folder by default? Because the default git ignore files for C# development have have them excluded from source control – WhiteIntel Jun 07 '16 at 17:06
  • 1
    I'm experiencing a similar issue and neither your solution or Valeria's worked for me. Any ideas what to try next? – rsnyder Nov 22 '17 at 15:24
7

I had the same problem, there are lots of answers by now but I will still post it here:

1.Close Visual Studio 2.Manually delete the local “packages” folder 3.Reopen the solution, and rebuild. (Nuget should restore the packages)

Source: http://robertgreiner.com/2013/09/team-foundation-service-build-error-nuget/

Valeria
  • 101
  • 1
  • 7
3

Go to TOOLS -> nuget package manager -> package manager console -> and run to the console : UPDATE-PACKAGE -REINSTALL . Clean your solution, rebuild and you are ready!

Give IT
  • 200
  • 1
  • 3
  • 19
0

First, go to VS--Tools--Extensions and Updates to check whether there are updates, install all updates. Then select one reference with a warning icon, check the Specific Version property, if the value is True, change it to False.

If the issue persists, check the Reference Assemblies of .Net framwork on your two computers, to see whether they are under the same location (the .Net framework is supposed to be under *C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework*).

========================================================================= 11/5: To avoid references missing, you can either check in all references to source control and reference from the source controlled ones, or use Nuget Package Manager to install packages. The previous is not recommended now, try Nuget Package Manager.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • I checked path on working PC, the path for Antlr3.Runtime is `C:\Users\Me\Documents\Visual Studio 2015\Projects\MyProj\ToT\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll` ... There is no path on the other computer (the one with the fault). It seems like the issue is just that it's not taking relative path names but absolute for the .dlls. If this assumption is right, how do I share the packages between machines? – MyDaftQuestions Nov 05 '15 at 06:59
  • Right click your solution, select "Manage Nuget Packages for Solution", under Nuget Package Manager, search "antlr" and install it, then check in the solution, you should be able to see the .dlls when you get the solution from another computer. – Cece Dong - MSFT Nov 05 '15 at 07:44
  • 1
    To avoid references missing, you can either check in all references to source control and reference from the source controlled ones, or use Nuget Package Manager to install packages. The previous is not recommended now, try Nuget Package Manager. – Cece Dong - MSFT Nov 05 '15 at 08:45
  • Will test when I'm in office, in 7 hours time – MyDaftQuestions Nov 05 '15 at 08:56
0

Sounds trivial but your missing references to system.xxxx could imply a problem with the .NET Framework, what version are you using and is it installed properly on your 'faulty' machine. Might be worth a re-install/repair? I'd check what versions are actually referenced too.

As for NuGet, make sure that Enable package restore is set as:

enter image description here

Also, I had a problem similar to this once and I had to upgrade the NuGet package manager to version 3 in Tools -> Extensions and Updates (You need to uninstall and then re-install as update won't work)

enter image description here

Finally if that doesn't work, check in File Explorer in the packages path and delete all packages. They should not be included in source control as this is what NuGet will download. If they are there or partially there, sometimes it will not download them.

Rodders
  • 2,425
  • 2
  • 20
  • 34
0

Verify the .NET version:

  1. Open the project properties pane and check the Target Framework: enter image description here

  2. Ensure this version of .NET is installed. OR change the target framework to a suitable version

Jared Dykstra
  • 3,596
  • 1
  • 13
  • 25
0

Before hitting your head against the wall with the million of Nuget 'fixes' you need to make sure you are getting ALL the DLLs that are in your Bin folder under source control. For some reason a simple "Get Latest Version" is not enough. Visual Studio will keep telling you all files are up to date but apparently this doesn't mean all the files under source control are downloaded (or it does and what happened to me is just a sassy bug). Anyways, to make sure you are truly "getting all" you need to force an update by using the "Get Specific Version" command with the "Overwrite all" option checked as VS suggests. To do this:

  1. Go to your Bin folder in Source Control Explorer (Or w.e folder you truly want to get all)

  2. Right Click > Advanced > Get Specific Version

  3. Check the "Overwrite all files even if the local version matches the specified version" checkbox

  4. Click Get

By doing this I ensured all the referenced DLLs were downloaded from TFS and for me that solved the problem. I'm using Visual Studio Enterprise 2015.

Raikol Amaro
  • 419
  • 4
  • 12