Browsing the archives for the MSI tag.


  • Anthony Stevens

How To Build .vdproj Files In MSBuild

Software

It’s somewhat amazing to me that in 2010 there should still be any problems or confusion surrounding how to build Windows Installer (.vdproj) projects in MSBuild.  But, as Edna Mode says, “Yet here we are, darling.”

First problem: figuring out the syntax.  Well that was the first, last, and in-between problem, but when I typed the following into PowerShell:

devenv.exe /?

I got Visual Studio to fire up and show a message box with some command-line help.  Unfortunately, the version of Visual Studio was 2005, not 2008 as I might have expected.  Turns out my $env:path environment variable was riddled with references to *Microsoft Visual Studio 8* when really I wanted *Microsoft Visual Studio 9.0*.

OK, I can fix that temporarily by navigating to:

c:\program files\microsoft visual studio 9.0\common7\ide

And re-running the command

devenv.exe /?

Yet I still got the IDE to open up with a message box full of command-line and switch information.

Aha! I thought.  Perhaps I need to run the .com version of the program, not the .exe.  I am operating in a command-line environment, after all.

Changing to:

devenv.com /?

Showed me an inline help list which matched the IDE message box, but at least I’m operating within PowerShell 100% now.

OK, so about the format of the command line to build a VDPROJ setup project.  At first I thought that it would be something simple like:

<Exec Command=”$(DevEnv) $(ProjectFile) /Build ‘Debug’”/>

Where $(DevEnv) was the path to devenv.com and $(ProjectFile) was the path to my .vdproj file.  Well, two problems.  First was the single- vs. double-quoting issue.  The Exec task’s Command attribute takes a quoted string.  It turns out you have to use XHTML &quot; pseudo-characters to delineate the arguments.

The second problem was more subtle.  As it turns out, you have to pass in the SOLUTION file first, then you have to tell devenv what PROJECT FILE you want built.  Very counter-intuitive.

Here’s my final target in my .msbuild file:

<Target Name="Foo">
        <PropertyGroup>
            <DevEnv>$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com</DevEnv>
            <SolutionFile>$(MSBuildProjectDirectory)\MySolution.sln</SolutionFile>
            <ProjectFile>$(MSBuildProjectDirectory)\MySetupProject\MySetup.vdproj</ProjectFile>
            <Configuration>Debug</Configuration>
        </PropertyGroup>
        <Exec
                Command="&quot;$(DevEnv)&quot; &quot;$(SolutionFile)&quot; /Rebuild &quot;$(Configuration)&quot; /Project &quot;$(ProjectFile)&quot; /ProjectConfig &quot;$(Configuration)&quot; /Log"
                ContinueOnError="false"
                IgnoreExitCode="false"
                WorkingDirectory="$(MSBuildProjectDirectory)" />
    </Target>

I still have to do some work to do a clean prior to the rebuild, and I’m not sure why the configuration needs to be specified twice, but this has gotten me working this weekend. Hope this helps some of you out.

9 Comments

Thursday Recap

Fitness, Personal, Software

What’s been going on?  First of all, what I really want to write about I can’t (or, more precisely, won’t) write about.  That’s stuff for my journal.  With that caveat out of the way…

I recently had reason to pass in a username/password combination to an MSi file for an unattended auto-install of a Windows Service.  I’d been following this CodeProject post on how to pass in additional parameters to an MSI, and things were going along swimmingly….almost.  It turns out that the parameter names I had chosen – “UserName” and “Password” – were reserved, and the “UserName” parameter was being replaced under the covers by my full name “Anthony Stevens” instead of the string parameter I’d been passing along on the command line.  Of course there was no warning, no error; the thing just didn’t work.  Lesson learned: logging can be your friend.  I have to get better at log4net so I can introduce a new log4net configuration in my sleep.

My CSS work is just about complete.  I got to include a smallish bit of JavaScript/jQuery work in the project as well.  Next steps look like they may include a broader architectural review, maybe including updates to the SDLC processes, which is really my bread and butter.  This organization wouldn’t fare so well on things like The Joel Test, so there is an opportunity to make significant progress right away.

Today and tomorrow I’ll be working on some architectural diagrams for a large-ish system that I’ve been collaborating on with a partner.  It’s a long-term investment of time and effort, but who knows which things will pay off.  On a philosophical level, sometimes you spend a lot of time doing things that seem like they’ll *never* bear fruit – but if you enjoy the time spent, you never know what can happen.  I believe that good things happen to good people.  I believe in optimism.  I believe in hope.  I believe that “no” can turn into “maybe” can turn into “yes”.

Exercise has been going well.  Last week’s proto-cold has disappeared, and although I’m not going back to two-a-days, I’ve been going every morning.  Yesterday I ran 4 1/2 miles on the treadmill, and this morning I lifted weights, to put day 88 behind me.  I also did something strange (for me) – I introduced myself to, and chatted with, someone that I’d seen at the gym regularly the last couple months.  Normally when I’m at the gym I’m very focused, intense, an in-and-out kind of guy.  But I figured I should get to know these people that I see every day so I had a nice short conversation before I left for the day.

I’m still losing weight, steadily – I’m down 57 pounds from my all-time high.  None of my pants – and this is not an exaggeration – fit me.  All of my belts are too long.  I’m also getting less and less shocked at seeing ab muscles in the mirror.  I feel physically great.  My sleep the last week or so has been ragged, but that’s a symptom of something else, not the exercise.

Wishing you the best possible day, whoever you are.

Comments Off