When trying to build a project using Azure Pipelines, it failed with the following error message:
NETSDK1005–Asset file is missing target
This error message is not very descriptive and it was not immediatelly obvious where the mistake was.
In this case the problem was related to the fact I was combining an older NuGet.exe to restore the nuget packages in combination with a .NET 5 project.
From the documentation:
NuGet writes a file named project.assets.json in the obj folder, and the .NET SDK uses it to get information about packages to pass into the compiler. In .NET 5, NuGet added a new field named
TargetFrameworkAlias
, so earlier versions of MSBuild or NuGet generate an assets file without the new field.
To fix the issue I had to change the NuGet Tool Installer task to use NuGet version 5.8 or higher:
More information: https://docs.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1005