0
votes

CICD TFS 2013 - Nuget auto restores on TFS Serer MSbuild(not in Visual Studio):

I added NuGet.config file on a solution folder. but auto restores NuGet on TFS Build it's not worked.

Error:

enter image description here

$/Core/testCICD/Webtest/Webtest.sln - 5 error(s), 1 warning(s), View Log File
 Default.aspx.cs (8): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
 Default.aspx.cs (9): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
 Model\Account.cs (1): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
 Model\Account.cs (12): The type or namespace name 'JsonProperty' could not be found (are you missing a using directive or an assembly reference?)
 Model\Account.cs (12): The type or namespace name 'JsonPropertyAttribute' could not be found (are you missing a using directive or an assembly reference?)
 C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1
Can you format your question better - so the error code is separated from your text? Now it's hard to read it.Maciej Pszczolinski
How about the issue? Does the answer below resolved your question, If yes, you could Accept it as an Answer , so it could help other community members who get the same issues and we could archive this thread, thanks.Leo Liu-MSFT

1 Answers

0
votes

CICD TFS 2013 - Nuget auto restore on TFS Serer build

According to the error message, it shows you have use the Newtonsoft.Json, Version=12.0.0.0 in your project.

AFAIK, starting from Newtonsoft.Json 9.0.1, this package supports the targets framework .NETStandard:

https://www.nuget.org/packages/Newtonsoft.Json/9.0.1:

enter image description here

Which is supported by NuGet 2.12.

So, to resolve this issue, you should make sure the nuget.exe version is higher than 2.12 and the Visual Studio version is high than 2013.

To resolve this issue, you could update Visual Studio 2013 to Visual Studio 2015 and above, then use MSBuild task to specify the MSBuild 14.0 (or above) to build your project.

Or you could use the Newtonsoft.Json 8.0.3 instead of 12.0.x in your projects.