oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.11k stars 176 forks source link

Project GUID in Wix# script gets assigned as upgrade code and project ID is differently generated #1610

Closed abskulkarni closed 1 month ago

abskulkarni commented 2 months ago

Hi @oleg-shilo I am trying to set a fixed product code for my product in wix sharp script.

I am using project.GUID = new Guid("DD3E7EFF-26F7-4A16-A905-F21A36D0C66B");

But I see this GUID has been assigned as its upgrade code in WXS file and project's ID is newly generated GUID with difference in its minor part as seen in below screen shots.

image

WXS changed to below : (GUID given in script becomes its upgrade code & it generates a project ID on its own from somewhere with difference in minor part of GUID given in script)

image

If you see MSI properties in ORCA tool, you can see these two properties:

image

oleg-shilo commented 2 months ago

That's correct. But why is it a problem? project.GUID is used to auto-generate all required MSI identities of your product. It is used as a seed value. Thus once you assign your GUID you don't need to change it ever. If you are building a setup for a new product version, WixSharp will ensure that the UpgradeCode stays the same but the ProductId is incremented.

So if you prefer to set these identities manually and update them every time you build a new setup version and rely on your memory to not forget to do then :) ... then you can start setting ProductId and Upgrade code manually.

You can read more about that here: https://github.com/oleg-shilo/wixsharp/wiki/Deployment-scenarios#identities-and-naming

But, of course, if you find a problem with the algorithm then I can have a look at it.

abskulkarni commented 2 months ago

I am not sure I got the concept of various IDs used and their purposes. May be an example of some product like Notepad++ with whole cycle of installing, upgrading may help.

But we figured out that we need explicit product id to be set to a defined value so that future MSIs will be able to know if product is already installed or not.

oleg-shilo commented 2 months ago

Any code sample from the samples library has IDs set correctly. This one even shows how to build two versions of MSI as part of the upgrade.

image

In a nutshell the messy MSI ID concept is handled in WixSharp transparently:

v1.0.0

var project = new ManagedProject(...);
project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
project.Version = new Version("1.0.0");
. . .

v2.0.0

var project = new ManagedProject(...);
project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
project.Version = new Version("2.0.0");
. . .

v2.0.0 and v1.0.0 MSIs have the same upgrade code but different product ID. Exactly as it is supposed to be. You can always check the generated IDs from the build output: image

But we figured out that we need explicit product id... Most likely the problem you are dealing with is not caused by that. But of course, I have no evidence of that. :)

Anyway, you can set the ids directly to the project object if you are not happy with the default approach.

project.ProductId
project.UpgradeCode