asp.net-core – 如何在VS2017 final中定位多个框架?

前端之家收集整理的这篇文章主要介绍了asp.net-core – 如何在VS2017 final中定位多个框架?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对于ASP.NET Core,我可以在一个Project.json中定位多个框架(例如netcoreapp1.1和dnx451):
"frameworks": {
   "netcoreapp1.1": {
     "dependencies": {
       "Microsoft.NETCore.App": {
         "version": "1.1.0","type": "platform"
       }
     },"imports": [
       "dotnet5.6","portable-net45+win8"
     ]
   },"dnx451": {}
 },

在Visual Studio 2017的最终版本中,我只能定位netcoreapp1.1或dnx451,但我认为无法同时定位两者.@H_403_5@

我尝试直接编辑csproj文件以通过设置< TargetFramework> netcoreapp1.1; dnx451< / TargetFramework>来添加第二个框架.甚至< TargetFrameworks> netcoreapp1.1; dnx451< / TargetFrameworks>但由于框架不受支持,在Visual Studio中会出现错误.@H_403_5@

那么如何在Visual Studio 2017的最终版本中的一个项目中同时定位netcoreapp1.1和dnx451?@H_403_5@

解决方法

你需要改变一些事情.首先< TargetFrameworks>标签是多目标的正确标签;是分隔符.

在RC2的开发过程中不推荐使用DNX,因此支持DNX的最新版本是RC1. dnxcore5x(以及后来的dotnet5.x)名字用netstandard1.x(对于类库)和netcoreapp1.x替换为应用程序. dnx4xx作为一个整体被弃用,应该使用net4xx.@H_403_5@

此外,当您定位.NET Framework(单独或使用.NET Core / NetStandard)时,您将需要定义运行时标识符:@H_403_5@

<RuntimeIdentifier>win7-x86</RuntimeIdentifier>

要么@H_403_5@

<RuntimeIdentifier>win7-x64</RuntimeIdentifier>

或者您想成为默认值.@H_403_5@

更新@H_403_5@

仅作为附加信息.当您定位多个平台时,您需要使用条件来解析包,即Condition =“’$(TargetFramework)’==’< targetmoniker>‘@H_403_5@

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1'">
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.0.1</Version>
    </PackageReference>
</ItemGroup>

否则,您可能会收到包恢复错误@H_403_5@

原文链接:https://www.f2er.com/aspnet/251420.html

猜你在找的asp.Net相关文章