netcoreapp1.0中的参考FrameworkAssembly

时间:2016-05-20 09:21:38

标签: c# .net-core

在仅运行Windows的netcoreapp上引用完整框架程序集(如System.DirectoryServices.AccountManagement)的首选方法是什么?

dnx支持这种方式:

 "frameworks": {
    "dnx451": {
      "frameworkAssemblies": {
        "System.DirectoryServices.AccountManagement": "4.0.0.0",
        "System.Messaging": "4.0.0.0",
        "System.Runtime.Serialization": "4.0.0.0"
      }
    }
  },

并使用netcore将其更改为:

 "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": "dnxcore50"
    }
  }

1 个答案:

答案 0 :(得分:3)

使用frameworkAssemblies仍适用于我。

如果要直接从ASP.NET Core应用程序使用程序集,那么project.json将如下所示:

"dependencies": {
  "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final"
},

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
      "System.DirectoryServices.AccountManagement": "4.0.0.0"
    }
  }
},

如果你想通过类库间接进行,那么类库中的project.json将如下所示:

"dependencies": {
  "NETStandard.Library": "1.5.0-rc2-24027"
},

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
      "System.DirectoryServices.AccountManagement": "4.0.0.0"
    }
  }
}

在应用程序中(假设类库名为ClassLibrary):

"dependencies": {
  "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
  "ClassLibrary": "1.0.0-*"
},

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