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.
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.
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:
Related
I am building a netstandard2.0, with a series of sub-dependencies, including Azure.Data.Tables. I have found that Azure.Data.Tables on >=12.3.0 is not compatible with 2.2 projects, but version 12.0.0 is (or at least it doesn't crash my .Net Core 2.2 application).
Based on these premises the resolution was simple: put version 12.0.0 in the netstandard library dependencies. There's only one problem, that when I install this library using Visual Studio into my Net Core 2.2 project I get that visual studio decides to install 12.3.0.
I have checked documentation around enforcing certain versions using the allowed wildcards(https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges-and-wildcards), such as:
<PackageReference Include="Azure.Data.Tables" Version="[12.0.0]" />
Which produces this package description just before pressing "install".
But it doens't seem to work, Visual Studio simply carries on with the 12.3.0 installation.
It turns out Visual Studio was just using the nuget cache for my locally generated packages. If I either changed the version of the packaged package then the sub-dependencies would change. As well, another way of getting the precise package would be to clear nuget's cache locally: nuget locals all -clear.
Project Setup : Mixed framework solution
.Net Framework 4.6.2 projects in solution : 15
.Net Standard 2.0 projects in solution - 1
Development Machine
Visual Studio 2017(15.7.4) : Builds without any errors
Build Server
TeamCity Version 2017.1.3
Build Steps
Nuget Restore(3.4.4)
dotnet Restore
MSBuild( Build Tools 2017), Tools Version 15.0
Build fails with following error in the .net standard 2.0 project : [ResolvePackageAssets] C:\Program Files\dotnet\sdk\2.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198, 5): Package System.Security.Cryptography.ProtectedData, version 4.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
What's interesting is I can't find reference or use of System.Security.Cryptography.ProtectedData anywhere in the project. Any help is greatly appreciated.
P.S - Can't use dotnet build, as the solution needs building of licenses.licx files, and the component which builds it (Microsoft.Build.Tasks.LC) is not ported to .Net Core. The suggestion from various posts was to use MsBuild.exe
When I try to upgrade ASP.NET Core in Nuget package manager, I get the following error:
Severity Code Description Project File Line Suppression State
Error Package Microsoft.AspNetCore.All 2.1.0-preview2-final is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore.All 2.1.0-preview2-final supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) 0
I have installed the sdk multiple times, so I'm confused because when I go to target it only has up to dotnet core 2.0 as an option. I installed visual studio preview but that hasn't helped either. Any suggestions?
For .NET Core 2.1 you need (currently) version 2.1.300-rc1 of the sdk. The version numbers of the SDK and .NET Core are not in sync, older 2.1 versions of the SDK are not enough.
This version can be downloaded from here: https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-rc1
You can check the version on command line with donet --version command. dotnet --info will also list all the installed runtimes and SDKs.
> dotnet --version
2.1.300-rc1-008673
Upgraded our ASP.Net Core project (using full .Net Framework) from .json project to .csproj format, using VisualStudio 2017, and the project builds and runs just fine locally.
From what I understand NuGet 4 is bundled with VisualStudio 2017.
Trying to build this using VisualStudioTeamServices fails on the "Nuget installer" task, as we can only select version 3.5 of NuGet for this task. (And yes, Visual Studio 2017 is installed on the build server, and the agent has been updated to have the capabilities updated)
There is an argument to enter a custom path for nuget in this task, could this be used? Or do we have to wait for an updated version of the Nuget installer build task?
If anybody else has the same problem, I figured out that we no longer need the "Nuget installer" step. Simply add "/t:restore" as an argument to MsBuild.
I have installed .NET Core 1.1 SDK and Tooling 1.0.1 Tools Preview 2.
When I create new .NET Core project using Visual Studio 2015 it creates 1.0.1 project instead of 1.1.
Not sure how to change this ugly behavior?
That's because the templates ship with Visual Studio, which haven't received an update as part of the .NET Core release. The reason for that is probably because 1.1 is a "Current" release and 1.0.1 is an "LTS" (Long Term Support) release. Visual Studio will most likely follow the LTS releases as they provide the best and most reliable support for customers.
If you create a new application with the .NET CLI tooling (e.g. dotnet new), it will use the latest version. You can specify the type of the template with the -t switch:
dotnet new: creates a console app
dotnet new -t web: creates a full-blown web app
dotnet new -t lib: creates a class library project