Skip to content

Commit

Permalink
Re-enable insignificant zeros in PackageVersion
Browse files Browse the repository at this point in the history
Closes 8589
  • Loading branch information
robmen committed Oct 4, 2024
1 parent 61d21b6 commit 3fd3204
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/wix/WixToolset.Core/ExtensibilityServices/BackendHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,13 @@ public bool TryParseMsiProductVersion(string version, bool strict, out string pa
{
if (WixVersion.TryParse(version, out var wixVersion) && wixVersion.HasMajor && wixVersion.Major < 256 && wixVersion.Minor < 256 && wixVersion.Patch < 65536 && wixVersion.Labels == null && String.IsNullOrEmpty(wixVersion.Metadata))
{
parsedVersion = $"{wixVersion.Major}.{wixVersion.Minor}";

if (strict || wixVersion.HasPatch)
if (strict)
{
parsedVersion += $".{wixVersion.Patch}";
parsedVersion = $"{wixVersion.Major}.{wixVersion.Minor}.{wixVersion.Patch}";
}

if (!strict && wixVersion.HasRevision)
else
{
parsedVersion += $".{wixVersion.Revision}";
parsedVersion = wixVersion.Prefix.HasValue ? version.Substring(1) : version;
}

return true;
Expand Down
56 changes: 56 additions & 0 deletions src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,62 @@ public void CanBuildMsiWithPrefixedVersion()
}
}

[Fact]
public void CanBuildMsiWithInsignificantZeroesVersion()
{
var folder = TestData.Get(@"TestData");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var msiPath = Path.Combine(baseFolder, "bin", "test1.msi");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "Version", "PackageWithReplaceableVersion.wxs"),
"-bindpath", Path.Combine(folder, "SingleFile", "data"),
"-intermediateFolder", intermediateFolder,
"-d", "Version=0001.002.0003.04",
"-o", msiPath
});

result.AssertSuccess();

var productVersion = GetProductVersionFromMsi(msiPath);
Assert.Equal("0001.002.0003.04", productVersion);
}
}

[Fact]
public void CanBuildMsiWithPrefixedInsignificantZeroesVersion()
{
var folder = TestData.Get(@"TestData");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var msiPath = Path.Combine(baseFolder, "bin", "test1.msi");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "Version", "PackageWithReplaceableVersion.wxs"),
"-bindpath", Path.Combine(folder, "SingleFile", "data"),
"-intermediateFolder", intermediateFolder,
"-d", "Version=v01.002.0003.000004",
"-o", msiPath
});

result.AssertSuccess();

var productVersion = GetProductVersionFromMsi(msiPath);
Assert.Equal("01.002.0003.000004", productVersion);
}
}

[Fact]
public void CanBuildMsiWithPrefixedVersionBindVariable()
{
Expand Down

0 comments on commit 3fd3204

Please sign in to comment.