Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 31, 2015 1:11 PM
How can I add additional files in the build output directory and have them in the Visual Studio project file?
I need to deploy additional DLLs and other files with my application. Those files cannot be added as a reference because they're not supposed to be used like that. (This cannot be changed.) Some of them are unmanaged native DLLs that cannot be used as reference either. And other files are just some resources like text or image files. Embedding is not an option, I need them as separate files in the output directory.
The only way I know to achieve this is to add those files in the project, in the middle of other source code files, and set their properties to "Copy to output directory". Unfortunately, the target directory cannot be set, so the files must be in the target directory's name in the project. That would be the root directory for most files, cluttering and messing up the project massively. Other files need to go to subdirectories like "x86" and "x64". These directories need to be created among other namespace-based source file directories.
As far as I know it, files not included like this in the project are not deployed with the web application deploy assistent, and are not copied to the build directory when starting the application in the debugger.
What is the suggested method to handle such external files?
And when I move that part into a separate class library project that is referenced from a front-end application project, how can the additional files from the class library be deployed to the referencing application, just like the main DLL is automatically copied there?
All replies (3)
Friday, September 4, 2015 7:07 PM âś…Answered
> What do you mean "the target directory cannot be set"?
You can add files to a project and have them copied to the build output directory. Unfortunately the files will always be copied to the same path that they come from relative to the project root. I can't say that a file should be copied to another directory in the target.
Example: Add a file in the project root directory and have it copied to bin\Debug\SomewhereElse\
Example: Add a file in the "DLLs" subdirectory of the project and have it copied directly into bin\Debug\ where the main application is.
The tutorial about adding extra files for web deployment did work. I didn't really understand what all these new words are good for, but at least it does what is advertised. I couldn't make any use of the other links you provided.
Adding extra files into the local build directory for executing and debugging requires 'xcopy' in a pre/post build event. Not exactly nice but at least perfectly comprehensible.
Thursday, September 3, 2015 6:30 AM
Hi dg9ngf,
>>The only way I know to achieve this is to add those files in the project, in the middle of other source code files, and set their properties to "Copy to output directory". Unfortunately, the target directory cannot be set, so the files must be in the target directory's name in the project.
What do you mean "the target directory cannot be set"?
>>As far as I know it, files not included like this in the project are not deployed with the web application deploy assistent, and are not copied to the build directory when starting the application in the debugger.
Which kind of app did you really create? Is it related to the web app?
Maybe you could add certain file in the .xxproj file after you unload your project.
Or you could use the post build event:
But for generally project files, we often use the Copy to output directory property:
If I have misunderstood this issue, please feel free to let me know.
Best Regards,
Jack
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
Monday, September 7, 2015 11:44 AM
Hi dg9ngf,
>>Adding extra files into the local build directory for executing and debugging requires 'xcopy' in a pre/post build event. Not exactly nice but at least perfectly comprehensible.
So use the build event would be a workaround for you, am I right? If so, would you mind closing this case?
If you have any VS usage issue, please feel free to let us know.
Best Regards,
Jack
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.