简体   繁体   中英

How should I create a library targetting .NET Framework 4.5.1 and .NET Standard 1.3 in VS 2017 RC?

This is my first time trying anything that targets more than just a .NET Framework. I can't seem to do it from the GUI. I've tried project type 'Class Library (Portable)' and project type 'Class Library (.NET Standard)'. I can change a 'Class Library (Portable)' to target .NET Standard but then I can't select anything else. I'm not sure if I should try to change the .csproj of 'Class Library (.NET Standard)' or the project.json of 'Class Library (Portable)', I just want whatever is most future-proof.

As of a few days ago the .csproj has been simplified and ease of use has improved. With the latest version of VS 2017 RC, I create such a library by creating a new 'Class Library (.NET Standard)', which has this default .csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup>
</Project>

And I edit it by hand (I don't see a way to do it through the UI) to be this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.3;net452</TargetFrameworks>
  </PropertyGroup>
</Project>

The 'Target framework' drop down under the project's Properties pane then becomes grayed out. By building you can verify separate netstandard1.3 and net452 folders under bin\\Debug. Be aware of the following issue if you're creating a NuGet package on build, which may mislead you into thinking you've done something incorrectly: https://github.com/NuGet/Home/issues/4289 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM