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

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

问题描述:

我希望将项目转换为使用 project.json 格式,但是仍要使用.NET CLR,直到第三方依赖项添加对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\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin ,则我的应用程序可以正常运行,因此这些文件只是以某种方式放入应用程序PATH中。

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.

那么,我该怎么做?在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/2acce95b3f2ad4e924bc36ed .Compilation.CSharp.Abstractions / project.json#L21-L28