新的 .NET “project.json"项目,将预先构建的本机 .dll 复制到输出目录

新的 .NET “project.json

问题描述:

我希望将我的项目转换为使用 project.json 格式,但仍使用 .NET CLR,直到第 3 方依赖项添加对 CoreCLR 的支持.

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.

话虽如此,我的内容"目录中的一些文件的 NuGet 依赖项需要输出到正在运行的应用程序的 bin 目录中.

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.

由于 project.json 目前不支持 NuGet 内容,我手动将文件添加到我的项目目录中.

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

但是,当我运行该应用程序时,它仍然找不到这些本机程序集.如果我手动将这些程序集添加到 .dnx untimesdnx-clr-win-x86.1.0.0-rc1-finalin,我的应用程序运行良好,所以这只是这些文件以某种方式进入应用程序路径.

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

那么,我该怎么做?在 MSBuild 中,有复制到输出目录"=如果更新则复制".

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

您可以使用 postbuild 脚本来实现您想要的.

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

这是一个例子:https://github.com/aspnet/dnx/blob/2acce95b3f2ad4e924bc36471ed8f08ee1fccd2b/src/Microsoft.Dnx.Compilation.CSharp.Abstractions/project.json#L21-L28