问题
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://docs.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?
回答1:
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
来源:https://stackoverflow.com/questions/39749344/copying-files-on-compile-for-asp-net-core-1-0-project