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

查看:141
本文介绍了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": {
    }
  }

并抛出The dependency mscorlib could not be resolved.

但是,如果我使用旧模板(没有project.json)创建一个项目,并将其添加为对dotnet核心项目的引用.效果很好.

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天全站免登陆