Jonas Stensved
Jonas Stensved

Reputation: 15286

VSTS fails with Visual Studio Build when net461 is referencing netstandard2.0

We're migrating a library project to netstandard2.0 from net461. Some libraries doesn't support .NET Standard yet so the hosting application is runnning net461 and are referencing our libraries that use netstandard2.0.

This works perfectly locally with Visual Studio 15.3 where everything runs and builds.

According to the Microsoft documentation .NET Standard with SDK 2.0 implements 4.6.1 which I assume is why it works locally.

.NET Standard support

When running build in Visual Studio Online (VSTS) fails with multiple errors like:

Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)

I read up on github discussions here and here that talks about similar problems being a tooling issue and added a .NET Core Tool Installer task to build that installs Core 2.0 but still with no luck.

What do I need to do to get build working in VSTS?

UPDATE:

(Changed title to Visual Studio Build instead of MS Build)

Found this thread https://github.com/dotnet/standard/issues/454 talking about the VSTS needing an update.

I'm running VS Enterprise 15.4.1, VSTS Build is running version 15.3.5 today which is enough according to the issue on github. This is even more confusing.

Upvotes: 3

Views: 755

Answers (1)

Jonas Stensved
Jonas Stensved

Reputation: 15286

Found a workaround by using dotnet restore and dotnet build with version 2.* (preview) which works perfectly.

Instead of using MS Build or Visual Studio 2017 build, just replace the build tasks with the following dotnet tasks.

(If you don't have any private feeds you don't even need the dotnet restore command since dotnet build will restore packages for you).

TL;DR; use this instead:

Working build tasks

Upvotes: 2

Related Questions