Skip to content

Commit

Permalink
Fix globbing x64 components
Browse files Browse the repository at this point in the history
Fix globbing payloads with duplicate file names (different folder)
Fix zip unit test
  • Loading branch information
nirbar committed Nov 26, 2024
1 parent d7d45f4 commit 6426d94
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/PanelSwCustomActions/Unzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ HRESULT CUnzip::ExecuteOneZip(::com::panelsw::ca::ZipDetails* pDetails)
fileName.setFileName(szEntryName);
ReleaseNullMem(szEntryName);

hr = StrAnsiAllocString(&szEntryName, fileEntry.Path(), 0, CP_UTF8);
hr = StrAnsiAllocString(&szEntryName, (LPCWSTR)fileEntry.Path(), 0, CP_UTF8);
ExitOnFailure(hr, "Failed allocating string");

file.setFileName(szEntryName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using WixToolset.Data;
using WixToolset.Data.Symbols;
using WixToolset.Extensibility;
Expand All @@ -14,7 +15,7 @@

namespace PanelSw.Wix.Extensions
{
public class PanelSwWiOptimizer : BaseOptimizerExtension
public class PanelSwOptimizer : BaseOptimizerExtension
{
private IParseHelper _parseHelper;
private IMessaging _messaging;
Expand Down Expand Up @@ -91,14 +92,13 @@ private void ResolveFileGlob()
foreach (FilePatternMatch filePattern in patternMatching.Files)
{
string fullPath = Path.Combine(folder, filePattern.Path);
Uri uri = new Uri(fullPath);
fullPath = uri.AbsolutePath;
fullPath = Path.GetFullPath(fullPath);

string recursiveDir = Path.GetDirectoryName(filePattern.Path);

if (!string.IsNullOrEmpty(glb.PayloadGroup_))
{
Identifier id = _parseHelper.CreateIdentifier("glb", glb.PayloadGroup_, Path.GetFileName(fullPath));
Identifier id = _parseHelper.CreateIdentifier("glb", glb.PayloadGroup_, recursiveDir, Path.GetFileName(fullPath));
string fileName = Path.Combine(recursiveDir, Path.GetFileName(fullPath));

section.AddSymbol(new WixBundlePayloadSymbol(glb.SourceLineNumbers, id) { SourceFile = new IntermediateFieldPathValue() { Path = fullPath }, Name = fileName });
Expand All @@ -113,8 +113,24 @@ private void ResolveFileGlob()
}
Identifier id = _parseHelper.CreateIdentifier("glb", directoryId, Path.GetFileName(fullPath));

section.AddSymbol(new ComponentSymbol(glb.SourceLineNumbers, id) { DirectoryRef = directoryId, KeyPath = id.Id, KeyPathType = ComponentKeyPathType.File });
section.AddSymbol(new FileSymbol(glb.SourceLineNumbers, id) { Source = new IntermediateFieldPathValue() { Path = fullPath }, Name = Path.GetFileName(fullPath), ComponentRef = id.Id, DirectoryRef = directoryId });
section.AddSymbol(new ComponentSymbol(glb.SourceLineNumbers, id)
{
ComponentId = "*",
DirectoryRef = directoryId,
KeyPath = id.Id,
KeyPathType = ComponentKeyPathType.File,
Location = ComponentLocation.LocalOnly,
Win64 = _context.Platform == Platform.ARM64 || _context.Platform == Platform.X64,
});

section.AddSymbol(new FileSymbol(glb.SourceLineNumbers, id)
{
Source = new IntermediateFieldPathValue() { Path = fullPath },
Name = Path.GetFileName(fullPath),
ComponentRef = id.Id,
DirectoryRef = directoryId,
Attributes = FileSymbolAttributes.None | FileSymbolAttributes.Vital,
});
if (!string.IsNullOrEmpty(glb.ComponentGroup_))
{
_parseHelper.CreateComplexReference(section, glb.SourceLineNumbers, ComplexReferenceParentType.ComponentGroup, glb.ComponentGroup_, null, ComplexReferenceChildType.Component, id.Id, false);
Expand Down
2 changes: 1 addition & 1 deletion src/PanelSwWixExtension/PanelSwWixExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PanelSwWixExtension()
typeof(PanelSwWixCompiler),
typeof(PanelSwWixExtData),
typeof(PanelSwBurnBackendBinder),
typeof(PanelSwWiOptimizer),
typeof(PanelSwOptimizer),
#if EnableZipContainer
typeof(PanelSwBurnContainer),
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/TidyBuild.custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)TidyBuild.user.props" Condition="Exists('$(MSBuildThisFileDirectory)TidyBuild.user.props')"/>
<PropertyGroup>
<FullVersion>5.4.0</FullVersion>
<FullVersion>5.4.1</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand Down
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions src/UnitTests/ZipFileUT/ZipFileUT.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

<PanelSW:ZipFile SourceFolder="[INSTALLFOLDER]" FilePattern="*.log" TargetZipFile="[INSTALLFOLDER]1.logs.zip" Condition="Not Installed"/>
<PanelSW:ZipFile SourceFolder="[INSTALLFOLDER]" TargetZipFile="[INSTALLFOLDER]1.zip" Condition="Not Installed"/>
<PanelSW:ZipFile SourceFolder="[ORIGINAL_DATABASE_DIR_]" TargetZipFile="[OriginalDatabase].zip" Condition="Not Installed" ErrorHandling="prompt"/>
<PanelSW:ZipFile SourceFolder="[ORIGINAL_DATABASE_DIR_]" TargetZipFile="[INSTALLFOLDER]origdir.zip" Condition="Not Installed" ErrorHandling="prompt"/>
<PanelSW:Unzip TargetFolder="[INSTALLFOLDER]" ZipFile="[INSTALLFOLDER]1.zip" OverwriteMode="Unmodified" Condition="Not Installed"/>
<PanelSW:Unzip TargetFolder="[WindowsVolume]1\2\3" ZipFile="[INSTALLFOLDER]1.zip" Overwrite="yes" Condition="Not Installed"/>
<PanelSW:Unzip TargetFolder="[WindowsVolume]1\2\4" ZipFile="[INSTALLFOLDER]1.zip" Overwrite="yes" DeleteZip="yes" CreateRootFolder="no" Condition="Not Installed"/>
<PanelSW:Unzip TargetFolder="[INSTALLFOLDER]npp" ZipFile="[#iconsext.zip]" OverwriteMode="Always" Condition="&amp;ProductFeature &gt;= 3"/>
<PanelSW:Unzip TargetFolder="[INSTALLFOLDER]msi" ZipFile="[OriginalDatabase].zip" OverwriteMode="Always" Condition="&amp;ProductFeature &gt;= 3" ErrorHandling="prompt"/>
<PanelSW:Unzip TargetFolder="[INSTALLFOLDER]msi" ZipFile="[INSTALLFOLDER]origdir.zip" OverwriteMode="Always" DeleteZip="yes" Condition="&amp;ProductFeature &gt;= 3" ErrorHandling="prompt"/>

<ComponentGroup Id="ProductComponents">
<Component Directory="INSTALLFOLDER">
Expand Down

0 comments on commit 6426d94

Please sign in to comment.