DotNet Core RC2 项目和 Net461 依赖项解决问题 [英] DotNet Core RC2 Project and Net461 dependency resolve issue

查看:28
本文介绍了DotNet Core RC2 项目和 Net461 依赖项解决问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是主要 dotnet 核心 web 项目的 project.json

Here is the project.json for the main dotnet core web project

"frameworks": {
  "netcoreapp1.0": {        
      "imports": [
          "dotnet5.6",
          "dnxcore50",
          "portable-net45+win8",
          "net461"
      ]
  }
}

如果我添加以下 net461 类库项目作为对上述项目的引用.它不会正确构建.

If I add the following net461 class library project as a reference to above one. It won't build correctly.

 "frameworks": {
    "net461": {
    }
  }

并抛出类似依赖mscorlib无法解析的错误.

但是,如果我使用旧模板(没有 project.json)创建一个项目,并将其添加为对 dotnet core 项目的引用.它工作正常.

However, if I create a project by using the old template(no project.json), and add it as a reference to dotnet core project. It works fine.

我想知道如何解决这个问题?

I wonder how to fix this?

推荐答案

您正在做的是创建一个只能在 .Net Framework 上运行的库,然后尝试从运行在 .Net Core 上的应用程序中使用它.那行不通.

What you're doing is creating a library that will run only on .Net Framework, and then trying to use it from an application that runs on .Net Core. That won't work.

如果你想在 .Net Core 上运行,那么你的应用程序的 project.json 应该包含:

If you want to run on .Net Core, then project.json of your application should contain:

"frameworks": {
  "netcoreapp1.0": {        
      "imports": [
          "dotnet5.6",
          "dnxcore50",
          "portable-net45+win8"
      ]
  }
}

和库(netstandard 的版本将取决于您想要做什么):

And library (the version of netstandard will depend on what you want to do):

"frameworks": {
    "netstandard1.4": {
    }
}

如果您想使用 dotnet CLI,但仍要在 .Net Framework 上运行,请在您的库和应用程序中使用以下内容(您在 frameworkAssemblies 中包含框架程序集):

If you want to use dotnet CLI, but still run on .Net Framework, then have the following in both your library and application (where you include framework assemblies inside frameworkAssemblies):

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
    }
  }
}

这篇关于DotNet Core RC2 项目和 Net461 依赖项解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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