.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..
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:
- Right-click your project
- Unload Project
- 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:
- Download my Windows Imaging Component bootstrapper
- Unzip it to %PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
- Download my BootstrapperTest solution
- 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.
- 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.
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.
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.
Most straightforward way would be to check for registry entries as listed in this question:
A script file might be the easiest way to check from the CD: