Copying files on compile for Asp.net Core 1.0 project
Asked Answered
E

1

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?

Edgy answered 28/9, 2016 at 13:43 Comment(1)
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?Edgy
M
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
Megargee answered 28/9, 2016 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.