Yongq Wong

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Visual studio 打包程序时添加自定义的系统必备组件

在使用Visual studio自带打包工具来制作安装包,有时需要添加自定义的系统必备组件。本文以要添加系统必备组件: Microsoft Access Database Engine 2010为例。则需要如下步骤来完成:

1. 新建文件夹AccessDatabaseEngine,  将它放在C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages目录下。复制安装程序AccessDatabaseEngine.exe到此文件夹。

2. 整个组件的文件结构如下:

  • 目录:C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages
    • 文件夹:AccessDatabaseEngine
      • 文件夹:en
        • package.xml
      • AccessDatabaseEngine.exe
      • product.xml

3. 新建产品清单(product.xml) 和程序包清单(package.xml)。

  • 产品清单(product.xml)内容
<?xml version="1.0" encoding="utf-8" ?> 

<Product
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  ProductCode="AccessDatabaseEngine"
>
  <!-- Defines list of files to be copied on build -->
  <PackageFiles>
    <PackageFile Name="AccessDatabaseEngine.exe" 
      HomeSite="https://www.microsoft.com/en-us/download/confirmation.aspx?id=13255" 
      />
  </PackageFiles>

  <InstallChecks>
    <RegistryCheck Property="ACEValue" Key="HKLM\SOFTWARE\Classes\Microsoft.ACE.OLEDB.12.0"/> 
  </InstallChecks>

  <Commands Reboot="Defer">
    <Command PackageFile="AccessDatabaseEngine.exe">

      <!-- These checks determine whether the package is to be installed -->

      <InstallConditions>
        <!-- Comment out the below BypassIf entry if you want install the 32bit version CRRuntime redist in the target machine -->      
        <BypassIf Property="ACEValue" Compare="ValueExists"/>

      </InstallConditions>

      <ExitCodes>
        <ExitCode Value="0" Result="Success"/>
        <ExitCode Value="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
      </ExitCodes>

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

 

  • 程序包清单(package.xml),该文件放在新建文件夹“en”下。
<?xml version="1.0" encoding="utf-8" ?> 

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

  <!-- Defines a localizable string table for error messages and url's  -->
  <Strings>
    <String Name="DisplayName">Access Database Engine</String>
    <String Name="Culture">en</String>
    <String Name="Anunexpected">An unexpected exit code was returned from the installer. The installation failed.</String>
    <String Name="AdminRequired">You do not have the permissions required to install this application.  Please contact your administrator.</String>
  </Strings>

</Package>

 

4.  在 visual studio在安装项目的系统必备组件中可以查看到新建的Access Database Engine 组件。

 

posted on 2020-06-30 16:15  Yongq wong  阅读(729)  评论(0编辑  收藏  举报