Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

.NET Standard 2.0 is final #439

Closed
terrajobst opened this issue Aug 9, 2017 · 89 comments
Closed

.NET Standard 2.0 is final #439

terrajobst opened this issue Aug 9, 2017 · 89 comments

Comments

@terrajobst
Copy link

terrajobst commented Aug 9, 2017

Summary

.NET Standard 2.0 is final.

You can now start producing .NET Standard 2.0 libraries and NuGet packages. Please use the latest .NET Core 2.0 Preview 2 as it contains many improvements that were necessary to provide a good experience.

Details

  • Bigger API Surface: We have more than doubled the set of available APIs from 13k in .NET Standard 1.6 to 32k in .NET Standard 2.0. Most of the added APIs are .NET Framework APIs. These additions make it much easier to port existing code to .NET Standard, and, by extension, to any .NET implementation of .NET Standard, such as .NET Core 2.0 and the upcoming version of UWP.

  • .NET Framework compatibility mode: The vast majority of NuGet packages are currently still targeting .NET Framework. Many projects are currently blocked from moving to .NET Standard because not all their dependencies are targeting .NET Standard yet. That's why we added a compatibility mode that allows .NET Standard projects to depend on .NET Framework libraries as if they were compiled for .NET Standard. Of course, this may not work in all cases (for instance, if the .NET Framework binaries uses WPF), but we found that 70% of all NuGet packages on nuget.org are API compatible with .NET Standard 2.0, so in practice it unblocks many projects.

  • Broad platform support. .NET Standard 2.0 is supported on the following platforms:
    • .NET Framework 4.6.1
    • .NET Core 2.0
    • Mono 5.4
    • Xamarin.iOS 10.14
    • Xamarin.Mac 3.8
    • Xamarin.Android 7.5
    • UWP is work in progress and will ship later this year.

Tooling Prerequisites

In general, make sure you run the latest version of the tooling:

  • .NET Core SDK. You always need to install .NET Core 2.0 Preview 2. This also includes the CLI (dotnet) for building packages, so if you only want to use the CLI, you can stop here.
  • Visual Studio. If you want to use Visual Studio for authoring .NET Standard 2.0 libraries, you also need to install Visual Studio 2017 15.3. Make sure to use 15.3 and not an earlier version, as this release addressed a couple of key issues to provide a good experience.
  • Visual Studio for Mac. The latest version of Visual Studio for Mac supports building .NET Standard 2.0 libraries.
  • Rider. The latest version also has support for .NET Standard 2.0.

Learn more by reading the .NET Standard FAQ.

@TylerBrinkley
Copy link

Is Visual Studio 15.3 RTM to be released in tandem?

@VeselovAndrey
Copy link

Please use Visual Studio 2017 15.3 to produce .NET Standard 2.0 libraries.

Only 15.3 preview available now. And if you read 15.3 preview release notes:

This release is not "go-live" and not intended for use on production computers or for creating production code.

Sounds like at this time we can produce .NET Standard 2.0 libraries for internal tests only.

@terrajobst
Copy link
Author

terrajobst commented Aug 9, 2017

@VeselovAndrey

The warning is standard boilerplate for unsupported previews and doesn't apply to the production of .NET Standard libraries. We're using this version of VS to build our stable bits too, so I wouldn't worry about it in this particular context.

@terrajobst
Copy link
Author

@TylerBrinkley

Is Visual Studio 15.3 RTM to be released in tandem?

To quote Ron Gilbert "Soon. On the 17th of soon" 😄

@MJomaa
Copy link

MJomaa commented Aug 9, 2017

FYI .NET Core 2 will be released on the 18th or 19th of September live during DEVintersection Europe.

Source:
https://www.youtube.com/watch?v=fGxGeP7b8j0
https://www.devintersectioneurope.com

@ncsurfus
Copy link

ncsurfus commented Aug 9, 2017

Awesome! Great job guys!

@bondarenkod
Copy link

Is it OK now to use it for XF?

@jeroenheijmans
Copy link

Nice, good job yall!

One question though, if I look at the diff between 1.6 and 2.0 I see quite at the top:

+    public sealed class AppDomain : MarshalByRefObject {
+        public string BaseDirectory { get; }
+        public static AppDomain CurrentDomain { get; }
+        public string DynamicDirectory { get; }
// etc...

Did I miss some announcement about AppDomain getting back in there? A typical search still yields mostly info on that it will not be there. Using a ""previous month" search doesn't give much more. The SO post about it also still suggests it's out.

I'm sure that I'm missing something obvious, and I hope this is the correct place to ask about this. Any input welcome.

@danmoseley
Copy link
Member

@jeroenheijmans yes the AppDomain class is in .NET Standard 2.0 (excluding some members snipped because they had problematic dependencies: remoting, CAS, ref emit).

Also yes .NET Core does not support secondary AppDomains so it's implementation of .NET Standard 2.0 will throw PlatformNotSupportedException or similar for some members.

Generally where a platform declares support for .NET Standard x it should fully implement it since this is the purpose of making a standard: and this is true in the vast majority of cases but there are always platform specific limitations such as secondary appdomains in the case of .NET Core that will bleed through the API in a few cases.

@terrajobst
Copy link
Author

terrajobst commented Aug 9, 2017

@jeroenheijmans

Did I miss some announcement about AppDomain getting back in there?

It's listed in our FAQ for quite some time.

I hope this is the correct place to ask about this. Any input welcome.

Yes, this is the right place to ask about all things .NET Standard.

@jeroenheijmans
Copy link

@danmosemsft Thx for the answer!

@terrajobst Also thx for the link. As I mentioned, I was already afraid that I had missed that. Apologies for not reading the FAQ first, I shouldn't have relied only on a Google search turning up that info.

@kspearrin
Copy link

.NET Framework compatibility mode: The vast majority of NuGet packages are currently still targeting .NET Framework. Many projects are currently blocked from moving to .NET Standard because not all their dependencies are targeting .NET Standard yet. That's why we added a compatibility mode that allows .NET Standard projects to depend on .NET Framework libraries as if they were compiled for .NET Standard. Of course, this may not work in all cases (for instance, if the .NET Framework binaries uses WPF), but we found that 70% of all NuGet packages on nuget.org are API compatible with .NET Standard 2.0, so in practice it unblocks many projects.

Is there anything special you have to do to get this to work? I have a project targeting 461 and netcoreapp2.0 and have not been able to reference 3 different nuget libraries that I've tested so far.

@terrajobst
Copy link
Author

terrajobst commented Aug 9, 2017

@jeroenheijmans

No worries. It's a fast moving world on GitHub and following us can be confusing for sure :-)

@terrajobst
Copy link
Author

@kspearrin

What tool are you using? Both VS and CLI should work, assuming you're running the latest versions (VS 15.3 and .NET Core 2.0 Preview 2). What's the error you're getting?

@kspearrin
Copy link

@terrajobst VS 2017. Tried installing Microsoft.Azure.NotificationHubs. Same issue with YubicoDotNetClient.

image

Microsoft Visual Studio Enterprise 2017 Preview (2)
Version 15.3.0 Preview 6.0
VisualStudio.15.Preview/15.3.0-pre.6.0+26724.1
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Visual Basic 2017   00369-60000-00001-AA734
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA734
Microsoft Visual C# 2017

Visual F# 4.1   00369-60000-00001-AA734
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30718.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017   15.0.30718.0
ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50601.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30719.0
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio   2.2.9000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.9000.0
Microsoft Azure Data Lake Tools for Visual Studio

Commit Formatter   1.0
Adds automatic word wrap to the Git commit message textbox.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

Indent Guides   15
Indent Guides

Adds visual guides at each indentation level.

JavaScript Language Service   2.0
JavaScript Language Service

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50712.2

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   4.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Redgate ReadyRoll   1.14.2.3918
Extend DevOps processes to your SQL Server databases and safely automate database deployments.
    
Visit https://www.red-gate.com/readyroll for more information.

Copyright (C) 2011 Red Gate Software Ltd. All rights reserved.
  
This software contains components from Component Owl.
SQL Server is a registered trademark of Microsoft Corporation. 
Visual Studio is a registered trademark of Microsoft Corporation. 

ReadyRoll contains code from the following open source software:

NuGet https://www.nuget.org/
SQL LocalDB Wrapper https://github.com/martincostello/sqllocaldb
Autofac https://autofac.org/
Json.NET https://json.net/
MahApps.Metro http://mahapps.com/
SemVer https://github.com/maxhauser/semver
Log4Net http://logging.apache.org/log4net/
Extended WPF Toolkit https://wpftoolkit.codeplex.com/
Code InfoBox VSX http://www.codeproject.com/Articles/55196/Code-InfoBox-Visual-Studio-Extension-VSX
OctoPack https://github.com/OctopusDeploy/OctoPack
SQLite https://sqlite.org/

This product contains icons from http://www.visualpharm.com distributed under a free backlink license.

For license details or other notices relating to the above software, please see NOTICE.TXT and EULA.rtf in the ReadyRoll application folder.
    

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

TypeScript   2.3.4.0
TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

WebJobs Tools v1.0.0   __RESXID_PRODUCTVERSION__
WebJobs Tools v1.0.0

@andrewlock
Copy link

Is there any way of opting out of the compatibility shim? What If I want it to be netstandard all the way down the dependencies, without the risk of pulling in a 461 dependency that isn't actually compatible?

Currently, the fact that I can happily reference and build with packages that aren't actually supported makes the process of building netstandard projects worse, not better for me. Previously (in < 2.0 days) I could reference a package, and if it wasn't supported, I'd get an error. Now, with the compat shim, I have to spend all my time trawling around nuget.org to check the dependencies, and see if each package I reference has a netstandard version (and hope that their dependencies don't rely on the compat shim and some unsupported api).

On top of that, the inclusion of AppDomain etc in netstandard means that even if you do avoid the compat shim, you could still end up with runtime PlatformNotSupportedExceptions from some dependency that supports netstandard but isn't cross platform! I know there was a trade off here, and the goal was to make it as easy to port to netstandard as possible, but this seems like it doesn't help with the goal of building cross platform apps. Runtime exceptions are the worst, so why make them a common and expected problem!?

Overall, 2.0 is great, especially if I can disable the compat shim (potentially selectively). But the incompatibilities between platforms will makes a concept that many people are already having some difficult understanding even harder to fathom.

@dasMulli
Copy link

The implicit .NET 4.6.1 package compatibility can be turned off by setting this property in your project file (inside of a PropertyGroup):

<DisableImplicitAssetTargetFallback>true</DisableImplicitAssetTargetFallback>

@terrajobst
Copy link
Author

terrajobst commented Aug 10, 2017

@kspearrin

The behavior you observe is correct and the compat shim is working as designed. Whenever you use NuGet packages that go through the compat shim you'll get a warning like this:

Warning NU1701: Package 'Huitian.PowerCollections 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

We've made sure you get this warning every time you build (rather only during package restore) to ensure you don't accidentally overlook it.

The idea here is that we have no way of knowing whether the .NET Framework binary will actually work. For example, it might depend on WinForms. To make sure you don't waste your time troubleshooting something that cannot work, we let you know that you're potentially going off the rails. Of course, warnings you have to overlook are annoying. Thus, we recommend that you test your application/library and if you're convinced everything is working fine, you suppress the warning:

image

In the project file this looks as follows:

<ItemGroup>
  <PackageReference Include="Huitian.PowerCollections" Version="1.0.0" NoWarn="NU1701" />
</ItemGroup>

Note that the suppression isn't global but per package reference. This ensures that just using one library through the compat shim doesn't result in a free ride for all future references. If you install another library that goes through the compat shim, you'll get another warning.

@terrajobst
Copy link
Author

@andrewlock

Is there any way of opting out of the compatibility shim? What If I want it to be netstandard all the way down the dependencies, without the risk of pulling in a 461 dependency that isn't actually compatible?

See my comment above; we make sure to tell you when you're consuming a library through the compat shim. I wouldn't bother turning it off and rather follow good hygiene and ensure you build with zero warnings.

@kspearrin
Copy link

@terrajobst Great. I guess I incorrectly assumed that the warning meant it just wasn't going to work. Glad to know. :)

@JaredShaver
Copy link

I am a little confused as to why the .NET Framework 4.7.1 Preview announcement https://blogs.msdn.microsoft.com/dotnet/2017/08/07/welcome-to-the-net-framework-4-7-1-early-access/ lists ".NET Framework support for .NET Standard 2.0" as a feature if it's already supported by .NET Framework 4.6.1. Can someone clarify what this means?

@terrajobst
Copy link
Author

@JaredShaver

Can someone clarify what this means?

Great question. Here is the deal: .NET Framework 4.6.1 has shipped before we built .NET Standard 2.0. While .NET Framework 4.6.1 supports the API surface of .NET Standard 2.0, it does require extra DLLs that need to be deployed by the application. This includes, for instance, netstandard.dll. Starting with .NET Framework 4.7.1, the .NET Standard support files will be shipped with the framework so that applications don't need to carry any extra files.

@JaredShaver
Copy link

@terrajobst That makes sense. Thank you for the explanation.

@harvinders
Copy link

Broad platform support. .NET Standard 2.0 is supported on the following platforms:

  • .NET Framework 4.6.1
  • .NET Core 2.0
  • Mono 5.4
  • Xamarin.iOS 10.14
  • Xamarin.Mac 3.8
  • Xamarin.Android 7.5
  • UWP is work in progress and will ship later this year.

@terrajobst What does that mean for UWP? Would we be limited to accessing .net standard 2.0 libraries from UWP apps targeting Fall Creators Update? Or would we be able to also target Anniversary Update?

@terrajobst
Copy link
Author

terrajobst commented Aug 11, 2017

AFAIR .NET Standard 2.0 will only be available for FCU and up. Reason being that we needed OS changes to make the added API surface work.

@danmoseley
Copy link
Member

@terrajobst is correct.

@GeertvanHorrik
Copy link

@terrajobst / @danmosemsft And backported to mobile "feature2"? Or will the combo of Win10M and .NET standard be a no-go?

@terrajobst
Copy link
Author

@GeertvanHorrik

We're trying to get an answer. Stay tuned.

@branko19
Copy link

Lynda - Building Web APIs with ASP NET Core_Chris_Wodruff

@Petermarcu
Copy link
Member

Also what is your Visual Studio version if you go to help->about?

@Petermarcu
Copy link
Member

I dont have access to that training. Can you paste the contents of your project file here so I can see what you are doing?

@branko19
Copy link

Also what is your Visual Studio version if you go to help->about? 15.40

@branko19
Copy link

sorry 15.4.0

@Petermarcu
Copy link
Member

Ok, that should be good with the .NET Core 2.0 SDK installed. Then if you do File->New Project and choose and ASP.NET Web API, can you build that app successfully?

@branko19
Copy link

dotnet new console
first time is it was written restore
but dotnet run have 100 pages of errors
dotnet new console
second time
Return the command and pass --force to accept and create

@branko19
Copy link

image

@branko19
Copy link

Ok your advice is to switch to ASP.NET Web API insted of core.

@Petermarcu
Copy link
Member

I wasn't meaning to get off of .NET Core. I should have said ASP.NET Core Web API.

I'm wondering if your NuGet cache somehow got corrupted. Can you try

dotnet nuget locals all –clear

Definitely looks like something is going on with restore.

Something else that is weird is the errors you are getting. There are references to System.Windows.Forms which would not exist in a normal ASP.NET project at all. That doesn't look right at all. I'm not sure how you created that project. Did you copy it from somewhere or was it through Visual Studio?

@branko19
Copy link

from command line i try from NuGet Package Manager >> Package manager console
but it it does not work there

@branko19
Copy link

dotnet nuget locals all –clear
image
image
First time I use dotnet cli sorry my flow

@branko19
Copy link

Even webapi template work with dotnet cli thank yooooooooooou very much :) :) :)

@Petermarcu
Copy link
Member

Ah great! That is a nasty bug in NuGet that I've seen numerous people hitting. Glad you are fixed now!

@Petermarcu
Copy link
Member

FYI - I think is this bug but may not be exactly that issue. NuGet/Home#5995

@branko19
Copy link

Petermarcu I do not know how to thank you !

@cassandragrace
Copy link

Regarding the guidance @terrajobst for using NoWarn - I'm seeing it work for top-level packages, but not their dependencies. I have a netcoreapp2.0 ASP.NET Core Web API and am working on getting it hosted in Service Fabric. Turns out there's an open issue for this: NuGet/Home#5740 in case anyone else runs into the same issue. The example I'm running into is below:

<PackageReference Include="Microsoft.ServiceFabric" Version="6.0.219" NoWarn="NU1701" />
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.WebListener" Version="2.8.219" NoWarn="NU1701" />
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="2.8.219" NoWarn="NU1701" />

Results in this view:
image

@MagicAndre1981
Copy link

How can I use .net standard 2.0 in UWP that allows targeting Win10 mobile? With FCU as target and minimum I get this message:

DEP3321: To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.16299.0 or higher. You currently are running version 10.0.15254.158. Please update your OS, or change your deployment target to a device with the appropriate version

Changing Min version to 15063 breaks .net standard 2.0 support:

Error Project '..\App.csproj' targets 'netstandard2.0'. It cannot be referenced by a project that targets 'UAP,Version=v10.0.15063'. App.UWP C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1601

🤷‍♂️

@GeertvanHorrik
Copy link

@MagicAndre1981 been waiting for an answer from the .NET team for about 4 months now. Crickets... so I think we need to draw our own conclusions here :-(

@MagicAndre1981
Copy link

@GeertvanHorrik ok, so we can wait forever 🤦‍♂️

@weshaggard
Copy link
Member

@MagicAndre1981 unfortunately .NET Standard 2.0 requires a minimum of 10.0.16299 (see https://blogs.msdn.microsoft.com/dotnet/2017/10/10/announcing-uwp-support-for-net-standard-2-0/), and you need to be running that version of the OS in order to deploy and run that version of an application.

@GeertvanHorrik sorry about not getting an answer, I don't have enough context to provide a full answer for that because I don't know how Win10M and UWP connect. Assuming Win10M is a target for UWP 16299 then .NET Standard will be available otherwise I don't believe it will support it.

@GeertvanHorrik
Copy link

@weshaggard Thanks for trying to answer the question.

Win10M is on a separate "feature" (what a name) branch and stuck on 10.0.15254.x. There were rumors about backporting newer API to at least make it possible to use .NET Standard 2.0 / keep targeting mobile users as well. I, as one of the users that are targeting Microsoft products because marketing told us to do so would like to know whether we should stop investing in Win 10 Mobile (and maybe UWP in general, for me personally it makes no sense to do anything in UWP if mobile is not part of the equation).

Thanks!

@weshaggard
Copy link
Member

There were rumors about backporting newer API to at least make it possible to use .NET Standard 2.0

Not to say there isn't but I'm not aware of any work to make .NET Standard 2.0 work there.

@MagicAndre1981
Copy link

@GeertvanHorrik the wired thing is that Microsoft does have a full 16xxx Build targeting the phone, but they simply want to f*ck up with all users and never want to release it to the public:

https://www.youtube.com/watch?v=YNxtMtlrm6U

This was captured last year, when MS accidental released Build 16212.1001 for Fast Ring mobile users. The user got it working on the HP Elite x3 and you see a UI that is like the full Windows 10 and has better Continuum support by providing Windows support on Continuum, which is much better compared to current full screen only.

So there are 3 ways this issue continues:

  1. Microsoft releases 16299 for current phones so that UWP finally makes sense

  2. Microsoft updates the crappy "Feature2" branch to allow .net standard 2.0 support

  3. Microsoft continues to ignore what users want and never give any official statement (most likely option to happen)

  4. Hackers provide a CustomROM of Build >= 16299 for current phones, so that it would work. Currently they stuck on missing drivers for touchscreen with the 170xx Builds

grafik

@Matt-17
Copy link

Matt-17 commented Jun 29, 2018

Without Windows 10 Mobile this is still a no go for me. What is right now the best configurations (and version numbers) for supporting Android and Windows 10 Mobile (15063) in a Xamarin.Forms app? Otherwise this whole thing does not make sense for me anymore. :-(

@MagicAndre1981
Copy link

@Matt-17

use old PCL and MinVersion to Build 15063 (because last is mobile is 15254.Patchlevel).

@GeertvanHorrik

Strange thing is, under C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\Microsoft.NETCore.UniversalWindowsPlatform\6.1.5\ref\uap10.0.15138 I see a netstandard.dll version 2.0 and this build number is lower than last Win10 mobile feature2 versions, so it could have .net standard 2.0 support. Xamarin also plays with this 15138

@MarcoB1234
Copy link

@terrajobst

The behavior you observe is correct and the compat shim is working as designed. Whenever you use NuGet packages that go through the compat shim you'll get a warning like this:

Warning NU1701: Package 'Huitian.PowerCollections 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

Does the same warning show up if the library is referenced not as Nuget package but via Add Project Reference... in VStudio or by browsing to a .dll on disk?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests