How to solve the "project.assets.json not found. Run a NuGet package restore to generate this file" problem in .NET Core applications when using MSBuild

While I was developing a .NET Core web application and wanted to automate the build process in VSTS, I got the following error, when I was triggering the build:

Error: Assets file ...\project.assets.json not found. Run a NuGet package restore to generate this file. Process 'msbuild.exe' exited with code 1.

The issue here is that needed .NET Core files are missing, when we start build our application. I solved this problem by defined an extra initial step in my build process.

I used the dotnet restore package and add it in the first place of my build:

The dotnet restore package you can use with MSBuild

The only setting you have to make for this package is to define the restore command:

Setting up the dotnet restore package

Now the first action that is being made is the restore the missing files and the continue with the next steps of your build process.

comments powered by Disqus