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?
I've tried adding a 'resource' variable like this but it doesn't work:
project.json
...
"resource":"NLog.config",
...
EDIT 1: I'm using dnx451 so compatibility is not an issue.
EDIT 2: I added the following to 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
There's nothing in the output window in VS to indicate that the script was actually run. Furthermore, log.txt is empty.
How can I debug the build process?
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
.
There's the copyToOutput
option which you can use like this:
Before:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
// more stuff
}
After:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"copyToOutput": { "includeFiles": [ "NLog.config" ] }
},
// more stuff
}
Use copyToOutput
inside buildOptions
:
{
"buildOptions": {
"copyToOutput": "NLog.config"
}
}
or for multiple files declare an array:
{
"buildOptions": {
"copyToOutput": ["NLog.config", "testdata\\"]
}
}
To copy a directory remember to add the trailing \\
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With