views:

277

answers:

0

I’m seeing some odd behaviour I can’t explain.

I'm using wix to generate a msi and using the msbuild GenerateBootstrapper task to handle pre-requisites. It all seems to build correctly i.e. there are no error or warnings but the generated setup.exe won’t run. It gives a nice blank error dialog and the event log gives about the same information.

The kicker is that if I drop to the command line and run msbuild manually on the project and specify the bootstrapper target it generates a correct and working setup.exe.

I've used this wix article as a base to get started. I've also used a few questions on StackOverflow to try and come up with a fix.

Has anyone seen this behaviour before, better still a fix?

Here's a part of the project file that calls the GenerateBootstrapper task:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">  
    ....
    <Import Project="$(WixTargetsPath)" />  
    <ItemGroup>
        <BootstrapperFile Include="Microsoft.Net.Framework.3.5">
            <ProductName>Microsoft .NET Framework 3.5</ProductName>
        </BootstrapperFile>
        <BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
            <ProductName>Windows Installer 3.1</ProductName>
        </BootstrapperFile>
    </ItemGroup>

    <Target Name="Bootstrapper" Inputs="$(OutDir)$(TargetFileName)" Outputs="$(OutDir)\Setup.exe" Condition=" '$(OutputType)'=='package' ">
        <GenerateBootstrapper 
          ApplicationName="MyProductName" 
          ApplicationFile="$(TargetFileName)" 
          BootstrapperItems="@(BootstrapperFile)" 
          ComponentsLocation="HomeSite" 
          OutputPath="$(OutputPath)" 
          Culture="en-US" />
        <Exec Command="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe&quot; sign /a setup.exe" WorkingDirectory="$(OutputPath)" />
        <Exec Command="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe&quot; timestamp /t http://timestamp.verisign.com/scripts/timstamp.dll setup.exe" WorkingDirectory="$(OutputPath)" />
        <Exec Command="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe&quot; sign /a $(TargetFileName)" WorkingDirectory="$(OutputPath)" />
        <Exec Command="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe&quot; timestamp /t http://timestamp.verisign.com/scripts/timstamp.dll $(TargetFileName)" WorkingDirectory="$(OutputPath)" />
    </Target>
    <PropertyGroup>
        <BuildDependsOn>$(BuildDependsOn);Bootstrapper</BuildDependsOn>
        <PreBuildEvent>
           "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe" sign /a "$(SolutionDir)Dotfuscator\$(ConfigurationName)\Dotfuscated\Application1.exe"
           "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\signtool.exe" timestamp /t http://timestamp.verisign.com/scripts/timstamp.dll $(SolutionDir)Dotfuscator\$(ConfigurationName)\Dotfuscated\application1.exe"
        </PreBuildEvent>
    </PropertyGroup>
</Project>

This is the command I use to get it to generate a setup.exe that works:

msbuild wixproject.wixproj /target:Bootstrapper /p:Configuration=Release