Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support >2GB media volumes with MediaTemplate #4674

Open
wixbot opened this issue Feb 17, 2015 · 6 comments
Open

Support >2GB media volumes with MediaTemplate #4674

wixbot opened this issue Feb 17, 2015 · 6 comments
Assignees
Labels
binder breaking change Must happen in a .0 major release enhancement wip required This issue is complex enough that it requires a WiX Improvement Proposal to be accepted first

Comments

@wixbot
Copy link

wixbot commented Feb 17, 2015

I found incorrect behavior when creating a multi-volume installations (using MediaTemplate element). Value of attribute MaximumUncompressedMediaSize (which shall mean the size of the media, such as CD, DVD, DVD-DL, BD, etc.) is ignored when it is larger than 2 GB. This is due to a restriction on the size of the cab-files.

As a result, it is impossible to get media larger than 2GB. This solution is valid for the CD, but does not account for DVD, DVD-DL, BD. This is the problem: MaximumUncompressedMediaSize shall mean the size of the media (CD, DVD, DVD-DL, BD), but in fact it is the size of cab-file.

To solve this problem, I suggest using the following logic: take the sum of the size of cab-files and create another media if the sum exceeds the MaximumUncompressedMediaSize. Thus on the same media will be placed a few cab-files and can not be limited size of the media.

Below is my solution to the problem as a unified diff. I used the code from the repository https://github.com/wixtoolset/wix3.git, develop branch, commit is:
SHA-1: b2691192b83550c66baff879b249f51467286d41 * Merge pull request #143 from wixbuild/develop WixBuild: Version 3.9.901.0

Remains the problem with the placement of cab-files into directories that have names matching the labels of volumes of media.

 src/tools/wix/AutoMediaAssigner.cs | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/tools/wix/AutoMediaAssigner.cs b/src/tools/wix/AutoMediaAssigner.cs
index 38f921c..2232d8b 100644
--- a/src/tools/wix/AutoMediaAssigner.cs
+++ b/src/tools/wix/AutoMediaAssigner.cs
@@ -134,6 +134,9 @@ namespace Microsoft.Tools.WindowsInstallerXml
             ulong maxPreCabSizeInBytes;
             int maxPreCabSizeInMB = 0;
             int currentCabIndex = 0;
+            int currentDiskId = 1;
+            ulong currentUncompressedMediaSize = 0;
+            ulong maxUncompressedMediaSize = 0;

             MediaRow currentMediaRow = null;

@@ -162,6 +165,7 @@ namespace Microsoft.Tools.WindowsInstallerXml
                     maxPreCabSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize;
                 }

+                maxUncompressedMediaSize = (ulong)maxPreCabSizeInMB * 1024 * 1024;
                 maxPreCabSizeInBytes = (ulong)maxPreCabSizeInMB * 1024 * 1024;
             }
             catch (FormatException)
@@ -219,11 +223,21 @@ namespace Microsoft.Tools.WindowsInstallerXml
                 {
                     // Associate current file with last cab (irrespective of the size) and cab index is not incremented anymore.
                     FileRowCollection cabinetFileRow = (FileRowCollection)this.cabinets[currentMediaRow];
-                    fileRow.DiskId = currentCabIndex;
+                    fileRow.DiskId = currentDiskId;
                     cabinetFileRow.Add(fileRow);
                     continue;
                 }

+                // Update current media size
+                currentUncompressedMediaSize += (ulong)fileRow.FileSize;
+                
+                // Calculate media (removable volume) Id by maxUncompressedMediaSize 
+                if (currentUncompressedMediaSize > maxUncompressedMediaSize)
+                {
+                    currentDiskId++;
+                    currentUncompressedMediaSize = (ulong)fileRow.FileSize;
+                }
+                
                 // Update current cab size.
                 currentPreCabSize += (ulong)fileRow.FileSize;

@@ -233,7 +247,7 @@ namespace Microsoft.Tools.WindowsInstallerXml
                     currentMediaRow = this.AddMediaRow(mediaTable, ++currentCabIndex, mediaTemplateRow.CompressionLevel);

                     FileRowCollection cabinetFileRow = (FileRowCollection)this.cabinets[currentMediaRow];
-                    fileRow.DiskId = currentCabIndex;
+                    fileRow.DiskId = currentDiskId;
                     cabinetFileRow.Add(fileRow);
                     // Now files larger than MaxUncompressedMediaSize will be the only file in its cabinet so as to respect MaxUncompressedMediaSize
                     currentPreCabSize = (ulong)fileRow.FileSize;
@@ -249,7 +263,7 @@ namespace Microsoft.Tools.WindowsInstallerXml

                     // Associate current file with current cab.
                     FileRowCollection cabinetFileRow = (FileRowCollection)this.cabinets[currentMediaRow];
-                    fileRow.DiskId = currentCabIndex;
+                    fileRow.DiskId = currentDiskId;
                     cabinetFileRow.Add(fileRow);
                 }
             }

Originally opened by abzaver

@wixbot
Copy link
Author

wixbot commented Feb 17, 2015

Can you send a pull request instead? It'd be easier to discuss. See http://wixtoolset.org/development/.

Type changed from Feature to Bug

@wixbot
Copy link
Author

wixbot commented Mar 10, 2015

Pull request sended wixtoolset/wix3#208

Originally posted by abzaver
Status changed from Open to Untriaged

@wixbot
Copy link
Author

wixbot commented Mar 10, 2015

Will review PR.

AssignedTo set to bobarnson

@wixbot wixbot added this to the v3.x milestone Dec 20, 2015
@abzaver
Copy link

abzaver commented Aug 5, 2016

Hello @barnson! This problem will be (or can be) solved? Do you need more detail? Do you need something else to solve this problem?

@barnson
Copy link
Member

barnson commented Aug 7, 2016

@abzaver I agree with your comments in PR 208. MediaTemplate was designed to create multiple cabs, not multiple volumes. More extensive changes are necessary to make it support both. It's something that probably can be done only in v4.0.

@barnson barnson modified the milestones: v4.0, v3.x Aug 7, 2016
@barnson barnson assigned robmen and unassigned barnson Aug 5, 2020
@rseanhall rseanhall added this to To do in wix.4.0-preview.1 Jun 14, 2021
@robmen robmen added binder and removed linker labels Mar 20, 2022
@robmen robmen changed the title Incorrect behavior MediaTemplate element when creating multi-volume installations Support >2GB media volumes with MediaTemplate Jul 7, 2022
@barnson barnson modified the milestones: v4.0, v.Next Jul 21, 2022
@barnson barnson removed this from To do in wix.4.0-preview.1 Jul 21, 2022
@barnson barnson added wip required This issue is complex enough that it requires a WiX Improvement Proposal to be accepted first breaking change Must happen in a .0 major release labels Jul 21, 2022
@robmen
Copy link
Member

robmen commented Dec 13, 2022

As @barnson notes above, the resolution to this issue goes beyond MediaTemplate. This issue should be considered in relation to enhancing the concept of a "release" in the WiX language as a whole. That work will not be started in WiX v4.

@robmen robmen removed their assignment Dec 13, 2022
@barnson barnson self-assigned this May 2, 2023
@barnson barnson removed this from the v.Future milestone May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binder breaking change Must happen in a .0 major release enhancement wip required This issue is complex enough that it requires a WiX Improvement Proposal to be accepted first
Projects
None yet
Development

No branches or pull requests

4 participants