Add EULA to ClickOnce Installation using Visual Studio 2015


ClickOnce technology is very smart and useful when you want simple, small and smart piece of software for deploying your Windows Forms or WFP application. This is specially useful if you deliver application which doesn’t require administrator rights during installation. ClickOnce is very powerful if you wants automatic update of your product, you can decide whenever the update appears before or after app is run. Also by using certificate you can deliver reliable and secure product to your customers. Long time ago I wrote detailed blog post  how to make ClickOnce deployment.

But one big thing is missing in ClickOnce deployment and for most of dev community is the feature which should be included by default. The feature which missing is “End User License Agreement” (EULA).  There is no simple way to implement it. Searching the internet I have found one forum post on Microsoft site describing how to implement it. Only way you can get ELUA at the beginning of the ClickOnce installation proces is by using it as prererquested component. Actually you build a redistributable component which would be seen as prerequsites dialog box under the publish window. To build custom prerequisites component you need a three files:

  1. Product.xml. – which is the file for bootstrapper and Visual Studio to show  a component in prerequisites dialog,
  2. Package.xml – which is the file containing all information about the component to be installed,
  3. EULA.txt – your ELUA text for user to accept.

Those three files must be installed in the location where all components are registered: C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages

For this blog post I have prepare demo sample which look like the following picture:

clickoncelicsl015

As can be seen, there is a two folders and one xml file. Each folder contains two files described earlier. Folders “en” and “de” means we are going to have EULA translated on two languages.

In order to successfully registered perquisites to be visible by Visual Studio we need to define proper content of the product.xml. The following xml code show content of our demo sample:

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

<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" ProductCode="EULA.Bootstrap.Component">
  <!-- Defines list of files to be copied on build -->
  <PackageFiles>
    <PackageFile Name="en/eula.txt"/>
  </PackageFiles>
  <Commands>
    <!-- Open eula.txt without any parameters -->
    <Command PackageFile="en/eula.txt" Arguments='' >
	
	  <!-- These checks determine whether the package is to be installed -->
	  <!-- No install conditions -->
      <InstallConditions>
        
      </InstallConditions>
	  
	   <!-- Exit codes -->
	   <ExitCodes>
        <ExitCode Value="0" Result="Success" />
        <DefaultExitCode Result="Fail" FormatMessageFromSystem="false" String="GeneralFailure" />
      </ExitCodes>

    </Command>
  </Commands>
</Product>

As we can see xml content is self-described, it contains product information, files to be installed, installation conditions and exit codes.

Each folder (en, de, …) contains package.xml file which holds localized messages and list of files to copied on build. The following xml content shows content of our en demo sample:

<?xml version="1.0" encoding="utf-8" ?>
<Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="ClickOnceWithLicenseAgreement" Culture="Culture" LicenseAgreement="eula.txt">
  <!-- Defines list of files to be copied on build -->
    <PackageFiles>
        <PackageFile Name="eula.txt"/>
    </PackageFiles>

  <!-- Defines a localizable string table for error messages and url's -->
  <Strings>
    <String Name="DisplayName">ClickOnceWithLicenseAgreement 1.0 (x86 and x64)</String>
    <String Name="Culture">en</String>

    <String Name="CancelFailure">User Refuse to Accept to ClickOnceWithLicenseAgreement End User License Agreement.</String>
    <String Name="GeneralFailure">A fatal error occurred during the installation of ELUA Component Execution</String>
    <String Name="AdminRequired">You do not have the permissions required to install this application.  Please contact your administrator.</String>
  </Strings>    
</Package>

The EULA.txt file contains the text user need to accept in order to install the product.

For this demo we created folder EULAPackage, put product.xml and two folders en and de because we are going to support two installation languages (see picture above).

Copy the EULAPackage folder in to : C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages

Now we have set all necessary information about ELUA component and can be included in our demo sample.

  1. Open Visual Studio 2015 and create new WFP application.Name it as “ClickOnceWithLicenseAgreement

clickoncelicsl011

2. Right-Click on the Project and select Property menu option, then select Publish tab item of the Project Property window.

clickoncelicsl016

3. Click on Prerequisites Button, then you will see your prerequisite component in the standard prerequisites lists.

clickoncelicsl013

4. Select ClickOnceWithLicenseAgreement component and click Ok button. Afterwards click Publish button to build installation package.

5. Open publish folder from the disk. DoubleClick Setup.exe and the ELUA window should be appeared:

clickoncelicsl014

6. Now user has two choises to accept or Refuse the EULA, which means install or not install the app.

Prerequested demo sample component for EULA can be downloaded from here.

Happy programming.

 

12 thoughts on “Add EULA to ClickOnce Installation using Visual Studio 2015

  1. I have an old ClickOnce app, compiled under VS2010. Windows 10 users cannot install using Edge. IE on W10 seems to work, usually. Any thoughts on this?

    • Hi Steve,

      I have no VS 2010 right now, but click once made by VS 2015 and .NET 4.5 works with Microsoft Edge.
      In your case I would check security parameters (UAC as well) on your Microsoft Edge.

      • Thank you. It seems the security parameters in Edge are a bit lacking? Many more choices in IE 11. I will check the UAC. Thank you!

  2. Thanks! Very useful post.
    One thing bothering me is automatic culture detection during installation of prerequisities. Actually there is no other possibility as setting the PublishLanguage in the Publish-Dialog in VS. Then you are forever bound to the combination install location/culture.
    I would prefer leaving the PublishLanguage not defined or neutral and starting another exe as prerequisity showing the EULA or even showing EULA during the first start of the app – see ApplicationDeployment class.

  3. I want to add ClickOnceWithLicenceAgreement on my Application Vsto Addin for Excel, but I don’t see “ClickOnceWithLicenceAgreement” in my prerequisite component however if I create an WPF application I see that. Maybe do you have an idea ?

    • Hi,

      maybe the different VS project uses different bootstraper locations. I would suggest to search all locations within Visual Studio. Try to search for some package which is Office Addin specific and which it is currently listed in the ClickOnce pre-requested modules.

      This is how I would try to solve this issue.

      Regards

  4. I tried this and keep getting error messages. Any ideas? Thanks
    Severity Code Description Project File Line Suppression State
    Error Cannot publish because a project failed to build. ClickOnceWithLicenseAgreement 1
    Error No ‘PublicKey’ or ‘Hash’ attribute specified for file ‘EULApackage\en/eula.txt’ in item ‘SampleApp End User License Agreement’. ClickOnceWithLicenseAgreement
    Error To enable ‘Download prerequisites from the same location as my application’ in the Prerequisites dialog box, you must download file ‘EULApackage\en/eula.txt’ for item ‘SampleApp End User License Agreement’ to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=616018. (ClickOnceWithLicenseAgreement
    Error Could not find required file ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages\EULApackage\en\eula.txt’ for item ‘SampleApp End User License Agreement’. ClickOnceWithLicenseAgreement

    I’ve tried downloading prerequisites from my machine as well as vendor website button but no luck
    I also added the required file (from the site below) to Windows Installer 4.5 , but not sure if that’s right
    https://msdn.microsoft.com/en-us/library/hh873130.aspx

  5. Pingback: VSTO Visio Addin – click once EULA depenency – Windows Questions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s