nuget - 从面向 .Net 4.0 客户端配置文件的 Win Forms 应用程序引用由 asp.net 5 类库创建的 nuget 包

标签 nuget asp.net-core visual-studio-2015

我有一个包含对象模型的 asp.net 5 类库,我需要与面向 .Net Framework 4.0 Client Profile 的 WinForms 应用程序共享该对象模型。

我已经从 asp.net 5 类库创建了一个 Nuget 包,并尝试从 WinForms 应用程序引用这个 NuGet 包。但是,在添加引用时出现以下错误:

Could not install package 'package name 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

我尝试在我的 project.json 文件的“框架”部分中添加 DNX40 作为目标框架,如下所示。

{
  "authors": [ "author" ],
  "dependencies": {
  },
  "description": "Shared object models",
  "frameworks": {
    "dnx40": { },
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "System.Collections": "4.0.10-beta-22816",
        "System.Linq": "4.0.0-beta-22816",
        "System.Threading": "4.0.10-beta-22816",
        "Microsoft.CSharp": "4.0.0-beta-22816"
      }
    }
  },
  "licenseUrl": "",
  "projectUrl": "",
  "tags": [ "" ],
  "version": "1.0.0-*"
}

我怀疑我针对的是错误的框架版本。

但如何将 .Net Framework 4.0 Client Profile 指定为目标框架?这可能吗?

最佳答案

使用net40:

"frameworks": {
    "net40": {},
    "dnx451": { },
    "dnxcore50": {}
 }

以下是一些可能的组合:https://github.com/aspnet/dnx/blob/b0c5920b8ff0a96cac2446b1aeb8a80b3069c2ab/test/Microsoft.Framework.Runtime.Tests/VersionUtilityFacts.cs

关于nuget - 从面向 .Net 4.0 客户端配置文件的 Win Forms 应用程序引用由 asp.net 5 类库创建的 nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31177539/

相关文章:

visual-studio-2015 - 在 VS2015 中的预构建事件中从 nuget 包文件夹调用可执行文件

.net - 如何安装 MyGet 包?

.net - 查找 nuget.targets 文件的 MSBuild 错误

c# - ASP.NET Core Web API 自动 JSON 参数反序列化不起作用

c# - 从 URI 查询字符串解析字符串总是返回空值

asp.net - 如何在使用 docker 容器化的 asp.net Core 中的项目之间共享类定义

visual-studio-2010 - InstallShield 中的依赖项未得到解决

c++ - Cmake 无法识别 MSVC 编译器

c# - Visual Studio 显示 ReSharper 的 'Configure settings to improve performance' 通知

c++ - 将 ASIO 链接到项目而不在 Visual Studio 中 boost