'Run a different installer with my ClickOnce installer

I was searching about how to do this but no avail.

I have a Winforms application and published it by mean of ClickOnce. It works, however, that application uses a device which needs a driver to be installed.

Currently, to use the application, after ClickOnce application installation user should run a "setup.exe" corresponding to the driver installation.

Is there a way to include that "setup.exe" as part of the ClickOnce installer? it can be run in first or last place. Order of installation is not relevant.

Thanks.



Solution 1:[1]

You need to create a bootstrapper package for your external setup.exe and install it as a prerequisite for the ClickOnce installer.

I've shared step by step example to show how you can do that. You can also find a few useful links to learn more at the bottom of the post.

Example - Create a custom bootstrapper package for custom setup.exe to install as a prerequisite using ClickOnce

Here is a step by step example which shows you how you can create a custom bootstrapper package and add it as a prerequisite to your ClickOnce setup. In the following example I assume you have a setup.exe and ExternalSetup.msi and name of your external dependency is ExternalSetup. Follow these steps:

  1. Go to the following folder:

    C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages
    
  2. Create the following file/folder structure:

    ExternalSetup             [Folder]
       en                     [Folder]
          eula.rtf            [File]
          package.xml         [File]
       ExternalSetup.msi      [File]
       setup.exe              [File]
       product.xml            [File]
    

    Note:

    • Per each culture of the custom installer you need a folder for enula and package.
    • eula.rtf is the end user license agreement of the external setup.
    • product.xml file describe the contents of the bootstrapper
    • package.xml file describe the localization-specific aspects of your package
    • If you don't have a .msi file, just ignore it.
  3. Here is the content for product.xml:

    <Product
      xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
      ProductCode="Microsoft.Sample.EULA">
     <!-- Defines the list of files to be copied on build. -->
     <PackageFiles CopyAllPackageFiles="true">
         <PackageFile Name="setup.exe"/>
         <PackageFile Name="ExternalSetup.msi"/>
     </PackageFiles>
    
     <!-- Defines how to run the Setup package.-->
     <Commands >
         <Command PackageFile = "setup.exe" Arguments=''>
             <ExitCodes>
                 <ExitCode Value="0" Result="Success" />
                 <ExitCode Value="-1" Result="Fail" String="Failed" />
                 <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
             </ExitCodes>
         </Command>
     </Commands>
    </Product>   
    
  4. Here is the content of package.xml:

    <Package
      xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
      Name="DisplayName"
      Culture="Culture"
      LicenseAgreement="eula.rtf">
     <PackageFiles>
         <PackageFile Name="eula.rtf"/>
     </PackageFiles>
    
     <!-- Defines a localizable string table for error messages. -->
     <Strings>
         <String Name="DisplayName">External Setup</String>
         <String Name="Culture">en</String>
         <String Name="Failed">Failed with -1.</String>
         <String Name="GeneralFailure">General failure.</String>
     </Strings>
    </Package>
    
  5. Add some test content for your eula.rtf.

  6. If VS is open, make sure you close close and reopen it.

  7. In your Windows Form Project which you want to distribute using ClickOnce, right-click and choose Properties, then go to Publish tab and click on Prerequisites... button, choose External Setup and select Download prerequisites from the same location and my application.

    enter image description here

  8. Build and Publish the application.

  9. Install the application from the publish.

More information

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1