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?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I removed this nuget package but it is giving me a different error: Assets file: ..\..\obj\prohect.assets.json not found
@WWpana, Check the solution here:stackoverflow.com/questions/51642172/…
@WWpana, Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.
yes it worked. thanks. Will comment again if it fails again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.