microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.72k stars 867 forks source link

Building .Net Standard 2.0 Application with Hosted VS2017 Agent #1146

Closed chris31389 closed 7 years ago

chris31389 commented 7 years ago

Hi,

When will .net standard 2.0 sdk be installed to the Hosted Agents?

Thanks, Chris

ghost commented 7 years ago

I've selected v2.0 and its still using the 1.0.4 SDK ???

Image

******************************************************************************
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]
chris31389 commented 7 years ago

@flightlevel Does the agent your using have .netstandard sdk 2.0 installed?

ghost commented 7 years ago

Is there a way to check? I'm using VSTS with the 2017 hosted build agent

chris31389 commented 7 years ago

@flightlevel I think the hosted build agent doesn't have it installed (or they haven't updated the docs yet) https://www.visualstudio.com/en-us/docs/build/concepts/agents/hosted

bryanmacfarlane commented 7 years ago

The image is in process of creating/rolling out.

Workaround: If you look under tasks, tools, there is a .net tool installer task we just released. That will pull it JIT during your build.

image

We're also working on a feature in the UI (not docs) to show "what's on this image"

chris31389 commented 7 years ago

Hi @bryanmacfarlane, thanks for your reply. I've added it to my build process. It looks like it ran with 2.0.0 but it also looks like it used the 1.0.4 package too. See below for the snippets of the logs.

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]
bryanmacfarlane commented 7 years ago

@chris31389 - it looks like it prepended the path but still called a 1.0.4 target??. Can you add an issue in the tasks repo (vsts-tasks). I'll make sure the right folks dig into it.

chris31389 commented 7 years ago

@bryanmacfarlane I'm guessing its not looking for the dotnet exe, its looking for the NuGet.targets file? Does that get installed with the runtime task?

TingluoHuang commented 7 years ago

@chris31389 what's your netstandard/netcoreapp version in your .csproj. 2.0 SDK only going to pick 2.0 stuff if you csproj target netcore 2.0 or netstandard 2.0.

chris31389 commented 7 years ago

@TingluoHuang I've just checked all my csproj's. All standard libs contain:

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

and all standard apps contain

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
MikeFoden commented 7 years ago

@chris31389 they have said they have now updated the hosted agent with .NET Core 2.0 support - https://twitter.com/VSTS/status/900134247205191680

TingluoHuang commented 7 years ago

I am going to close the issue since it's not an agent's problem, it's about the Hosted Image setup.