GenerateBootstrapperTask and the Visual Studio 2010 Command Prompt

If you’re using MSBuild and want to generate a bootstrapper for your application you might be drawn to this example on MSDN. It looks straightforward enough, and I’ve reproduced it below with a few changes (to install a later version of the .NET Framework, and Windows Installer 3.1).

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <ItemGroup>
        <BootstrapperFile Include="Microsoft.Net.Framework.3.5.SP1">
            <ProductName>Microsoft .NET Framework 3.5 SP1</ProductName>
        </BootstrapperFile>

        <BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
            <ProductName>Windows Installer 3.1</ProductName>
        </BootstrapperFile>
    </ItemGroup>

    <Target Name="BuildBootstrapper">
        <GenerateBootstrapper
            ApplicationFile="WindowsApplication1.application"
            ApplicationName="WindowsApplication1"
            ApplicationUrl="http://mycomputer"
            BootstrapperItems="@(BootstrapperFile)"
            OutputPath="C:\output" />
    </Target>

</Project>

However, building this project from the Visual Studio 2010 Command Prompt will give you many nasty errors:

bootstrapper.proj(10,9): error MSB3147: Could not find required file 'setup.bin' in 'C:\Output\Engine'.

The problem here is that even though you launched MSBuild from the Visual Studio 2010 Command Prompt, it doesn’t know what toolset to use.

The solution is implemented easily enough, simply change the root node of the project XML:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

With this change the project builds successfully:

Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 28/09/2012 4:24:11 PM.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.40

If changing the project XML is not is not suitable or convenient, you can also set the ToolsVersion from the command line.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s