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 內容如下

<?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 內容如下

<?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 節如下

<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的安裝包。
http://files.cnblogs.com/binsys/120311BootstrapperForWIC.7z