3

I have a .NET WinForms application which needs to be run from CD. What I need to figure out is if user has required .NET version installed or install if necessary than run the application after installation. Any info I've found about bootstrapping involves setup and installation of the application. How can I do this if I don't install anything? I'd appeciate any info..

Siguza
  • 21,155
  • 6
  • 52
  • 89
dstr
  • 8,362
  • 12
  • 66
  • 106
  • So, essentially you want a bootstrap program named "LaunchProgram.exe" instead of setup.exe and when it's done checking for .NET it runs "MainProgram.exe" instead of "InstallMe.msi"? – Grant Feb 04 '09 at 17:38

4 Answers4

4

I was also thinking that you can't do it without making an installer for a long time, but that's not true. There is a msbuild action, called "GenerateBootstrapper". If you're in Visual Studio:

  1. Right-click your project
  2. Unload Project
  3. Edit YourProjectName.csproj"

Then you can add GenerateBootstrapper action in different ways (depend on what you want to install). MSDN gives an example for .NET 2.0:

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

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

I didn't try this example, but I tried my own and I can tell you, that in order to install .NET 4 Client Profile (which is the latest stable .NET release for today) on XP machines, you need to install Windows Imaging Component first. That's why standard .NET4 Client Profile prerequisite, included in VS2010, fails on XP. So i wrote my own bootstrapper. You can download my sample VS2010 solution, that creates a bootstrapper for console app. But it requires you to install (just copy) my bootstrapper. So here are the steps:

  1. Download my Windows Imaging Component bootstrapper
  2. Unzip it to %PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
  3. Download my BootstrapperTest solution
  4. Build solution. You'll see that it created BootstrapperTest.exe and setup.exe in \bin\Debug directory. Setup.exe is a bootstrapper, you can run it without .NET installed - it will get it for you and then run BootstrapperTest.exe.
  5. If you want to distribute it as a single file, I recommend using a ChilkAt Zip2Secure or it's analogues. Zip2Secure is very easy to use and I hope you won't have any troubles with it.
Community
  • 1
  • 1
ptkvsk
  • 2,096
  • 1
  • 25
  • 47
3

The msi installer you build with visual studio can include a native setup.exe that checks the framework dependency and kicks off the installer first if needed. You can even include the redistributable on your cd. But you have to install the program for that to work.

Otherwise, you must build your own native code tool.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • +1; the bootstrapper must actually be a separate file due to a limitation of MSI: One MSI installer is not allowed to launch another MSI installation (e.g. the .NET Framework installation) – Dirk Vollmar Feb 04 '09 at 17:47
  • Armagan is not trying to run an MSI file at all. He isn't even installing anything (except .NET if the user doesn't already have it). – Grant Feb 04 '09 at 17:53
2

You could code a small native code loader that checks for .NET runtime, triggers the installation of .NET if necessary, and then starts your .NET application.

Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
2

Most straightforward way would be to check for registry entries as listed in this question:

.Net Framework detection

A script file might be the easiest way to check from the CD:

Windows Script Host - RegRead method

Community
  • 1
  • 1
Lurker Indeed
  • 1,521
  • 1
  • 12
  • 21