ClickOnce and WCF
April 6th, 2006
I’ve been concerned about the relationship between ClickOnce and WCF. Lot of buzz has been generated regarding partial-trust scenario not being supported for WCF v1. I see this as something desirable, but it is not the end of the world
I’ve written a Smart Client application that leverage WCF. I wanted to deploy it so I choose ClickOnce. ClickOnce supports installing prerequisites as part of the whole process, so I downloaded WinFx and include it as part of the installation. If you are insterested in how to do this, keep reading.
WCF is part of
the WinFX Runtime Components, which is currently in Beta 2 (Feb CTP). The installation of this runtime requires
Admin privileges and the size of the Redistributable package is 45.3 MB.
These are the alternatives to distribute it on client desktops:
- Install
WinFx manually on each desktop
- Use SMS
to distribute WinFx - Include
WinFx as part of the prerequisites of the ClickOnce application - Distrubute
an MSI which includes WinFx
I was interested in the 3rd option, so let’s analyze it further
Include WinFx as part of the prerequisites of the
ClickOnce application
ClickOnce has a feature that allows including the
prerequisites of the application to be deployed. When the application is published
it creates a setup bootstraper that will download and install all the
prerequisites (if they were not installed yet) before the ClickOnce application
is executed. This way the deployment will be more controlled as it will be a
single package.
The user executing the setup bootstraper must have
Admin
privileges. If the user logged does not have Admin privileges, an
option would
be to execute Internet Explorer with “Run As…†and login with a local
administrator account. This will at least install the prerequisites and
also the application in the Administrator profile. Later you would need
to open a new IE instance and launch the app again from the currently
logged user.
The following sequence illustrates the install of
prerequisites (.Net Framework 2.0 and WinFx Beta 2)
Figure 1. Prerequisites of the
application listed in the Publish ClickOnce html file
Figure 2. Pressing
Install will launch the bootstrapper that detects the uninstalled
prerequisites: Net Framework 2.0 and WinFx Runtime Components Beta 2
Figure 3. The setup downloads the prerequisites from a specific location
<!–[if !vml]–><!–[endif]–>
Figure 4. After
downloading, the setup will install the WinFx Runtime Components
Using WCF on your application requires more
CAS permissions (FullTrust)
In many real scenarios, developers need their applications
to run as a Partial Trust Application, but need more permissions. For example,
you may need to use a SQL Client. To solve this kind of problems, ClickOnce introduces a feature called Permission
Elevation, which allows an application without enough permissions to
request them to the user. If the user accepts, then the needed permissions are
granted and the application can run normally. This could goes up till
FullTrust which is the requirement for WCF. Besides, in scenarios in which users should not make these kinds of
decisions, a practical solution is offered: system administrators can sign the
application manifests or set a deployment policy that specifies that a
publisher is a trusted source. This way, permissions will automatically be
granted before the application loads.
Figure 5. Installing the application and permission elevation
Creating the prerequisites
WinFx does not come as a prerequisite in the
Visual Studio 2005 Publish tab. However, we can create our own
prerequisite with any MSI or EXE installation.
The process to do this is:
- Create a new folder called "WinFx" here %Program Files%\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages
- Use the Bootstrapper Manifest Generator to create the manifest for WinFx. I’ve created it already for WinFx.
- Copy the manifest to %Program Files%\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\WinFx
- Copy the WinFx Runtime Components redistributable to the same folder
- Restart Visual Studio 2005
More resources
- Adding
Custom Prerequisites: http://msdn2.microsoft.com/en-us/library/ms165429.aspx - How
to: Install Prerequisites with a ClickOnce Application: http://msdn2.microsoft.com/en-us/library/8st7th1x.aspx - Brian Noyes ClickOnce article, http://msdn.microsoft.com/msdnmag/issues/04/05/clickonce/default.aspx
- Security
Considerations for ClickOnce Deployments: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/ClickOnceSec.asp - ClickOnce
Deployment and Security: http://msdn2.microsoft.com/en-us/library/76e4d2xw.aspx
ClickOnce, MSBuild and CAB
April 2nd, 2006
Lately, I’ve been wondering about the strength of ClickOnce
applied in enterprise applications. In these scenarios, the deployment of a
Smart Client application involves more than a simple XCOPY. Let’s enumerate
some of them:
- multiple environments (dev,
qa, staging, production) - prerequisites
- CAS permissions
- run as non-admin
- pre and post-deployment
tasks - partial deploys (only a set
of modules) - rollbacks
- segmented deploy (e.g. only
deploy a beta testers group) - versioning
The truth is that ClickOnce has been designed with some of
these things in mind out of the box but not all of them. Fortunately the ClickOnce
world does not finish in the “Visual Studio 2005 Publish tabâ€. We have MSBuild
tasks,
mage.exe
and mageui.exe
to overcome the advanced scenarios.
A great
sample showing the advanced features has been written by Mike Bouck.
Based on this and my previous post about dynamic
modules, I’m planning to write a sample consisting of a CAB application leveraging ClickOnce
and CAB Module Loader to download
modules on-demand and load them dynamically.