New .NET “project.json” project, copying pre-built native .dlls to the output directory

为君一笑 提交于 2019-12-01 21:49:57

问题


I'm looking to convert my project to use project.json format, but still using the .NET CLR until 3rd party dependencies add support for CoreCLR.

With that said, some of my NuGet dependencies of files in the "content" directory that need to be output into the bin directory of the running application.

Since project.json currently doesn't support NuGet content, I manually added the files to my project directory.

However, when I run the application, it still can't find these native assemblies. If I add these assemblies manually to .dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin, my application runs fine, so it is just a matter of these files somehow getting put into the applications PATH.

So, how do I do it? In MSBuild, there was "Copy To Output Directory" = "Copy if newer".


回答1:


You can use a postbuild script to achive what you want.

Here's an example: https://github.com/aspnet/dnx/blob/2acce95b3f2ad4e924bc36471ed8f08ee1fccd2b/src/Microsoft.Dnx.Compilation.CSharp.Abstractions/project.json#L21-L28




回答2:


The current way to do this in .NET Core RTM is setting copyToOutput in project.json's buildOptions section:

Change your project.json from this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  // more stuff
}

...to this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true,
    "copyToOutput": { "includeFiles": [ "ClearScriptV8-32.dll", "v8-ia32.dll" ] }
  },

  // more stuff
}


来源:https://stackoverflow.com/questions/33951362/new-net-project-json-project-copying-pre-built-native-dlls-to-the-output-di

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!