Azure-pipelines-tasks: after dotnet tool installer, fails on Nuget.Targets file

Created on 16 Aug 2017  路  16Comments  路  Source: microsoft/azure-pipelines-tasks

When trying to use an alternative .netstandard sdk version, the dotnet restore uses the sdk version you have installed but it fails at a later point when it tries to use the Nuget.Targets file.

@bryanmacfarlane asked me to raise the issue here after creating an issue under the vsts-agent repo https://github.com/Microsoft/vsts-agent/issues/1146

2017-08-16T10:39:25.6434014Z Successfully installed .NET Core runtime version 2.0.0.
2017-08-16T10:40:40.9796157Z [command]d:\a\_tool\dncr\2.0.0\x64\dotnet.exe restore d:\a\1\s\Draycir.Tenants.WebApi\Draycir.Tenants.WebApi.csproj --configfile d:\a\1\Nuget\tempNuGet_6367.config --verbosity Detailed
2017-08-16T10:41:20.0170050Z C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Project Draycir.Tenants.Domain is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Project Draycir.Tenants.Domain supports: netstandard2.0 (.NETStandard,Version=v2.0) [d:\a\1\s\Draycir.Tenants.WebApi\Draycir.Tenants.WebApi.csproj]

This is a log output from flightlevel (also in the above issue)

******************************************************************************
Starting: Restore
******************************************************************************
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.5
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
SYSTEMVSSCONNECTION exists true
Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
Caching tool: NuGet 4.0.0 x64
Using version: 4.0.0
Found tool in cache: NuGet 4.0.0 x64
Saving NuGet.config to a temporary config file.
Can\'t find loc string for key: NGCommon_NoSourcesFoundInConfig
NGCommon_NoSourcesFoundInConfig d:\a\1\Nuget\tempNuGet_144.config
"C:\Program Files\dotnet\dotnet.exe" restore d:\a\1\s\src\MyProject.Tests\MyProject.Tests.csproj --configfile d:\a\1\Nuget\tempNuGet_144.config --verbosity Detailed
  Restoring packages for d:\a\1\s\src\MyProject\MyProject.csproj...
  Restoring packages for d:\a\1\s\src\MyProject.Tests\MyProject.Tests.csproj...
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0'. [d:\a\1\s\src\MyProject.Tests\MyProject.Tests.csproj]
Release

Most helpful comment

Above advice allowed me to get further along thank you, but was still getting weird (to me) NuGet issues

Found this which got me going! Might help someone else https://stackoverflow.com/questions/45717283/vsts-build-packages-failed-to-restore-unable-to-resolve-netstandard-library

All 16 comments

same issue here, stucked deploying my updated website

@rmarinho - just to be clear, were you capable of deploying your 2.0 website previously? Or was it 1.0 using vsts2017 hosted and you updated it to 2.0? Just trying to understand your scenario.

Yap, everything was working with 1.0 the VSTS build was setup automactly from azure portal CI integration, it does a dotnet restore, dotnet build and dotnet publish .. i updated locally on my OSX to 2.0 everything works, i commit my code and the build started breaking and so then i can't deploy

@rmarinho - OK, thanks. Confirmed my suspicion, you're moving faster than the images are :)

Ah. Same here with me??

NOTE: This csproj should be targetting NETSTANDARD2_0

2017-08-16T13:55:06.5468374Z ##[section]Starting: Restore
2017-08-16T13:55:06.5634696Z ==============================================================================
2017-08-16T13:55:06.5634696Z Task         : .NET Core
2017-08-16T13:55:06.5634696Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2017-08-16T13:55:06.5634696Z Version      : 2.0.5
2017-08-16T13:55:06.5634696Z Author       : Microsoft Corporation
2017-08-16T13:55:06.5634696Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2017-08-16T13:55:06.5634696Z ==============================================================================
2017-08-16T13:55:09.2068874Z SYSTEMVSSCONNECTION exists true
2017-08-16T13:55:09.5608318Z Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
2017-08-16T13:55:09.7597187Z Caching tool: NuGet 4.0.0 x64
2017-08-16T13:55:09.7877201Z Using version: 4.0.0
2017-08-16T13:55:09.7887189Z Found tool in cache: NuGet 4.0.0 x64
2017-08-16T13:55:09.7907194Z Saving NuGet.config to a temporary config file.
2017-08-16T13:55:09.8017197Z ##[warning]Can\'t find loc string for key: NGCommon_NoSourcesFoundInConfig
2017-08-16T13:55:09.8017197Z ##[warning]NGCommon_NoSourcesFoundInConfig d:\a\1\Nuget\tempNuGet_52.config
2017-08-16T13:55:09.8447208Z [command]"C:\Program Files\dotnet\dotnet.exe" restore d:\a\1\s\src\Hornet.Core\Hornet.Core.csproj --configfile d:\a\1\Nuget\tempNuGet_52.config --verbosity Detailed
2017-08-16T13:55:13.8522632Z   Restoring packages for d:\a\1\s\src\Hornet.Core\Hornet.Core.csproj...
2017-08-16T13:55:13.9280652Z C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'. [d:\a\1\s\src\Hornet.Core\Hornet.Core.csproj]

Does it help if you add NuGet tool installer task up front and select version 4.1.0?

@bryanmacfarlane Hi Bryan,
We have the similar issue with our build

2017-08-17T12:41:58.0450965Z ##[section]Starting: Restore
2017-08-17T12:41:58.0450965Z ==============================================================================
2017-08-17T12:41:58.0450965Z Task         : .NET Core
2017-08-17T12:41:58.0450965Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2017-08-17T12:41:58.0450965Z Version      : 2.0.5
2017-08-17T12:41:58.0450965Z Author       : Microsoft Corporation
2017-08-17T12:41:58.0450965Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2017-08-17T12:41:58.0450965Z ==============================================================================
2017-08-17T12:41:59.0281251Z SYSTEMVSSCONNECTION exists true
2017-08-17T12:41:59.0301257Z Saving NuGet.config to a temporary config file.
2017-08-17T12:41:59.0361254Z [command]d:\a\_tool\NuGet\4.1.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile d:\a\3\Nuget\tempNuGet_3735.config
2017-08-17T12:41:59.9570375Z Package Source with Name: NuGetOrg added successfully.

2017-08-17T12:42:38.4875131Z C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Package Microsoft.AspNetCore 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj]
2017-08-17T12:42:38.4885106Z C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Package Microsoft.Extensions.Logging 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.Logging 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj]
2017-08-17T12:42:38.4885106Z C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : One or more packages are incompatible with .NETCoreApp,Version=v2.0. [d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj]
2017-08-17T12:42:38.5415101Z   Generating MSBuild file d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\obj\MiddleWare.External.Platform.csproj.nuget.g.props.
2017-08-17T12:42:38.5425105Z   Generating MSBuild file d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\obj\MiddleWare.External.Platform.csproj.nuget.g.targets.
2017-08-17T12:42:38.5435105Z   Writing lock file to disk. Path: d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\obj\project.assets.json
2017-08-17T12:42:38.5665099Z   Restore failed in 7.81 sec for d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj.
2017-08-17T12:42:38.5677221Z   
2017-08-17T12:42:38.5677221Z   Errors in d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj
2017-08-17T12:42:38.5677221Z       Package Microsoft.AspNetCore 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-08-17T12:42:38.5677221Z       Package Microsoft.Extensions.Logging 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.Logging 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-08-17T12:42:38.5677221Z       One or more packages are incompatible with .NETCoreApp,Version=v2.0.
2017-08-17T12:42:38.5705100Z   
2017-08-17T12:42:38.5705100Z   NuGet Config files used:
2017-08-17T12:42:38.5705100Z       d:\a\3\Nuget\tempNuGet_3735.config
2017-08-17T12:42:38.5705100Z   
2017-08-17T12:42:38.5705100Z   Feeds used:
2017-08-17T12:42:38.5705100Z       https://api.nuget.org/v3/index.json
2017-08-17T12:42:38.5805112Z   
2017-08-17T12:42:38.5805112Z   Installed:
2017-08-17T12:42:38.5815106Z       11 package(s) to d:\a\3\s\ESB.MiddleWare\MiddleWare.External.Platform\MiddleWare.External.Platform.csproj
2017-08-17T12:42:38.6115102Z ##[error]Error: d:\a\_tool\dncr\2.0.0\x64\dotnet.exe failed with return code: 1
2017-08-17T12:42:38.6115102Z ##[error]Packages failed to restore
2017-08-17T12:42:38.6145100Z ##[section]Finishing: Restore

@bryanmacfarlane Just tried it and it didn't work https://gist.github.com/chris31389/85f1abfa5d2c8802c6274b32fa9f6095

Had this issue after upgrading a project from 1.1 to 2.0.

Fixed it by adding a ".NET Core Tool Installer" task at the beginning of the build and specifying "2.0.0" as the version.

capture

Looks like 2.0 is not installed on all the build images yet.

@chrispoulter That worked! I didn't realise there was a dropdown where I had to select the SDK. All this time I had been running the tool installer installing just the runtime.

Thanks for your help @bryanmacfarlane

NP! We will get that fixed where SDK is the default. This is the "tool" installer :)

@bryanmacfarlane, @chrispoulter Thanks for your help! That worked for us too

Above advice allowed me to get further along thank you, but was still getting weird (to me) NuGet issues

Found this which got me going! Might help someone else https://stackoverflow.com/questions/45717283/vsts-build-packages-failed-to-restore-unable-to-resolve-netstandard-library

i thought this was going to be fixed last week with new image of Hosted 2017 ?!

We started rolling late last week. By EOD it will be in 3 of 4 rings.

Was this page helpful?
0 / 5 - 0 ratings