views:

34

answers:

2

I have a solution that is building a lot of executables and assemblies which need to be in a specific folder hierarchy to work. Mostly all the .exe files and their accompanying .dll files must be in one folder because the main exe will spawn (via process.start) the other exe files and they will dynamically load assemblies.

TS redirects all output to a common folder which works fine. In installation, all th output for the main app will end up in one directory, too.

Is there a central way to do so in a solution (with our without UI)? My alternative so far would be to change that in every project which seems - a lot of work and unstable (I have about 30 or so projects so far).

A: 

By TS do you mean TFS and MS Build? Why can't you just configure where the build output goes in the project files?

Fred Thomas
TS = TFS. I CAN do that per project, but that is prone to errors (forgetting a project) and very manual. I would prefer a central solution wide switch ;)
TomTom
Don't think there is a turnkey on this one, however the project and solution files are just XML, so it would be pretty easy to write a simple program to do this.
Fred Thomas
@TomTom as Fred said it is lot more easier and simple to write your own utility program to perform this. Will save lot of time.
Avatar
+1  A: 

In projects, you have these primary options:

  1. Configure the output path of the project so that the built assembly is written to your shared file structure.
  2. Add a post-build script that xcopy's the built assemblies to your shared file structure.
  3. It's also possible (as TFS Build does) to override the output folder for the entire build, but AFAIK this can only be done to a single folder (as TFSBuild does) so you can't build a hierarchy of files.

The drawback of 1,2 is that you have to set up every single project to do this.

I tend to use (2), the "post-build script" approach. The reasons for this are:

  • The core build remains the same. On desktop builds the assembly is written locally, and in server (TFS) builds it (annoyingly) redirects everything to a shared folder. xcopy of the target file works regardless of how TFS Build interferes with the outputs.

  • Using xcopy you can fully control the output (build a hieararchy rather than lump everything into a single folder), and only copy the items you need. I prefer to careefully pick out only the files Iwant for my final install than relying on an automated process that will chuck loads of unnecessary junk (xml doc and pdb files)

  • With VS2010 the "copy local" option seems to completely screw up file references. We use our libraries by referencing pre-built dlls from a shared folder, but after a copy local VS often changes a reference to the "copied local" dll in the debug folder instead of our shared libraries folder. Which means that any subsequent changes to the library are never picked up by the build! Argh! The only solution I have found is to disable "copy local" for every reference.

Jason Williams
Any way to do your option (3)? I would be perfectly ok centrally redirecting all output to one folder. My problem with (2) is that the copies are complex.... and these events must reference other projects output folders, which are different in TFS, so this is complicated. How would I go forward redirecting all VS output to one folder? A change in the solution file?
TomTom
(3) You just have to edit the .csproj file (which is simply an msbuild script). See the accepted answer to: http://stackoverflow.com/questions/587672/nant-msbuild-custom-output-directory
Jason Williams
Note that for (2) your projects should xcopy to the final folder hierarchy. Inter-project output references should be set to point at the final folder hierachy, not the "intermediate" msbuild output folder - then you're in completer control of the file references.
Jason Williams