views:

683

answers:

2

I'm building a custom Windows installer package for my .NET 3.5 SP1 WPF application. I want it to detect what version (if any) of the .NET framework is installed on the client's computer, and then automatically download it from Microsoft if they don't have it.

Now, I've read about the .NET bootstrapper and even seen it in action in a ClickOnce installer I made. It seems to do just what I need.

The problem is, I don't want to use ClickOnce. I'm partial to NSIS. So essentially I'm looking for some documentation on how to communicate with or integrate the bootstrapper in some way so I can leverage it inside my own installer. But I'm not finding much.

Any help would be greatly appreciated.

Thanks, Steve

A: 

I don't think you can actually communicate with a bootstrapper. My understanding is that you define prerequisites, and it will install them as necessary. I have always used MSbuild GenerateBootstrapper to do this.

<ItemGroup>
 <BootstrapperFile Include="Microsoft.Net.Framework.2.0">
  <!--This requires the either the Platform SDK or VS.Net to be installed-->
  <ProductName>Microsoft .NET Framework 2.0</ProductName>
 </BootstrapperFile>
</ItemGroup>

 <!--Create the bootstrapper-->
 <GenerateBootstrapper
   ApplicationName="MyApp"
   ApplicationFile="MyApp.msi"
   ApplicationUrl="$(ApplicationUrl)"
   BootstrapperItems="@(BootstrapperFile)"
   Culture="en"
   CopyComponents="True"

   ComponentsLocation="Relative"
   OutputPath="$(InstallationPath)\"/>
Greg Dean
I couldn't get this to work, although it does look promising. I may have to look at this again later with other projects. Thank you.
Steve Wortham
what didn't work about it? This is the defacto way of bootstrapping the runtime for a .Net app in windows
Greg Dean
+3  A: 

You'll want something like this, except when I've used this it only detects up to 2 properly. I'm at home now but when I get to work I'll post my hack of this code to make it work up to 3.5 SP1. They changed the location of the version number a little.

Edit: Posted my version on pastebin

alphabeat
Awesome. This works great.I was a little apprehensive about doing it this way because of the unpredictability of .NET detection and future releases. But I suppose I'll address that when and if it becomes a problem.
Steve Wortham
Hey sweet! Yeah I had to dig around in the registry to make sure it worked for .NET 3. I'm sure there's a Microsoft certified way to do it but my testing so far on Windows Server 08 and XP SP2 has worked with this. Good luck!
alphabeat