Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

project.assets.json not found - TFS Build Server, no internet

We're just in the process of transitioning from VS2013&15/TFS2013 to VS2017/TFS2017 (on-site TFS, not VSTS) and the first test solution is a dotNet Core 1.1 based one (a multi-project web service).

The solution builds fine on the original developer's box and I've got it out of TFS and it builds fine on mine too. In keeping with our previous methodology the contents of the packages folder are checked in with the projects as this makes the packages locally available on the build box (no internet).

Building the solution on the build server is a different story, however, as I get multiple errors of the form...

..\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

I get the errors both when I run the TFS build definition and when I remote to the box and build directly through the VS on the box itself.

This whole project.assets.json not found issue seems to be causing headaches all over. In my case the issue is that I'm trying to resolve it on our TFS 2017 Build Server, which does not and never will have internet access ('cos it's a server!).

All the solutions I've seen thus far seem to suggest running the Nuget Restore command but that can't work since the server cannot get to nuget.

This is nothing fancy yet, just a simple TFS 2017 Build definition with a Get sources and a Build solution step. I can't understand how something so simple has become so difficult.

Changing the Nuget Package Restore options makes no difference.

Since the project.assets.json files are generated on the fly in the obj folder, I can't even check them in to reuse. Can anyone please suggest a workaround, at the moment the test project is dead in the water.

Edit: trying the same process with a 4.6.1 web project created with VS2015 had similar results of unresolved references (e.g. System.Web) but didn't raise the same error, probably due to being an older, non-Core project.

like image 750
Mike Avatar asked Feb 01 '18 06:02

Mike


People also ask

How do I fix netsdk1004 assets not found?

To resolve the error, remove the % from the folder name, and rerun dotnet build . A change to the project file wasn't automatically detected and restored by the project system. To resolve the error, open a command prompt and run dotnet restore on the project.

Where does project assets JSON come from?

json file is generated in the process of restoring the NuGet packages in projects that use project. json . It holds a snapshot of all the information that is generated as NuGet walks the graph of packages and includes the version, contents, and dependencies of all the packages in your project.


1 Answers

According to I get the errors both when I run the TFS build definition and when I remote to the box and build directly through the VS on the box itself.

The issue seems not related to TFS build side since it also not work with local build through VS in the build agent machine.

Since this is a dotnet project. So, you could try to use “dotnet restore” and not “nuget restore”. Try using the dotnet core template (which uses dotnet restore).

If you are using authenticated nuget feeds, then you can use nuget restore but you also need to use nuget installer task. See https://github.com/Microsoft/vsts-tasks/issues/3762 for a discussion on that. The Nuget version should be higher than 4.0.

Without dotnet restore and Nuget restore and only use get source/Visual Studio Build will not be able to build the dotnet core project. If your server do not have internet access, as a workaround you should use Local feeds.

like image 136
PatrickLu-MSFT Avatar answered Nov 30 '22 13:11

PatrickLu-MSFT