json将内容文件复制到DNX

json将内容文件复制到DNX

本文介绍了通过project.json将内容文件复制到DNX Console应用程序的输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始在VS2015中使用DNX 1.0.0-rc1-update1.我的第一个应用程序是控制台应用程序(程序包)"项目.一切正常,除了NLog日志记录.我怀疑这是因为NLog.config没有被复制到输出文件夹.如何告诉VS通过project.json将此文件复制到输出文件夹?

I've just started working with DNX 1.0.0-rc1-update1 in VS2015. My first app is a 'Console Application (package)' project. Everything works, except NLog logging. I suspect it's because the NLog.config doesn't get copied to the output folder. How can I tell VS to copy this file to the output folder via project.json?

我尝试添加这样的'resource'变量,但是它不起作用:

I've tried adding a 'resource' variable like this but it doesn't work:

project.json

...
"resource":"NLog.config",
...

我正在使用dnx451,因此兼容性不是问题.

EDIT 1:I'm using dnx451 so compatibility is not an issue.

我在 project.json

"scripts": {
    "postbuild": [
      "%project:Directory%/../scripts/copy_resources.bat \\\"%project:Directory%\\\" \\\"%project:Directory%/../artifacts/bin/%project:Name%/%project:Version%/dnx451\\\""
    ]
  }

copy_resources.bat

echo "Running script" >> C:\logs\log.txt
echo %1 >> C:\logs\log.txt
echo %2 >> C:\logs\log.txt

xcopy %1\NLog.config %2 /U /Y

VS的输出窗口中没有任何内容指示脚本实际上已在运行.此外,log.txt为空.

There's nothing in the output window in VS to indicate that the script was actually run. Furthermore, log.txt is empty.

如何调试构建过程?

推荐答案

同时,发布了.NET Core RTM.

In the meantime, .NET Core RTM was published.

现在,将内容复制到输出文件夹的当前方法是使用.

Now, the current way to get stuff copied to the output folder is using the buildOptions section in project.json.

有一个 copyToOutput 选项,您可以像这样使用:

There's the copyToOutput option which you can use like this:

之前:

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

  // more stuff
}

之后:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true,
    "copyToOutput": { "includeFiles": [ "NLog.config" ] }
  },

  // more stuff
}

这篇关于通过project.json将内容文件复制到DNX Console应用程序的输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:20