WixSharp.Project.GenerateProductGuids C# (CSharp) Method

GenerateProductGuids() public method

Generates all missing product Guids (e.g. UpgradeCode and ProductId).

Wix# compiler call this method just before building the MSI. However you can call it any time if you want to preview auto-generated Guids.

public GenerateProductGuids ( ) : void
return void
        public void GenerateProductGuids()
        {
            if (!GUID.HasValue)
                GUID = Guid.NewGuid();

            if (!UpgradeCode.HasValue)
                UpgradeCode = GUID;

            if (!ProductId.HasValue)
                ProductId = CalculateProductId(guid.Value, Version);
        }

Usage Example

Example #1
0
        private static void Main()
        {
            const string mode =
            #if DEBUG
            "Debug";
            #elif FULL
                "Full";
            #else
            "Release";
            #endif
            const string rootSolutionDirectory = @"..\..";
            var octoStyleOutputPath = Path.Combine(rootSolutionDirectory, @"src\OctoStyle.Console\bin\", mode);

            var project = new Project(
                "OctoStyle",
                new Dir(
                    @"%ProgramFiles%\Omego2K\OctoStyle",
                    new File(Path.Combine(octoStyleOutputPath, "OctoStyle.Console.exe")),
                    new File(Path.Combine(octoStyleOutputPath, "OctoStyle.Core.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "NDesk.Options.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "Octokit.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "StyleCop.CSharp.Rules.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "StyleCop.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "StyleCop.CSharp.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "OMetaSharp.dll")),
                    new File(Path.Combine(octoStyleOutputPath, "SharpDiff.dll"))));

            project.GenerateProductGuids();

            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;

            const string wixToolsLocation = @"packages\WiX.3.9.2\tools";

            Compiler.WixLocation = Path.Combine(rootSolutionDirectory, wixToolsLocation);
            Compiler.WixSdkLocation = Path.Combine(rootSolutionDirectory, wixToolsLocation, "sdk");
            Compiler.BuildMsi(project);
        }
All Usage Examples Of WixSharp.Project::GenerateProductGuids