Saturday, July 22, 2017

Using .NET Standard 2.0.0 preview in Visual Studio

.NET Standard is the new common library for all .NET platforms (.NET Framework, .NET Core, Xamarin). There is a good introduction on the .NET Blog (https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/).
You can create a new .NET Standard project within Visual Studio 2017. Click on "Create new project...". Then you can select the .NET Standard entry to create a Class Library (.NET Standard). As .NET Framework you can choose a version equal or greater than 4.6.1 to support .NET Standard 2.0.



After creating the project, you can see under Dependencies the NETStandard.Library.



You can choose "Manage NuGet Packages..." from the context menu to have a closer look. You can see that version 1.6.1 is used, since it is the latest stable version that is compatible with the .NET Framework 4.7.



Furthermore you can see the messages "Blocked by project" and "Following versions are unavailable due to additional constraints in the project or packages.config" for version 2.0.0-preview2-25401-01 and some others.

Following entries can you see in the project file.
<Project Sdk="Microsoft.NET.Sdk"> 
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup> 
</Project>

Nevertheless you can install the 2.0 version via Package Manager Console. Just enter

Install-Package NETStandard.Library -IncludePrerelease -Version 2.0.0-preview2-25401-01

If you look again in the project file, you will see 3 lines that were added.
<Project Sdk="Microsoft.NET.Sdk"> 
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup> 
  <ItemGroup>
    <PackageReference Update="NETStandard.Library" Version="2.0.0-preview2-25401-01" />
  </ItemGroup> 
</Project>

But this will not solve the problem. .NETStandard 2.0 is not used properly. In Visual Studio 15.2 you can not choose .NERStandard 2.0.



It is supported with Visual Studio 15.3.






<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
</Project>

11 comments:

  1. As a fresher, I learned much precious information about .net from your blog, Thanks for taking time to discuss about the beauty of dot net language.
    Regards,
    DOT NET Training in Chennai|DOT NET Course in Chennai

    ReplyDelete
  2. I really appreciate your hard work an giving us some information and inspiring others to follow.
    Dot Net Online Training

    ReplyDelete
  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete
  4. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    .Net Certification Training Gurgaon

    ReplyDelete
  5. Learned a lot of new things from your post!Good creation ,It's amazing blog


    .Net Online Training Hyderabad

    ReplyDelete
  6. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    mean-stack-training-institute-in-chennai

    ReplyDelete
  7. Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
    amazon-web-services-training-in-bangalore

    ReplyDelete
  8. Your new valuable key points simply much a person like me and extremely more to my office workers. With thanks; from every one of us.
    Best selenium training Institute in chennai

    ReplyDelete
  9. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.


    python training in bangalore

    ReplyDelete

  10. Thanks for sharing this post. Your post is really very helpful its students. .Net Online course Bangalore

    ReplyDelete