1

The Nuget Restore from VSO's build pipeline failed due to some nuget packages that are not compatible with netcoreapp2.1. However, when I looked through all the csproj files in the solution, none of the csproj files have these nuget packages. I might have installed these before but right now it's definitely not here.

enter image description here

Here's the csproj file that is mentioned in the error message.

 <ItemGroup>
    <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.6" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
  </ItemGroup>

Here's the Nuget.Config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Please advise how to fix this issue.

EDIT=====================================================

After removing the nuget package from Microsoft.AspNet.WebApi, the NugetRestore passed, but Build solution failed. It shows a different error

[error]C:\Program Files\dotnet\sdk\2.2.104\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5):

Error NETSDK1004: Assets file 'd:\agentwrok\18\s....\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

This is the configuration for Build Solution

enter image description here Any advice on the next step?

Community
  • 1
  • 1
superninja
  • 3,114
  • 7
  • 30
  • 63

1 Answers1

3

VSO Build Pipeline's Nuget Restore Failed

Just like Volodymyr commented, you should not use the package Microsoft.AspNet.WebApi for the .net core project. That is because this package is targeted at .NETFramework, not .NET Core/.NETStandard. It is not compatible with .NET Core.

When you check the package Microsoft.AspNet.WebApi on nuget.org, you will notice that this package has a dependency on Microsoft.AspNet.WebApi.WebHost, which only targets the .NET Framework:

enter image description here

enter image description here

And the sub-dependency Microsoft.AspNet.WebApi.Core of the package Microsoft.AspNet.WebApi.WebHost also only targets the .NET Framework:

enter image description here

So, the reason for this issue is that the package Microsoft.AspNet.WebApi and its dependencies are not compatible with .NET Core framework.

Hope this helps.

Palle Due
  • 5,929
  • 4
  • 17
  • 32
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I removed this nuget package but it is giving me a different error: `Assets file: ..\..\obj\prohect.assets.json` not found – superninja Mar 22 '19 at 18:29
  • 1
    @WWpana, Check the solution here:https://stackoverflow.com/questions/51642172/the-project-was-restored-using-microsoft-netcore-app-version-2-1-0-but-with-cur/51644988#51644988 – Leo Liu Mar 23 '19 at 05:18
  • 1
    @WWpana, Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance. – Leo Liu Mar 27 '19 at 07:31
  • yes it worked. thanks. Will comment again if it fails again. – superninja Mar 27 '19 at 18:46