From c1f7e431ba09005bcc173bc251882d5761069376 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 27 Sep 2020 22:01:36 -0400 Subject: Modularize IconFile --- src/ca/netshortcuts.cpp | 5 +++- .../TestData/InternetShortcut/Package.ico | Bin 0 -> 83899 bytes .../InternetShortcut/PackageComponents.wxs | 7 +++--- .../InternetShortcutModule/Package.en-us.wxl | 11 ++++++++ .../TestData/InternetShortcutModule/Package.ico | Bin 0 -> 83899 bytes .../TestData/InternetShortcutModule/Package.wxs | 15 +++++++++++ .../InternetShortcutModule/PackageComponents.wxs | 11 ++++++++ .../WixToolsetTest.Util/UtilExtensionFixture.cs | 28 ++++++++++++++++++--- .../WixToolsetTest.Util/WixToolsetTest.Util.csproj | 6 ++++- src/wixext/UtilTableDefinitions.cs | 2 +- 10 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico create mode 100644 src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico create mode 100644 src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.wxs create mode 100644 src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/PackageComponents.wxs diff --git a/src/ca/netshortcuts.cpp b/src/ca/netshortcuts.cpp index 6ff129db..06826264 100644 --- a/src/ca/netshortcuts.cpp +++ b/src/ca/netshortcuts.cpp @@ -219,6 +219,8 @@ static HRESULT CreateUrl( if (wzIconPath) { + WcaLog(LOGMSG_STANDARD, "Adding icon '%ls' index '%d'", wzIconPath, iconIndex); + hr = piURL->QueryInterface(IID_IPropertySetStorage, (void **)&piProperties); ExitOnFailure(hr, "failed to get IPropertySetStorage for shortcut '%ls'", wzShortcutPath); @@ -234,7 +236,7 @@ static HRESULT CreateUrl( ppvar[0].vt = VT_I4; ppvar[0].lVal = iconIndex; ppvar[1].vt = VT_LPWSTR; - ppvar[1].pwszVal = (LPWSTR)wzIconPath; + ppvar[1].pwszVal = const_cast(wzIconPath); hr = piStorage->WriteMultiple(2, ppids, ppvar, 0); ExitOnFailure(hr, "failed to write icon storage for shortcut '%ls'", wzShortcutPath); @@ -285,6 +287,7 @@ static HRESULT CreateLink( if (wzIconPath) { + WcaLog(LOGMSG_STANDARD, "Adding icon '%ls' index '%d'", wzIconPath, iconIndex); hr = piShellLink->SetIconLocation(wzIconPath, iconIndex); ExitOnFailure(hr, "failed to set icon for shortcut '%ls'", wzShortcutPath); } diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico b/src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico new file mode 100644 index 00000000..53134de7 Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/InternetShortcut/Package.ico differ diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcut/PackageComponents.wxs b/src/test/WixToolsetTest.Util/TestData/InternetShortcut/PackageComponents.wxs index 5319d2f7..2a1b4347 100644 --- a/src/test/WixToolsetTest.Util/TestData/InternetShortcut/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Util/TestData/InternetShortcut/PackageComponents.wxs @@ -1,9 +1,10 @@ - + - - + + + diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.en-us.wxl b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico new file mode 100644 index 00000000..53134de7 Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.ico differ diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.wxs b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.wxs new file mode 100644 index 00000000..f38295e7 --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/PackageComponents.wxs b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/PackageComponents.wxs new file mode 100644 index 00000000..2a1b4347 --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/InternetShortcutModule/PackageComponents.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs index 101d71e8..a32a7d62 100644 --- a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs @@ -73,7 +73,7 @@ namespace WixToolsetTest.Util } [Fact] - public void CanBuildInternetShortcut() + public void CanBuildInternetShortcutInProduct() { var folder = TestData.Get(@"TestData\InternetShortcut"); var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }); @@ -85,8 +85,30 @@ namespace WixToolsetTest.Util "CustomAction:Wix4CreateInternetShortcuts_X64\t3073\tWix4UtilCA_X64\tWixCreateInternetShortcuts\t", "CustomAction:Wix4RollbackInternetShortcuts_X64\t3329\tWix4UtilCA_X64\tWixRollbackInternetShortcuts\t", "CustomAction:Wix4SchedInternetShortcuts_X64\t1\tWix4UtilCA_X64\tWixSchedInternetShortcuts\t", - "RemoveFile:wixshortcut\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tzf9nskwi.lnk|WiX Toolset.lnk\tINSTALLFOLDER\t2", - "Wix4InternetShortcut:wixshortcut\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tINSTALLFOLDER\tWiX Toolset.lnk\thttps://wixtoolset.org\t0\t\t0", + "RemoveFile:uisdCsU32.1i4Hebrg1N7E194zJQ8Y\tPackage.ico\thoiptxrr.url|WiX Toolset (url).url\tINSTALLFOLDER\t2", + "RemoveFile:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A\tPackage.ico\tjcxd1dwf.lnk|WiX Toolset (link).lnk\tINSTALLFOLDER\t2", + "Wix4InternetShortcut:uisdCsU32.1i4Hebrg1N7E194zJQ8Y\tPackage.ico\tINSTALLFOLDER\tWiX Toolset (url).url\thttps://wixtoolset.org\t1\t[#Package.ico]\t0", + "Wix4InternetShortcut:uisjV.q0ROZZYR3h_lkpbkZtLtPH0A\tPackage.ico\tINSTALLFOLDER\tWiX Toolset (link).lnk\thttps://wixtoolset.org\t0\t[#Package.ico]\t0", + }, results.OrderBy(s => s).ToArray()); + } + + [Fact] + public void CanBuildInternetShortcutInMergeModule() + { + var folder = TestData.Get(@"TestData\InternetShortcutModule"); + var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(BuildX64, "Binary", "CustomAction", "RemoveFile", "Wix4InternetShortcut"); + WixAssert.CompareLineByLine(new[] + { + "Binary:Wix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\t[Binary data]", + "CustomAction:Wix4CreateInternetShortcuts_X64\t3073\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixCreateInternetShortcuts\t", + "CustomAction:Wix4RollbackInternetShortcuts_X64\t3329\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixRollbackInternetShortcuts\t", + "CustomAction:Wix4SchedInternetShortcuts_X64\t1\tWix4UtilCA_X64.047730A5_30FE_4A62_A520_DA9381B8226A\tWixSchedInternetShortcuts\t", + "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", + "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", + "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", + "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", }, results.OrderBy(s => s).ToArray()); } diff --git a/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj b/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj index f2d5c486..50776c2c 100644 --- a/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj +++ b/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj @@ -27,10 +27,14 @@ - + + + + + diff --git a/src/wixext/UtilTableDefinitions.cs b/src/wixext/UtilTableDefinitions.cs index ef5bfeec..e5d0850f 100644 --- a/src/wixext/UtilTableDefinitions.cs +++ b/src/wixext/UtilTableDefinitions.cs @@ -100,7 +100,7 @@ namespace WixToolset.Util new ColumnDefinition("Name", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Text, description: "Name used for shortcut.", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("Target", ColumnType.Localized, 0, primaryKey: false, nullable: false, ColumnCategory.Text, description: "URL target."), new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, description: "Attribute flags that control how the shortcut is created."), - new ColumnDefinition("IconFile", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Icon file for shortcut"), + new ColumnDefinition("IconFile", ColumnType.Localized, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Icon file for shortcut", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("IconIndex", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Index of the icon being referenced."), }, symbolIdIsPrimaryKey: true -- cgit v1.2.3-55-g6feb