Assets file project.assets.json not found when running a build on Azure Devops

Rui Jarimba picture Rui Jarimba · Nov 29, 2018 · Viewed 9.6k times · Source

I have a build pipeline configured for a Service Fabric solution on Azure DevOps like this:

Build tasks

Everything was fine until a few days ago when the build started failing on a particular build agent (private), with the following error (for a few projects):

C:\Program Files\dotnet\sdk\2.1.200\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(327,5): Error : Assets file 'F:\Agent03\w\84\s\src\MyProject.Sam.Tiles.Domain\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

The failing task is the Build solution $(PathToSolution) one.

The weird thing is that the build fails when running on some agents but with others the build is fine.

Some details:

  • Use NuGet 4.x task started using NuGet v4.9.1 very recently, I think. I tried using v4.8.1 with no luck;
  • Most of the projects use the PackageReference format, but the .sfproj project uses the packages.config file
  • I tried using the dotnet restore task but there is an error when trying to restore the packages for the .sfproj project:

    `Error : Unable to find the '....\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package

Any idea on what might be causing this issue?

Answer

Rui Jarimba picture Rui Jarimba · Dec 7, 2018

Some of the projects use the PackageReference format but the .sfproj project uses the packages.config file.

I still don't understand why the build started failing, but I was able to find a workaround. Given that PackageReference is not yet supported in Service Fabric projects, my workaround was to use both restore tasks as follows:

Build tasks