如何在VS 2017 RC中创建针对.NET Framework 4.5.1和.NET Standard 1.3的库? [英] How should I create a library targetting .NET Framework 4.5.1 and .NET Standard 1.3 in VS 2017 RC?

查看:176
本文介绍了如何在VS 2017 RC中创建针对.NET Framework 4.5.1和.NET Standard 1.3的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试不仅仅针对.NET Framework的目标.我似乎无法从GUI做到这一点.我尝试过项目类型为类库(便携式)"和项目类型为类库(.NET标准)".我可以将类库(便携式)"更改为目标.NET Standard,但随后我无法选择其他任何内容.我不确定是否应该尝试更改类库(.NET标准)"的.csproj或类库(可移植)"的project.json,我只是想要最能适应未来发展的内容.

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.

推荐答案

几天前,.csproj进行了简化,易用性得到了改善.使用最新版本的VS 2017 RC,我通过创建一个新的类库(.NET Standard)"来创建这样的库,该库具有默认的.csproj:

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>

然后我手动编辑它(我看不到通过UI进行编辑的方法):

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>

项目的属性"窗格下的目标框架"下拉菜单将变为灰色.通过构建,您可以在bin \ Debug下验证单独的netstandard1.3和net452文件夹.如果要在构建中创建NuGet软件包,请注意以下问题,这可能会误导您以为您做错了什么:

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.

这篇关于如何在VS 2017 RC中创建针对.NET Framework 4.5.1和.NET Standard 1.3的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆