Visual Studio Beta2: One Click Deployment Non-Default Prerequisite Installs: (SqlExpress 2005)

Author: Terry Voss

 

Introduction:

One Click Deployment is a setup capability that is built into your project. You go to Project Properties and click on the publish tab to set it up. From there after specifying a few things, you can publish to a Web site or other location that can be a Setup server for your application. A web page is created that allows the download. If your application needs .NET Framework 2.0 installed and maybe also SqlExpress 2005, you can do that there also since One Click has the capability to build into a setup.exe file the instructions to install them after checking for what is already installed, and maybe after getting the end user’s acceptance of a EULA. Without understanding something about how this Bootstrapping works through manifest files, one gets the default install of Windows Authentication with an sa user with unknown password. This article shows how to modify this. (For an introduction to OneClick Deployment and more about the Bootstrapper, see links at article bottom)

 

Selecting the prerequisites:

Go to the Project Properties, Publish tab and click on the Prerequisite button to view this dialog.

The only reason I see to download from another location than the vendor is if you think the vendor’s site might be busy and your web could do better.

 

Where are the Manifest files:

In Microsoft Explorer, go to: …\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bootstrapper\Packages\  where you will see these folders:

There is one folder for each application that the Bootstrapper currently has manifest files which are xml files, defined for already. By the RTM there will be more.

Inside the folder for SqlExpress we see:

Now, there are 2 types of manifests. Product and Package manifests which have similar elements and attributes, but product manifests are for the non-localization-specific files of the application, and package manifests are for the localization-specific files. It happens that dotnetfx.exe is non-language specific because there is a separate language pack that handles that aspect. Therefore dotnetfx.exe is in a folder called dotnetfx directly below packages folder with a product.xml manifest. Contents for the en folder are seen below:

The install file for SqlExpress, sqlexpr.exe, is in the en, short for English, folder below the SqlExpress folder since that file is language specific, and associated with a package.xml manifest file. Note in SqlExpress folder we have the SqlExpressChk.exe file which is an application that checks to see if SqlExpress is already installed on the target machine of the user, and it is non-language-specific and so is with a product.xml manifest file. Examine both, but mainly we want to look at sqlexpr.exe’s package.xml file to see if we can modify the install to be SqlAuthentication with a known sa password that does need to be a strong password.

 

Code listing 1 – Page load event

  <?xml version="1.0" encoding="utf-8" ?>

- <Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="DisplayName" Culture="Culture" LicenseAgreement="eula.txt">

- <PackageFiles CopyAllPackageFiles="false">

  <PackageFile Name="sqlexpr.exe" HomeSite="SqlExprExe" PublicKey="3082010A0282010100CF38F7E1A4275EF8F0CCAACEFB3ADE3B6231460546BBF5B6051AD3B3ACC29F0F4C670828C44310F53B75797F6A91F4D633C861BFFA9190007AF0791D5D6870F690B29877B5031D2F9B9D9B75892F4A01417C9E7CCB87439BF49674999E98C1CF40575816F6C0D59216E52485718F9949ED557C65C91F380023C53EAB11D6296CC69EA0705B7DD537D4677720C306CE85F84E3480A035C41C53320157EFB128BD6C01E3AD40BC80A90949DB36E337F41D49AA2AA76BD019D3CC8E9DD686467A134AD64519A553B3E2782F2E35976B4CC6E81AB0D3D1249069ABCEFC696E3E4CFB024162DC07985D7E5CA74C27316B564CE198D8E0D11D718D3D2AC07F714DFFCF0203010001" />

  <PackageFile Name="eula.txt" />

  </PackageFiles>

- <Commands Reboot="Defer">

- <Command PackageFile="sqlexpr.exe" Arguments="-q /norebootchk /qn reboot=ReallySuppress addlocal=all instancename=SQLEXPRESS sapwd=sssaaa999 securitymode=SQL SCCCHECKLEVEL=IncompatibleComponents:1 SQLAUTOSTART=1" EstimatedInstalledBytes="225000000" EstimatedInstallSeconds="420">

- <InstallConditions>

  <BypassIf Property="SQLExpressInstalled" Compare="ValueEqualTo" Value="0" />

  <BypassIf Property="VersionNT" Compare="VersionGreaterThanOrEqualTo" Value="5.1" />

  <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired" />

  <FailIf Property="Version9x" Compare="ValueExists" String="InvalidPlatform" />

  <FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.0.4" String="InvalidPlatform2K" />

  </InstallConditions>

- <ExitCodes>

  <ExitCode Value="0" Result="Success" />

  <ExitCode Value="1641" Result="SuccessReboot" />

  <ExitCode Value="3010" Result="SuccessReboot" />

  <ExitCode Value="50037" Result="Fail" String="MissingMSXml" />

  <ExitCode Value="50251" Result="Fail" String="MissingMSXml" />

  <ExitCode Value="50198" Result="Fail" String="InsufficientHardware" />

  <ExitCode Value="50236" Result="Fail" String="InsufficientHardware" />

  <ExitCode Value="50222" Result="Fail" String="InvalidPlatformOSServicePacks" />

  <ExitCode Value="70003" Result="Fail" String="InvalidPlatformOSServicePacks" />

  <ExitCode Value="50247" Result="Fail" String="InvalidPaltformIE" />

  <ExitCode Value="50248" Result="Fail" String="InvalidPaltformIE" />

  <ExitCode Value="70004" Result="Fail" String="AnotherInstanceRunning" />

  <ExitCode Value="70032" Result="Fail" String="BetaComponentsFailure" />

  <ExitCode Value="70033" Result="Fail" String="InvalidPlatformArchitecture" />

  <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />

  </ExitCodes>

  </Command>

 

In the Command elements inside the Commands element, there is an argument: Arguments. I added the 2 arguments for sapwd=sssaaa999 (replace sssaaa999 with your password), and securitymode=SQL. The other arguments were already there. So it is as simple as that except there were 2 gotchas that should be handled by the time of the RTM.  Note that there are 2 Command elements inside the Commands element. They are identical and relate both to sqlexpr.exe. I found that if I didn’t put the 2 new arguments into both, the bootstrapper read the second command without the arguments and did a default install anyway. If the second one was deleted it probably would work fine also as a solution to this gotcha. Then after testing this, I got an install that did not finish, but gave me an error:

This app requires that your Windows be updated to: Microsoft.ReportViewer.Winforms

To solve this one needs to workaround for now by going into publishing, and clicking on the application files button. You will see 2 entries relating to ReportViewer that need their Publish Status changed to “Include”, versus the default of “Include(Auto)”. This solves that problem that will be no problem at the RTM.

Another thing to be aware of is that if you turn versioning off because you don't want a new version every time you publish, you may have to delete the five things that a publish puts on your website or other install server to make sure your next publish takes over:
1) a folder named something like(for version one): myapp_1_0_0_0
2) a file named: setup.exe
3) a file named: publish.htm
4) a file named: myapp.application
5) a file named: myapp_1_0_0_0.application

Links

Get a basic introduction to One Click Deployment(this is a .PDF download that takes a while, but it is well worth it)

Study more about the Bootstrapper capabilities of One Click Deployment

Summary:

For the install of your custom VS2005 application and .NET Framework 2.0 and SqlExpress 2005, the user sees a fairly seamless install that looks like one smooth install with no reboots required.  It is impressive that 2 projects, my custom application and the publishing source website can work together so automatically not just for the initial install, but for version upgrades as well. To me it is very well worth the time to get to know this technology since I feel One Click Deployment will have a big impact, but also since manifest files are going to be used everywhere in future Microsoft products.