@joebigelow / wix / commits / c1f7e431

Modularize IconFile

Bob Arnson committed Sep 27, 2020 at 22:01 UTC c1f7e431ba09005bcc173bc251882d5761069376
10 files changed +76 -9
src/ca/netshortcuts.cpp
+4 -1
@@ -219,6 +219,8 @@ static HRESULT CreateUrl(
219
220 if (wzIconPath)
221 {
222 + WcaLog(LOGMSG_STANDARD, "Adding icon '%ls' index '%d'", wzIconPath, iconIndex);
223 +
224 hr = piURL->QueryInterface(IID_IPropertySetStorage, (void **)&piProperties);
225 ExitOnFailure(hr, "failed to get IPropertySetStorage for shortcut '%ls'", wzShortcutPath);
226
@@ -234,7 +236,7 @@ static HRESULT CreateUrl(
236 ppvar[0].vt = VT_I4;
237 ppvar[0].lVal = iconIndex;
238 ppvar[1].vt = VT_LPWSTR;
237 - ppvar[1].pwszVal = (LPWSTR)wzIconPath;
239 + ppvar[1].pwszVal = const_cast<LPWSTR>(wzIconPath);
240
241 hr = piStorage->WriteMultiple(2, ppids, ppvar, 0);
242 ExitOnFailure(hr, "failed to write icon storage for shortcut '%ls'", wzShortcutPath);
@@ -285,6 +287,7 @@ static HRESULT CreateLink(
287
288 if (wzIconPath)
289 {
290 + WcaLog(LOGMSG_STANDARD, "Adding icon '%ls' index '%d'", wzIconPath, iconIndex);
291 hr = piShellLink->SetIconLocation(wzIconPath, iconIndex);
292 ExitOnFailure(hr, "failed to set icon for shortcut '%ls'", wzShortcutPath);
293 }
src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico
Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico differ
src/test/WixToolsetTest.Util/TestData/InternetShortcut/PackageComponents.wxs
+4 -3
@@ -1,9 +1,10 @@
1 -<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
2 <Fragment>
3 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
4 <Component>
5 - <File Source="example.txt" />
6 - <util:InternetShortcut Id="wixshortcut" Name="WiX Toolset" Target="https://wixtoolset.org" />
5 + <File Id="Package.ico" Source="Package.ico" />
6 + <util:InternetShortcut Type="link" Name="WiX Toolset (link)" Target="https://wixtoolset.org" IconFile="[#Package.ico]" />
7 + <util:InternetShortcut Type="url" Name="WiX Toolset (url)" Target="https://wixtoolset.org" IconFile="[#Package.ico]" />
8 </Component>
9 </ComponentGroup>
10 </Fragment>
src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.en-us.wxl new
+11
@@ -0,0 +1,11 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<!--
4 +This file contains the declaration of all the localizable strings.
5 +-->
6 +<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7 +
8 + <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 + <String Id="FeatureTitle">MsiPackage</String>
10 +
11 +</WixLocalization>
src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico
Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico differ
src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.wxs new
+15
@@ -0,0 +1,15 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
2 + <Module Language="1033" Version="1.0.0.0" Id="InternetShortcutModule">
3 + <Package Id="047730a5-30fe-4a62-a520-da9381b8226a" Manufacturer="Example Corporation" />
4 +
5 + <ComponentGroupRef Id="ProductComponents" />
6 + </Module>
7 +
8 + <Fragment>
9 + <Directory Id="TARGETDIR" Name="SourceDir">
10 + <Directory Id="ProgramFilesFolder">
11 + <Directory Id="INSTALLFOLDER" Name="MergeModule" />
12 + </Directory>
13 + </Directory>
14 + </Fragment>
15 +</Wix>
src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/PackageComponents.wxs new
+11
@@ -0,0 +1,11 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
2 + <Fragment>
3 + <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
4 + <Component>
5 + <File Id="Package.ico" Source="Package.ico" />
6 + <util:InternetShortcut Type="link" Name="WiX Toolset (link)" Target="https://wixtoolset.org" IconFile="[#Package.ico]" />
7 + <util:InternetShortcut Type="url" Name="WiX Toolset (url)" Target="https://wixtoolset.org" IconFile="[#Package.ico]" />
8 + </Component>
9 + </ComponentGroup>
10 + </Fragment>
11 +</Wix>
src/test/WixToolsetTest.Util/UtilExtensionFixture.cs
+25 -3
@@ -73,7 +73,7 @@ namespace WixToolsetTest.Util
73 }
74
75 [Fact]
76 - public void CanBuildInternetShortcut()
76 + public void CanBuildInternetShortcutInProduct()
77 {
78 var folder = TestData.Get(@"TestData\InternetShortcut");
79 var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder });
@@ -85,8 +85,30 @@ namespace WixToolsetTest.Util
85 "CustomAction:Wix4CreateInternetShortcuts_X64\t3073\tWix4UtilCA_X64\tWixCreateInternetShortcuts\t",
86 "CustomAction:Wix4RollbackInternetShortcuts_X64\t3329\tWix4UtilCA_X64\tWixRollbackInternetShortcuts\t",
87 "CustomAction:Wix4SchedInternetShortcuts_X64\t1\tWix4UtilCA_X64\tWixSchedInternetShortcuts\t",
88 - "RemoveFile:wixshortcut\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tzf9nskwi.lnk|WiX Toolset.lnk\tINSTALLFOLDER\t2",
89 - "Wix4InternetShortcut:wixshortcut\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tINSTALLFOLDER\tWiX Toolset.lnk\thttps://wixtoolset.org\t0\t\t0",
88 + "RemoveFile:uisdCsU32.1i4Hebrg1N7E194zJQ8Y\tPackage.ico\thoiptxrr.url|WiX Toolset (url).url\tINSTALLFOLDER\t2",
89 + "RemoveFile:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A\tPackage.ico\tjcxd1dwf.lnk|WiX Toolset (link).lnk\tINSTALLFOLDER\t2",
90 + "Wix4InternetShortcut:uisdCsU32.1i4Hebrg1N7E194zJQ8Y\tPackage.ico\tINSTALLFOLDER\tWiX Toolset (url).url\thttps://wixtoolset.org\t1\t[#Package.ico]\t0",
91 + "Wix4InternetShortcut:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A\tPackage.ico\tINSTALLFOLDER\tWiX Toolset (link).lnk\thttps://wixtoolset.org\t0\t[#Package.ico]\t0",
92 + }, results.OrderBy(s => s).ToArray());
93 + }
94 +
95 + [Fact]
96 + public void CanBuildInternetShortcutInMergeModule()
97 + {
98 + var folder = TestData.Get(@"TestData\InternetShortcutModule");
99 + var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder });
100 +
101 + var results = build.BuildAndQuery(BuildX64, "Binary", "CustomAction", "RemoveFile", "Wix4InternetShortcut");
102 + WixAssert.CompareLineByLine(new[]
103 + {
104 + "Binary:Wix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\t[Binary data]",
105 + "CustomAction:Wix4CreateInternetShortcuts_X64\t3073\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixCreateInternetShortcuts\t",
106 + "CustomAction:Wix4RollbackInternetShortcuts_X64\t3329\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixRollbackInternetShortcuts\t",
107 + "CustomAction:Wix4SchedInternetShortcuts_X64\t1\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixSchedInternetShortcuts\t",
108 + "RemoveFile:uisdCsU32.1i4Hebrg1N7E194zJQ8Y.047730A5_30FE_4A62_A520_DA9381B8226A\tPackage.ico.047730A5_30FE_4A62_A520_DA9381B8226A\thoiptxrr.url|WiX Toolset (url).url\tINSTALLFOLDER.047730A5_30FE_4A62_A520_DA9381B8226A\t2",
109 + "RemoveFile:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A.047730A5_30FE_4A62_A520_DA9381B8226A\tPackage.ico.047730A5_30FE_4A62_A520_DA9381B8226A\tjcxd1dwf.lnk|WiX Toolset (link).lnk\tINSTALLFOLDER.047730A5_30FE_4A62_A520_DA9381B8226A\t2",
110 + "Wix4InternetShortcut:uisdCsU32.1i4Hebrg1N7E194zJQ8Y.047730A5_30FE_4A62_A520_DA9381B8226A\tPackage.ico.047730A5_30FE_4A62_A520_DA9381B8226A\tINSTALLFOLDER.047730A5_30FE_4A62_A520_DA9381B8226A\tWiX Toolset (url).url\thttps://wixtoolset.org\t1\t[#Package.ico.047730A5_30FE_4A62_A520_DA9381B8226A]\t0",
111 + "Wix4InternetShortcut:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A.047730A5_30FE_4A62_A520_DA9381B8226A\tPackage.ico.047730A5_30FE_4A62_A520_DA9381B8226A\tINSTALLFOLDER.047730A5_30FE_4A62_A520_DA9381B8226A\tWiX Toolset (link).lnk\thttps://wixtoolset.org\t0\t[#Package.ico.047730A5_30FE_4A62_A520_DA9381B8226A]\t0",
112 }, results.OrderBy(s => s).ToArray());
113 }
114
src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj
+5 -1
@@ -27,10 +27,14 @@
27 <Content Include="TestData\CloseApplication\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
28 <Content Include="TestData\CloseApplication\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
29 <Content Include="TestData\CloseApplication\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
30 - <Content Include="TestData\InternetShortcut\example.txt" CopyToOutputDirectory="PreserveNewest" />
30 + <Content Include="TestData\InternetShortcut\Package.ico" CopyToOutputDirectory="PreserveNewest" />
31 <Content Include="TestData\InternetShortcut\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
32 <Content Include="TestData\InternetShortcut\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
33 <Content Include="TestData\InternetShortcut\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
34 + <Content Include="TestData\InternetShortcutModule\Package.ico" CopyToOutputDirectory="PreserveNewest" />
35 + <Content Include="TestData\InternetShortcutModule\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
36 + <Content Include="TestData\InternetShortcutModule\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
37 + <Content Include="TestData\InternetShortcutModule\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
38 <Content Include="TestData\PermissionEx\example.txt" CopyToOutputDirectory="PreserveNewest" />
39 <Content Include="TestData\PermissionEx\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
40 <Content Include="TestData\PermissionEx\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
src/wixext/UtilTableDefinitions.cs
+1 -1
@@ -100,7 +100,7 @@ namespace WixToolset.Util
100 new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Text, description: "Name used for shortcut.", modularizeType: ColumnModularizeType.Property),
101 new ColumnDefinition("Target", ColumnType.Localized, 0, primaryKey: false, nullable: false, ColumnCategory.Text, description: "URL target."),
102 new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, description: "Attribute flags that control how the shortcut is created."),
103 - new ColumnDefinition("IconFile", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Icon file for shortcut"),
103 + new ColumnDefinition("IconFile", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Icon file for shortcut", modularizeType: ColumnModularizeType.Property),
104 new ColumnDefinition("IconIndex", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Index of the icon being referenced."),
105 },
106 symbolIdIsPrimaryKey: true