   Visual Studio Build events
  Im trying a create a system where upon compiling an application in visual studio it copies across a bunch of files from some other directory. Basically I have a number of projects that all use the same resource files, and rather than manually copy them across, i want to automate it with some master copy. So I can make any changes i want to the master copy, and these master copies get copied across when the projectr is build or run. This also means its easyier to edit the files, as i only have to edit them in one place, and then these will get copied when one of the dependant projects gets compiled.So something like this- Upon building *or running* project, if project local directory does not have [Folder containing resource files] or project has [Folder containing resource files] but is out of date, then perform copy of the master copy.I have this already working, ....kindof, with the following as a Post-Build Eventif not exist ..\Resources mkdir ..\Resources copy ..\..\Resources  ..\Resourcesbuta) it always does the copy. How do i only do the copy if the Resources folders in the local directory is out of date compared with the masters? ie the files within the masters folder have been modified since the last copy?b) this only works when I either have made a code change (causeing a new build) or I rebuild the project. How do i get it to run whenever the project is simply just run?
  I personally found it easiest in the long run to just write my own program and call that from the post-build event. It just took a simple little C# program to recursively scan the source and destination, and copy over newer and missing files. It even spawns a few threads just to speed things up a bit since it mostly skips files on all but the first build. If you want, you can check out the program on Google Code.Quote:How do i get it to run whenever the project is simply just run?Not sure if you can through pre-build and post-build events. This is another time that an external program has an advantage. For my editors that need it, I also call the copying program to make sure things are up-to-date. This way, if you are just running the editor outside of Visual Studio, it will still update the content without any concerns over the build process.If you really do want to go the route without making your own copy program, just use xcopy:xcopy "$(ProjectDir)\Content\Data" "$(TargetDir)Content\Data" /E /C /R /K /I /Y(Here for more on XCopy)I myself "had" to choose a custom program since my post-build copying was in replacement of the XNA pipeline (since I moved to SFML), and I had to make sure I could perform some file name and data manipulation instead of just copying exactly as-is.   ;  Yes, that does sound easier. Any ideas about the second issue though? That being that i need it to happen whenever the project is run from Visual Studio as opposed to just being built in visual studio.For example, say I modify one of the external master resouce files, and then re-run the project from visual studio, i need it to make the appropiate copies.   ;Quote:Original post by hick18Yes, that does sound easier. Any ideas about the second issue though? That being that i need it to happen whenever the project is run from Visual Studio as opposed to just being built in visual studio.For example, say I modify one of the external master resouce files, and then re-run the project from visual studio, i need it to make the appropiate copies.You are going to have to do this in the program itself. You CAN tell Visual Studio to always build a project (I believe), but you don't want to shoot yourself in the foot like that. It also won't help at all if you want to just run the program from the .exe instead of through VS. So if you have a custom program, use the Process class to call it with the needed parameters. If you use XCopy, you may want to create a batch file (*.bat) and call that instead both from the post-build and when your program starts just to avoid duplicate code.   