8

I have trouble with TFS. It won't build my project because

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

I tried adding it via nuget but still I am getting this error. I have other projects which work fine when i add this dll via nuget. Also, a local build of this project is successful. I created a new folder inside the solution and then placed the dll in it and I referenced it.

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Sabareesh Kkanan
  • 1,201
  • 1
  • 14
  • 22

1 Answers1

8

If your local build is successful and just the TFS build is failing then it is usually due to dll reference path issue. Make sure that the Dll is referenced as a relative path in the project file (.csproj).

To add a relative reference in a separate directory, such as C:\tfs_get\Sources\assembly\abc.dll, do the following:

Add the reference in Visual Studio by right clicking the project in Solution Explorer and selecting Add Reference.

Find the *.csproj where this reference exist and open it in a text editor. Lets say your .csproj location is c:\tfs_get\sources\myfolder\myproject\myproj.csproj

Edit the < HintPath > to be equal to

..\..\assembly\abc.dll

This build will work properly with the assumption that the folders ( assembly, myfolder) under the sources folder exist in TFS.

Hope this helps.

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • Hmmm everything is appears to be fine , the hint path is exactly pointing to the location of the dll file. but no luck – Sabareesh Kkanan Aug 15 '13 at 14:54
  • But location where? In your local project? o in your TFS project? I mean, it's doing the refer to a in-solution project? – GianlucaBobbio Aug 15 '13 at 14:56
  • Okay if the location is correct, then how does the DLL get there? Is it checked-in to TFS? or is it being built? If it is being built, make sure that the particular project is compiler before your project. Also answer the question by GianlucaBobbio about the location of the DLL. You have to explain more of your situation, what you have done etc for us to help you. – Isaiah4110 Aug 15 '13 at 17:21
  • It is actually a local project that is converted into a TFS project. I did check in after adding the reference to the local project folder and referenced to it – Sabareesh Kkanan Aug 15 '13 at 17:25
  • So you checked the TFS folder and you can see the DLL inside that folder? When you try to add DLL's to TFS it will exclude it by default, hence the question. – Isaiah4110 Aug 15 '13 at 17:41
  • hmm i ended up adding the dll file into the bin folder where the builds located in TFS server and it worked. but i think TFS should take care of it – Sabareesh Kkanan Aug 15 '13 at 19:51
  • Adding it to the TFS Server is not the right thing to do. When your source code is downloaded from TFS(repository), it should compile successfully on any machine where it is downloaded. I am not sure where/how you are missing the reference. Anyways, as a last note make sure that the version of the DLL's are same or the specificversion attribute is set to false in the .csproj file. – Isaiah4110 Aug 15 '13 at 20:25
  • 1
    - Open "Source Explorer" - Select assembly folder - Right click and select "Add items to folder" - Select DLL files and click Finish – aslanpayi Apr 29 '15 at 12:22