views:

7093

answers:

4

On a successful build, I wish to copy the contents of the output directory to a different location under the same "base" folder. This parent folder is a relative part and can vary based on Source Control settings.

I have listed a few of the Macro values available to me ...

$(SolutionDir) = D:\GolbalDir\Version\AppName\Solution1\build

$(ProjectDir) = D:\GolbalDir\Version\AppName\Solution1\Version\ProjectA\

I want to copy the Output Dir contents to the following folder :

D:\GolbalDir\Version\AppName\Solution2\Project\Dependency

The base location "D:\GolbalDir\Version\AppName" needs to be fetched from one of the above macros. However, none of the macro values list only the parent location.

How do I extract only the base location for the post build copy command ?

+10  A: 

You could try:

$(SolutionDir)\..\..\
ichiban
+10  A: 

If none of the TargetDir or other macros point to the right place, use the ".." directory to go backwards up the folder hierarchy.

ie. Use $SolutionDir\..\.. to get your base directory.

gbjbaanb
This is helpful, too: http://msdn.microsoft.com/en-us/library/c02as0cs.aspx
Eric Willis
+1  A: 

Hi

Would it not make sense to use msbuild directly? If you are doing this with every build, then you can add a msbuild task at the end? If you would just like to see if you can’t find another macro value that is not showed on the Visual Studio IDE, you could switch on the msbuild options to diagnostic and that will show you all of the variables that you could use, as well as their current value.

To switch this on in visual studio, go to Tools/Options then scroll down the tree view to the section called Projects and Solutions, expand that and click on Build and Run, at the right their is a drop down that specify the build output verbosity, setting that to diagnostic, will show you what other macro values you could use.

Because I don’t quite know to what level you would like to go, and how complex you want your build to be, this might give you some idea. I have recently been doing build scripts, that even execute SQL code as part of the build. If you would like some more help or even some sample build scripts, let me know, but if it is just a small process you want to run at the end of the build, the perhaps going the full msbuild script is a bit of over kill.

Hope it helps Rihan

Rihan Meij
thx Rihan, but apparently VS 2003 doesn't seem to support this ! I am of course quite content with the post build event ;-)
Preets
I did not realize it was vs2003, and hence the using msbuild as a possible solution, if I recall vs2003 was pre the msbuild era? Thanks for the response. Best of luck with VS 2003, I did not look back after moving over to VS2005
Rihan Meij
A: 

Here is what you want to put in the project's Post-build event command line:

copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)lib\$(ProjectName).dll"

Lucas B