3

I have prebuild events on the installer to rebuild the projects with the appropriate configuration etc.

If I right-click build/rebuild on the WiX (3.0) project in visual studio it all builds fine, but if I try to run MSBuild on the wixproj file the pre-build events will throw errors.

I can instead call Candle and Light on the wixproj but it won't run the pre-build events.

The prebuild events rely on the macros provided by VS and I'm not sure how to get around that other than creating another project and basically just use the prebuild event of the project which just screams hack.

Another problem is that I need to feed in a self-updating version number into WiX from the command line.

I was planning on using just a csproj to handle the version number and updating it and just shelling to the MSBuild and Candle and Light, but the problem is that I don't know how to access the solution directory from code other than hard-coding it in

Davy8
  • 30,868
  • 25
  • 115
  • 173
  • And what are the errors? I've had a hell of a time getting WiX paths to work on both the development and build machines. There are ways of doing it, if that's your issue. As for versioning, I dunno... –  Jan 26 '09 at 18:54

2 Answers2

2

We found it easiest to use a utility to edit the project itself and to dump all the pre-build and post build events before we build it with our autobuilder (in our case VisualBuild).

This leaves us with a nice and juicy build process that doesn't rely on any nasty hacks in the IDE and give us full control over where source comes from and where built components go to.

Brody
  • 2,074
  • 1
  • 18
  • 23
-1

I'm using a different way that works well for me, which I described here.

  • I maintain the version number in a batch file, which just writes it into an environment variable
  • I create my release builds by running a batch file that first calls the "version number" batch file (so I have the version number in an environment variable called %VersionNumber%) and then executes an MSBuild project file
  • The MSBuild project file builds the solution, and I get the version number for the .exe in the .csproj file by reading it from the environment variable if it exists (and then I use MSBuild Community Tasks to create an AssemblyInfo file with the version number in a pre build event)
    This means that the .exe has version 0.0 when built from Visual Studio, but Im fine with that because I create all my releases from the batch file.
  • To create a relase build with WiX setup, I execute another batch file, which just calls the "build" batch file mentioned above, and then calls the WiX utilities candle and light to build the actual setup.
  • candle uses this .wxs file to create the setup, where I again get the version number from the environment variable: $(env.VersionNumber)
  • the final .msi file created by light includes the version number in its file name because I pass the file name (including the environment variable with the version number) as an argument: -out release\msi\bitbucket-backup-%VersionNumber%.msi

It took me a while to figure all this out in the beginning, but now I release all my projects in a similar way.

Christian Specht
  • 35,843
  • 15
  • 128
  • 182