4

I'm creating a REST Api with Asp.Net Core 1.0 and I want to copy a file which is not in included in the project to the output path when the project is compiled.

I can't figure out how to do it though. I have tried to use "buildOptions: copyToOutput" without any success. I can't really understand the project.json reference found here: https://learn.microsoft.com/en-us/dotnet/articles/core/tools/project-json

Say that I want to copy the file ....\TestFolder\Test.config to the output folder of the current project. How can I do that?

Janni Kajbrink
  • 661
  • 2
  • 7
  • 21
  • Thanks it worked, but if I copy my Test.config to the output folder, the "TestFolder" folder will be created and the path to Test.config will be [output directory]\TestFolder\Test.config. Can I somehow specify that the file should be copied to the root of the output directory? – Janni Kajbrink Sep 30 '16 at 10:22

1 Answers1

4

You can specify files you want to copy to output in buildOptions when project is compiled.

"buildOptions": {
    "copyToOutput": [
       "../../../copyme.txt"
    ]
}

The path to the file is relative to the folder where your project.json is residing. In my case:

Root folder:
-copyme.txt
-WebApplication\src\WebApplication\project.json
Ignas
  • 4,092
  • 17
  • 28