dstr
dstr

Reputation: 8928

.NET Bootstrap without setup

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..

Upvotes: 3

Views: 2623

Answers (4)

ptkvsk
ptkvsk

Reputation: 2222

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.

Upvotes: 4

Lurker Indeed
Lurker Indeed

Reputation: 1531

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

Upvotes: 2

Adrian Grigore
Adrian Grigore

Reputation: 33318

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.

Upvotes: 2

Joel Coehoorn
Joel Coehoorn

Reputation: 416053

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.

Upvotes: 3

Related Questions