VS2010 Visual Studio Installer 项目 系统必备(Bootstrapper) 自定义 之 WIC(Windows 图像处理组件)

20130120 更新

Package.xml 内 PackageFile 节点 的 PublicKey 属性来源为(图片看不完成的右键另存为):

去掉hash属性,更改为使用公钥。

大家可能遇到过一种情况,在开发.NET 4项目后,用 Visual Studio Installer 项目 类型进行项目安装打包,

1.在 安装项目上 点右键
2.选择 属性
3.选择 系统必备
4.选择 如下图

打包之后在 Windows Server 2003 或者 Windows XP <=SP2 部署环境时,显示缺少 "Windows 图像处理组件"(WIC)。

一台两台机器的话就直接到微软网站上下载了,但如果N多(N>10)每台手动装很不方便,于是产生此文。WIC组件XP SP3以上自带,.NET 4.0依赖此组件。我打算把他添加到系统必备列表。

经过Google后,得到 "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\" 目录与此有关(注:我的VS2010安装在C盘默认目录,下同)。

MSDN相关资料:
添加自定义系统必备 http://msdn.microsoft.com/zh-cn/library/ms165429(v=vs.80).aspx
创建引导程序包 http://msdn.microsoft.com/zh-cn/library/ms165429.aspx
产品和包架构引用 http://msdn.microsoft.com/zh-cn/library/ms229223.aspx

1.在 "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\" 目录下建立 WindowsImagingComponent 组件目录。
2.建立如下目录文件结构

├─WindowsImagingComponent
│  │  product.xml
│  │
│  ├─en
│  │      eula.txt
│  │      package.xml
│  │      wic_x64_enu.exe
│  │      wic_x86_enu.exe
│  │
│  └─zh-Hans
│          eula.txt
│          Package.xml
│          wic_x64_chs.exe
│          wic_x86_chs.exe

3.编辑文件 product.xml 内容如下

<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="Windows.Imaging.Component" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
</Product>

4.编辑 zh-Hans  目录下 Package.xml 内容如下

 

Package.xml
<?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="eula.txt"/>
        <PackageFile Name="wic_x64_chs.exe" HomeSite="WICRedistX64" PublicKey="3082010A0282010100CD819638AE5CA2F2C1DFDED0AB958DD63C9D1F8BC35D862E5DF0B172F5ABAC886AB5DAB1227B0BC8C8A54B915E2213E9F9F5239DB5F46E76AEEFEEA43CC7C4C0595C3FABB3733326A662816179A162F46E8895D06EDDC79FD2A451117661BA708A65A1961689A75D81D04466E5DB569E40CAFCDC76242E443000E5D67D7B9511D5581DA3E84F0BC988DCA2D653996CCA63CA996A9A925E4C4D11E82FD35B5B5E5F52A3732DA5BB84450D8C191576CB08DA9AA67015E84DEC69FD5DB26B8FED295137388BC6464915945098B0F468A4D7DE097167749E778C1D856B97EAE75F45CCE0E6710DD16300937B31988E0BB413BDB3D0EEF1DF21EEA96061EE37433DC30203010001" />
        <PackageFile Name="wic_x86_chs.exe" HomeSite="WICRedistX86" PublicKey="3082010A0282010100CD819638AE5CA2F2C1DFDED0AB958DD63C9D1F8BC35D862E5DF0B172F5ABAC886AB5DAB1227B0BC8C8A54B915E2213E9F9F5239DB5F46E76AEEFEEA43CC7C4C0595C3FABB3733326A662816179A162F46E8895D06EDDC79FD2A451117661BA708A65A1961689A75D81D04466E5DB569E40CAFCDC76242E443000E5D67D7B9511D5581DA3E84F0BC988DCA2D653996CCA63CA996A9A925E4C4D11E82FD35B5B5E5F52A3732DA5BB84450D8C191576CB08DA9AA67015E84DEC69FD5DB26B8FED295137388BC6464915945098B0F468A4D7DE097167749E778C1D856B97EAE75F45CCE0E6710DD16300937B31988E0BB413BDB3D0EEF1DF21EEA96061EE37433DC30203010001" />
    </PackageFiles>
    <InstallChecks>
        <FileCheck Property="VersionPMHdll32" FileName="PhotoMetadataHandler.dll" SearchPath="system32" SpecialFolder="WindowsFolder" />
        <FileCheck Property="VersionPMHdll64" FileName="PhotoMetadataHandler.dll" SearchPath="system64" SpecialFolder="WindowsFolder" />
    </InstallChecks>
    <Commands Reboot="Defer">
        <Command PackageFile="wic_x86_chs.exe"
          Arguments="/quiet /norestart"
          EstimatedInstalledBytes="1200000"
          EstimatedTempBytes="3700000"
          EstimatedInstallSeconds="60">
            <InstallConditions>
                <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel" />
                <BypassIf Property="VersionPMHdll32" Compare="VersionGreaterThanOrEqualTo" Value="6.0.5840.16388" />
                <BypassIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" />
                <!-- Requires the user to be an admin user when installing the prerequisite -->
                <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
            </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>
        <Command PackageFile="wic_x64_chs.exe"
          Arguments="/quiet /norestart"
          EstimatedInstalledBytes="1200000"
          EstimatedTempBytes="6400000"
          EstimatedInstallSeconds="60">
            <InstallConditions>
                <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64" />
                <BypassIf Property="VersionPMHdll64" Compare="VersionGreaterThanOrEqualTo" Value="6.0.5840.16388"/>
                <BypassIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2"/>
                <!-- Requires the user to be an admin user when installing the prerequisite -->
                <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
            </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>
    <Strings>
        <String Name="Culture">zh-Hans</String>
        <String Name="DisplayName">Windows 图像处理组件</String>
        <String Name="AdminRequired">安装 Windows 图像处理组件 必须要有管理员权限。请与管理员联系。</String>
        <String Name="GeneralFailure">尝试安装 Windows 图像处理组件 时失败。</String>

        <!-- http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=8e011506-6307-445b-b950-215def45ddd8 -->
        <String Name="WICRedistX86">http://download.microsoft.com/download/f/f/1/ff178bb1-da91-48ed-89e5-478a99387d4f/wic_x86_chs.exe</String>

        <!-- http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=f64654ac-6e26-41d9-a90a-0e7783b864ee -->
        <String Name="WICRedistX64">http://download.microsoft.com/download/6/4/5/645fed5f-a6e7-44d9-9d10-fe83348796b0/wic_x64_chs.exe</String>
    </Strings>
</Package>

 

5. 编辑 en 目录下 package.xml 内容如下

package.xml
<?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="eula.txt"/>
<PackageFile Name="wic_x64_enu.exe" HomeSite="WICRedistX64" PublicKey="3082010A0282010100CD819638AE5CA2F2C1DFDED0AB958DD63C9D1F8BC35D862E5DF0B172F5ABAC886AB5DAB1227B0BC8C8A54B915E2213E9F9F5239DB5F46E76AEEFEEA43CC7C4C0595C3FABB3733326A662816179A162F46E8895D06EDDC79FD2A451117661BA708A65A1961689A75D81D04466E5DB569E40CAFCDC76242E443000E5D67D7B9511D5581DA3E84F0BC988DCA2D653996CCA63CA996A9A925E4C4D11E82FD35B5B5E5F52A3732DA5BB84450D8C191576CB08DA9AA67015E84DEC69FD5DB26B8FED295137388BC6464915945098B0F468A4D7DE097167749E778C1D856B97EAE75F45CCE0E6710DD16300937B31988E0BB413BDB3D0EEF1DF21EEA96061EE37433DC30203010001" />
<PackageFile Name="wic_x86_enu.exe" HomeSite="WICRedistX86" PublicKey="3082010A0282010100CD819638AE5CA2F2C1DFDED0AB958DD63C9D1F8BC35D862E5DF0B172F5ABAC886AB5DAB1227B0BC8C8A54B915E2213E9F9F5239DB5F46E76AEEFEEA43CC7C4C0595C3FABB3733326A662816179A162F46E8895D06EDDC79FD2A451117661BA708A65A1961689A75D81D04466E5DB569E40CAFCDC76242E443000E5D67D7B9511D5581DA3E84F0BC988DCA2D653996CCA63CA996A9A925E4C4D11E82FD35B5B5E5F52A3732DA5BB84450D8C191576CB08DA9AA67015E84DEC69FD5DB26B8FED295137388BC6464915945098B0F468A4D7DE097167749E778C1D856B97EAE75F45CCE0E6710DD16300937B31988E0BB413BDB3D0EEF1DF21EEA96061EE37433DC30203010001" />
</PackageFiles>
<InstallChecks>
<FileCheck Property="VersionPMHdll32" FileName="PhotoMetadataHandler.dll" SearchPath="system32" SpecialFolder="WindowsFolder" />
<FileCheck Property="VersionPMHdll64" FileName="PhotoMetadataHandler.dll" SearchPath="system64" SpecialFolder="WindowsFolder" />
</InstallChecks>
<Commands Reboot="Defer">
<Command PackageFile="wic_x86_enu.exe"
Arguments
="/quiet /norestart"
EstimatedInstalledBytes
="1200000"
EstimatedTempBytes
="3700000"
EstimatedInstallSeconds
="60">
<InstallConditions>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel" />
<BypassIf Property="VersionPMHdll32" Compare="VersionGreaterThanOrEqualTo" Value="6.0.5840.16388" />
<BypassIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" />
<!-- Requires the user to be an admin user when installing the prerequisite -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
</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>
<Command PackageFile="wic_x64_enu.exe"
Arguments
="/quiet /norestart"
EstimatedInstalledBytes
="1200000"
EstimatedTempBytes
="6400000"
EstimatedInstallSeconds
="60">
<InstallConditions>
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64" />
<BypassIf Property="VersionPMHdll64" Compare="VersionGreaterThanOrEqualTo" Value="6.0.5840.16388"/>
<BypassIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2"/>
<!-- Requires the user to be an admin user when installing the prerequisite -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
</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>
<Strings>
<String Name="Culture">en</String>
<String Name="DisplayName">Windows Imaging Component</String>
<String Name="AdminRequired">Administrator permissions are required to install Windows Imaging Component. Contact your administrator.</String>
<String Name="GeneralFailure">A failure occurred attempting to install Windows Imaging Component.</String>

<!-- http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8e011506-6307-445b-b950-215def45ddd8&displaylang=en -->
<String Name="WICRedistX86">http://download.microsoft.com/download/f/f/1/ff178bb1-da91-48ed-89e5-478a99387d4f/wic_x86_enu.exe</String>

<!-- http://www.microsoft.com/downloads/en/details.aspx?familyid=F64654AC-6E26-41D9-A90A-0E7783B864EE&displaylang=en -->
<String Name="WICRedistX64">http://download.microsoft.com/download/6/4/5/645fed5f-a6e7-44d9-9d10-fe83348796b0/wic_x64_enu.exe</String>
</Strings>
</Package>

其中 两个 eula.txt 是各自语言的授权协议,不用关注,几个exe文件下载地址如下
wic_x64_chs.exe:http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=f64654ac-6e26-41d9-a90a-0e7783b864ee
wic_x86_chs.exe:http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=8e011506-6307-445b-b950-215def45ddd8

wic_x64_enu.exe:http://www.microsoft.com/downloads/en/details.aspx?familyid=F64654AC-6E26-41D9-A90A-0E7783B864EE&displaylang=en
wic_x86_enu.exe:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8e011506-6307-445b-b950-215def45ddd8&displaylang=en

真实地址在相关XML里已经标注,在打包文件中。

 

使用方法:

1.解压,把 WindowsImagingComponent 目录 剪贴到 "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\"  目录下。
2.下载上述四个文件依照目录结构放入WindowsImagingComponent子文件夹。
3.修改
   C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40 和
   C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40Client
   目录下的 Product.xml 文件

   在 每个文件的 RelatedProducts 节增加子节点 <DependsOnProduct Code="Windows.Imaging.Component" />
   修改后的 DotNetFX40 的 Product.xml 的 RelatedProducts  节如下
  

View Code
  <RelatedProducts>
<EitherProducts>
<DependsOnProduct Code="Microsoft.Windows.Installer.3.1" />
<DependsOnProduct Code="Microsoft.Windows.Installer.4.5" />
</EitherProducts>
<DependsOnProduct Code="Windows.Imaging.Component" />
<IncludesProduct Code=".NETFramework,Version=v4.0,Profile=Client" />
</RelatedProducts>


这时重新编译Installer项目,就会得到自动安装WIC的安装包。

 

https://files.cnblogs.com/binsys/120311BootstrapperForWIC.7z

 

posted @ 2012-03-11 20:04  BinSys  阅读(7005)  评论(3编辑  收藏  举报