I created bootstrapper,it works
but it does not install NET Framework 4.0. After the installation completed my application does not start because no NET Framework 4.0.
Why it does not install NETF 4.0?
<ItemGroup>
<BootstrapperFile Include="Microsoft.Windows.Installer.4.5">
<ProductName>Windows Installer 4.5</ProductName>
</BootstrapperFile>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>True</Visible>
<ProductName>.NET Framework 4.0</ProductName>
<Install>True</Install>
<Visible>True</Visible>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<Target Name="AfterBuild">
<GenerateBootstrapper ApplicationFile="DOGInstaller.msi"
ApplicationName="DOG"
BootstrapperItems="@(BootstrapperFile)"
CopyComponents="True"
ComponentsLocation="HomeSite"
OutputPath="$(OutputPath)\en-us\"
Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper"
Culture="en" />
</Target>
In the wixproj file, add the following structure. Note that the <WixTargetsPath>
tags must reside in the the first <PropertyGroup>
node, along with the rest of what's usually there.
<Project>
<PropertyGroup> <!-- This must be the first PropertyGroup node. -->
...
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
...
<ItemGroup>
<BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
<ProductName>Windows Installer 3.1</ProductName>
</BootstrapperFile>
<BootstrapperFile Include=".NETFramework,Version=v4.0">
<ProductName>Microsoft .NET Framework 4.0 (x86 and x64)</ProductName>
</BootstrapperFile>
</ItemGroup>
<PropertyGroup>
<BootstrapperPath>$(ProgramFiles)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\</BootstrapperPath>
</PropertyGroup>
<Target Name="AfterBuild">
<GenerateBootstrapper
ApplicationFile="$(TargetFileName)"
ApplicationName="$(OutputName)"
BootstrapperItems="@(BootstrapperFile)"
ComponentsLocation="Relative"
CopyComponents="True"
OutputPath="$(OutputPath)"
Path="$(BootstrapperPath)" />
</Target>
</Product>
All items in the item group need to have the same name, "BootstrapperFile" - currently you will have two item groups, so the .Net Framework will not be included in the bootstrapper (as it's in a different item group called "BootstrapperPackage".
Though most examples on the net use "BootstrapperFile" or "BootstrapperPackage", the name is not significant, it just has to line up with the parameter of the bootstrapper generation task - unfortunately consistency of examples in some cases can lead to misconceptions :)
Once corrected, the other thing to check is that when building - on both your local machine and on the build server (if you have one) that no warnings are logged - the boostrapper generation task by default will not cause the build to fail if one or more packages can't be located.
You will see this in the msbuild logs as:
- warning MSB3155: Item '.NETFramework,Version=v4.0' could not be located in ''.
Easy ways to detect this is the case with your bootstrapper, are:
- Your generated .exe file is unusually small - say 300-400K.
- Delete your accompany .MSI file, then run the bootstrapper - it will generate a log file (which it provides the path to in an error message). The log file will list which packages were checked (to see if they need to be executed) - along with what was executed. If your package wasn't in the list, it's likely not in the bootstrapper.
I used dotnetinstaller for checking and installing pre-requisites. Its very simple and easy to use. Also it provides the facility to convert msi into exe and attaching UAC prompt.
You need to have an configuration file
Then in your project in post-build event add this code. This will embed your msi and pre-requisite file.
copy /Y "$(ProjectDir)Files\dotnetfx35setup.exe" "C:\Windows\Temp"
copy /Y $(TargetPath) "C:\Windows\Temp"
"$(SolutionDir)Tools\dotNetInstaller 2.0\Bin\installerLinker.exe" /o:"$(TargetDir)Setup.exe" /t:"$(SolutionDir)Tools\dotNetInstaller 2.0\Bin\dotNetInstaller.exe" /c:"$(ProjectDir)Files\Configuration.xml" /b:"$(ProjectDir)Files\banner.bmp" /Embed+ /Verbose+