WIX Autogenerate GUID *?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 20:04:33

Product/@Id="*" randomly generates a new GUID, which is sufficient for product codes. Component/@Guid="*" calculates a GUID that stays the same as long as your target path stays the same, which is necessary to comply with component rules.

Product ID (ProductCode) uniquely identifies everything in the installer package as a particular product. When you search to see if a previous version is installed search is performed on the Upgrade Code. For all items found with the particular Upgrade code Installer will note each of the Product Codes as different incarnations of the same product. So you can say a different product code of same upgrade code identifies different incarnations (versions if you will, of the same product).

From http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Auto-generated-vs-statically-assigned-GUIDs-td4670083.html:

If you want to ship updates as MSP's (Small Update or Minor Upgrade in Microsoft terminology) don't use auto-generated GUIDs. If you're only ever going to ship updates as MSI's (Major Upgrades) you need to change the Product Code every time anyway so auto-generating is fine. See -> http://msdn.microsoft.com/en-us/library/aa370579.aspx

This quick guideline can help you. Be sure the check the MSDN links referenced from that article for better understanding how it works.

What links other versions to new version is the upgrade code. That should not change for the same product assuming you want to use the upgrade functionality. Otherwise it is almost like each version is a different product

This may be somewhat misguided but I did have a lot of files I was importing as components into a new WiX Product.wxs file. I discovered after I had created all the components with Guid="*" that when trying to build the installer, WiX reported the following error for each component:

The component 'AjaxControlToolkit.dll' has a key file with path 'TARGETDIR\ajaxcontroltoolkit.dll'. Since this path is not rooted in one of the standard directories (like ProgramFilesFolder), this component does not fit the criteria for having an automatically generated guid.

I used the following PowerShell script to assign a new guid to each component. Be aware that this script will modify the Product.wxs file directly and a backup of the file should be kept in case something goes wrong:

(Get-Content Product.wxs) | 
Foreach-Object { $guid = [guid]::NewGuid().ToString(); $_ -replace 'Guid="\*"',"Guid=""$guid"""}  | 
Out-File Product.wxs

You must set a value to the property "UpgradeCode" in your product element. Which must be unique and must remain the same for all of your future builds for the setup. The upgrade code is responsible for letting an installations upgrade or not upgrade depending on the setup versions being executed.

ie:-

<Product Id="*" Name="My Application" Language="1033" Version="1.1.0" Manufacturer="Myself :p" UpgradeCode="{561DA858-5398-4B87-8F3A-8B8BB12650F6}"> 

NOT maintaining a static upgrade code will result duplicating identical installations.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!