Skip to content

Commit

Permalink
Lock looking for WiX binaries exclusively to packages folder
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwille committed Jun 7, 2023
1 parent f12a3d3 commit bdb3235
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ILSpy.Installer/setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,41 @@ static public void Main()
new FileShortcut("ILSpy", @"%ProgramMenu%")
};

Compiler.WixLocation = GetWixBinLocationForPackage();
Compiler.BuildMsi(project, Path.Combine(Environment.CurrentDirectory, "wix", $"ILSpy-{AppPackage.Version}-{buildPlatform}.msi"));
}

// Copied from https://github.com/oleg-shilo/wixsharp/blob/c4f8615ce8e47c7162edb30656669d0d326f79ff/Source/src/WixSharp/Utilities/WixBinLocator.cs#L117
private static string GetWixBinLocationForPackage()
{
//The global packages may be redirected with environment variable
//https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders

string wixBinPackageDir;
var nugetPackagesEnvironmentVariable = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
if (nugetPackagesEnvironmentVariable.IsNotEmpty() && Directory.Exists(nugetPackagesEnvironmentVariable))
{
wixBinPackageDir = Path.Combine(nugetPackagesEnvironmentVariable, "wixsharp.wix.bin");
}
else
{
wixBinPackageDir = @"%userprofile%\.nuget\packages\wixsharp.wix.bin".ExpandEnvVars();
}

if (Directory.Exists(wixBinPackageDir))
{
Version greatestWixBinVersion = System.IO.Directory.GetDirectories(wixBinPackageDir)
.Select(dirPath => new Version(dirPath.PathGetFileName()))
.OrderDescending()
.FirstOrDefault();

if (greatestWixBinVersion != null)
{
return wixBinPackageDir.PathJoin(greatestWixBinVersion.ToString(), @"tools\bin");
}
}

return "";
}
}
}

0 comments on commit bdb3235

Please sign in to comment.