.NET Core - 未找到框架 "DNXCore,Version=v5.0" 的参考程序集

.NET Core - The reference assemblies for framework "DNXCore,Version=v5.0" were not found

将 .NET 核心库 (DNXCore50) 从 VS 2015 迁移到 VS 2017 时出现此错误。

The reference assemblies for framework "DNXCore,Version=v5.0" were not found.

我的项目文件当前如下所示:(在 VS 2017 迁移向导将我的 "project.json" 迁移到 .csproj 文件之后)

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <Description>An FTP and FTPS library for .NET, optimized for speed. Provides extensive FTP commands, file uploads/downloads, SSL/TLS connections and FTP proxies.</Description>
    <VersionPrefix>16.3.0</VersionPrefix>
    <Authors>J.P. Trosclair;Harsh Gupta</Authors>
    <TargetFrameworks>netstandard1.6;dnxcore50</TargetFrameworks>
    <DefineConstants>$(DefineConstants);CORE</DefineConstants>
    <RootNamespace>FluentFTP</RootNamespace>
    <AssemblyName>FluentFTP</AssemblyName>
    <OutputType>Library</OutputType>
    <PackageId>FluentFTP</PackageId>
    <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
    <TargetFrameworkIdentifier>DNXCore</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
    <GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.IO" Version="4.3.0.0" />
    <PackageReference Include="System.Net.NameResolution" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Sockets" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Security" Version="4.3.0.0" />
  </ItemGroup>

</Project>

我在编译时遇到上述错误。我尝试过的事情:

我应该使用什么来代替 DNXCore 5.0?我需要最新的 API,例如 TlsStreamUri,这些东西不存在或者有没有办法强制编译器编译?请注意,当我使用 VS 2015 进行编译时,这是一个工作库。现在我已经切换到 VS 2017,我无法再编译我的项目了!在 .NET Core 或 .NET Portable 中。

嗯,真令人惊讶!

我的库使用 .NETStandard v1.6!

成功编译

包括我的 XML 以防其他人遇到此问题:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <Description>An FTP and FTPS library for .NET, optimized for speed. Provides extensive FTP commands, file uploads/downloads, SSL/TLS connections and FTP proxies.</Description>
    <VersionPrefix>16.3.0</VersionPrefix>
    <Authors>J.P. Trosclair;Harsh Gupta</Authors>
    <TargetFrameworks>netstandard1.6;dnxcore50</TargetFrameworks>
    <DefineConstants>$(DefineConstants);CORE</DefineConstants>
    <RootNamespace>FluentFTP</RootNamespace>
    <AssemblyName>FluentFTP</AssemblyName>
    <OutputType>Library</OutputType>
    <PackageId>FluentFTP</PackageId>
    <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
    <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v1.6</TargetFrameworkVersion>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
    <GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.IO" Version="4.3.0.0" />
    <PackageReference Include="System.Net.NameResolution" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Sockets" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Security" Version="4.3.0.0" />
  </ItemGroup>

</Project>

dnxcore50 不再用作 TargetFramework。您可以看到 1.1.0 documentation for netstandard 将其列为已弃用的绰号。

有关最新的 .NET Standard 文档,请参阅 .NET Standard FAQ

你可以完全放弃第二个 TFM。 netstandard1.6 将在 .NET Core 上正常工作。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <Description>An FTP and FTPS library for .NET, optimized for speed. Provides extensive FTP commands, file uploads/downloads, SSL/TLS connections and FTP proxies.</Description>
    <VersionPrefix>16.3.0</VersionPrefix>
    <Authors>J.P. Trosclair;Harsh Gupta</Authors>
    <TargetFramework>netstandard1.6</TargetFramework>
    <DefineConstants>$(DefineConstants);CORE</DefineConstants>
    <RootNamespace>FluentFTP</RootNamespace>
    <AssemblyName>FluentFTP</AssemblyName>
    <OutputType>Library</OutputType>
    <PackageId>FluentFTP</PackageId>
    <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
    <GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.IO" Version="4.3.0.0" />
    <PackageReference Include="System.Net.NameResolution" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Sockets" Version="4.3.0.0" />
    <PackageReference Include="System.Net.Security" Version="4.3.0.0" />
  </ItemGroup>

</Project>

我还删除了 TargetFrameworkIdentifierTargetFrameworkVersion 的设置,因为这些属性是从 TargetFramework 推断出来的。