问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/18243606/namespace-could-not-be-found-building-using-tfs