diff --git a/src/ext/UI/ca/DriveCheck.cpp b/src/ext/UI/ca/DriveCheck.cpp index fafd73c27..75e6ffd1f 100644 --- a/src/ext/UI/ca/DriveCheck.cpp +++ b/src/ext/UI/ca/DriveCheck.cpp @@ -12,21 +12,21 @@ static HRESULT PathIsRemovable(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRe UINT __stdcall ValidatePath(MSIHANDLE hInstall) { HRESULT hr = S_OK; - + LPWSTR pwszWixUIDir = NULL; LPWSTR pwszInstallPath = NULL; BOOL fInstallPathIsRemote = TRUE; BOOL fInstallPathIsRemoveable = TRUE; - + hr = WcaInitialize(hInstall, "ValidatePath"); ExitOnFailure(hr, "failed to initialize"); hr = WcaGetProperty(L"WIXUI_INSTALLDIR", &pwszWixUIDir); ExitOnFailure(hr, "failed to get WixUI Installation Directory"); - + hr = WcaGetProperty(pwszWixUIDir, &pwszInstallPath); ExitOnFailure(hr, "failed to get Installation Directory"); - + hr = PathIsRemote(pwszInstallPath, &fInstallPathIsRemote); if (FAILED(hr)) { @@ -34,7 +34,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) //reset HR, as we need to continue and find out if is a UNC path hr = S_OK; } - + hr = PathIsRemovable(pwszInstallPath, &fInstallPathIsRemoveable); if (FAILED(hr)) { @@ -45,7 +45,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) // If the path does not point to a network drive, mapped drive, or removable drive, // then set WIXUI_INSTALLDIR_VALID to "1" otherwise set it to 0 - BOOL fInstallPathIsUnc = PathIsUNCW(pwszInstallPath); + BOOL fInstallPathIsUnc = ::PathIsUNCW(pwszInstallPath); if (!fInstallPathIsUnc && !fInstallPathIsRemote && !fInstallPathIsRemoveable) { // path is valid @@ -61,7 +61,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) hr = WcaSetProperty(L"WIXUI_INSTALLDIR_VALID", L"0"); ExitOnFailure(hr, "failed to set WIXUI_INSTALLDIR_VALID"); } - + LExit: ReleaseStr(pwszInstallPath); ReleaseStr(pwszWixUIDir); @@ -79,22 +79,22 @@ static HRESULT PathIsRemote(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRemot LPWSTR pStrippedTargetFolder = NULL; hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); - + // Terminate the path at the root - if(!::PathStripToRootW(pStrippedTargetFolder)) + if (!::PathStripToRootW(pStrippedTargetFolder)) { hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); - ExitOnFailure(hr, "failed to parse target folder"); + ExitOnFailure(hr, "failed to parse target folder"); } - - UINT uResult = GetDriveTypeW(pStrippedTargetFolder); - - *fPathRemote = (DRIVE_REMOTE == uResult) ; + + UINT uResult = ::GetDriveTypeW(pStrippedTargetFolder); + + *fPathRemote = (DRIVE_REMOTE == uResult); LExit: ReleaseStr(pStrippedTargetFolder); - return hr; + return hr; } /******************************************************************** @@ -107,16 +107,16 @@ static HRESULT PathIsRemovable(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRe LPWSTR pStrippedTargetFolder = NULL; hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); - + // Terminate the path at the root - if(!::PathStripToRootW(pStrippedTargetFolder)) + if (!::PathStripToRootW(pStrippedTargetFolder)) { hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); - ExitOnFailure(hr, "failed to parse target folder"); + ExitOnFailure(hr, "failed to parse target folder"); } - - UINT uResult = GetDriveTypeW(pStrippedTargetFolder); - + + UINT uResult = ::GetDriveTypeW(pStrippedTargetFolder); + *fPathRemovable = ((DRIVE_CDROM == uResult) || (DRIVE_REMOVABLE == uResult) || (DRIVE_RAMDISK == uResult) || (DRIVE_UNKNOWN == uResult)); LExit: diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs index 68e1177db..2bfe4bb37 100644 --- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs +++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs @@ -12,7 +12,7 @@ - + diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs index 5bb7fa1a8..24b98ad58 100644 --- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs +++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs @@ -12,7 +12,7 @@ - + diff --git a/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs b/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs index eb5e36875..d42290c35 100644 --- a/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs +++ b/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs @@ -29,7 +29,6 @@ public void CanBuildUsingWixUIAdvanced() "Binary:WixUI_Bmp_Up\t[Binary data]", "Binary:WixUI_Ico_Exclam\t[Binary data]", "Binary:WixUI_Ico_Info\t[Binary data]", - "Binary:WixUiCa_X86\t[Binary data]", }, results.Where(r => r.StartsWith("Binary:")).ToArray()); WixAssert.CompareLineByLine(new[] { @@ -37,13 +36,8 @@ public void CanBuildUsingWixUIAdvanced() "CustomAction:WixSetDefaultPerUserFolder\t51\tWixPerUserFolder\t[LocalAppDataFolder]Apps\\[ApplicationFolderName]\t", "CustomAction:WixSetPerMachineFolder\t51\tAPPLICATIONFOLDER\t[WixPerMachineFolder]\t", "CustomAction:WixSetPerUserFolder\t51\tAPPLICATIONFOLDER\t[WixPerUserFolder]\t", - "CustomAction:WixUIValidatePath_X86\t65\tWixUiCa_X86\tValidatePath\t", }, results.Where(r => r.StartsWith("CustomAction:")).ToArray()); - WixAssert.CompareLineByLine(new[] - { - "ControlEvent:BrowseDlg\tOK\tDoAction\tWixUIValidatePath_X86\tNOT WIXUI_DONTVALIDATEPATH\t1", - "ControlEvent:InstallDirDlg\tNext\tDoAction\tWixUIValidatePath_X86\tNOT WIXUI_DONTVALIDATEPATH\t2", - }, results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); + Assert.Empty(results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); WixAssert.CompareLineByLine(new[] { "InstallUISequence:AdvancedWelcomeEulaDlg\tNOT Installed\t1297", @@ -68,7 +62,6 @@ public void CanBuildUsingWixUIAdvancedX64() "Binary:WixUI_Bmp_Up\t[Binary data]", "Binary:WixUI_Ico_Exclam\t[Binary data]", "Binary:WixUI_Ico_Info\t[Binary data]", - "Binary:WixUiCa_X64\t[Binary data]", }, results.Where(r => r.StartsWith("Binary:")).ToArray()); WixAssert.CompareLineByLine(new[] { @@ -76,13 +69,8 @@ public void CanBuildUsingWixUIAdvancedX64() "CustomAction:WixSetDefaultPerUserFolder\t51\tWixPerUserFolder\t[LocalAppDataFolder]Apps\\[ApplicationFolderName]\t", "CustomAction:WixSetPerMachineFolder\t51\tAPPLICATIONFOLDER\t[WixPerMachineFolder]\t", "CustomAction:WixSetPerUserFolder\t51\tAPPLICATIONFOLDER\t[WixPerUserFolder]\t", - "CustomAction:WixUIValidatePath_X64\t65\tWixUiCa_X64\tValidatePath\t", }, results.Where(r => r.StartsWith("CustomAction:")).ToArray()); - WixAssert.CompareLineByLine(new[] - { - "ControlEvent:BrowseDlg\tOK\tDoAction\tWixUIValidatePath_X64\tNOT WIXUI_DONTVALIDATEPATH\t1", - "ControlEvent:InstallDirDlg\tNext\tDoAction\tWixUIValidatePath_X64\tNOT WIXUI_DONTVALIDATEPATH\t2", - }, results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); + Assert.Empty(results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); } [Fact] @@ -102,7 +90,6 @@ public void CanBuildUsingWixUIAdvancedARM64() "Binary:WixUI_Bmp_Up\t[Binary data]", "Binary:WixUI_Ico_Exclam\t[Binary data]", "Binary:WixUI_Ico_Info\t[Binary data]", - "Binary:WixUiCa_A64\t[Binary data]", }, results.Where(r => r.StartsWith("Binary:")).ToArray()); WixAssert.CompareLineByLine(new[] { @@ -110,13 +97,8 @@ public void CanBuildUsingWixUIAdvancedARM64() "CustomAction:WixSetDefaultPerUserFolder\t51\tWixPerUserFolder\t[LocalAppDataFolder]Apps\\[ApplicationFolderName]\t", "CustomAction:WixSetPerMachineFolder\t51\tAPPLICATIONFOLDER\t[WixPerMachineFolder]\t", "CustomAction:WixSetPerUserFolder\t51\tAPPLICATIONFOLDER\t[WixPerUserFolder]\t", - "CustomAction:WixUIValidatePath_A64\t65\tWixUiCa_A64\tValidatePath\t", }, results.Where(r => r.StartsWith("CustomAction:")).ToArray()); - WixAssert.CompareLineByLine(new[] - { - "ControlEvent:BrowseDlg\tOK\tDoAction\tWixUIValidatePath_A64\tNOT WIXUI_DONTVALIDATEPATH\t1", - "ControlEvent:InstallDirDlg\tNext\tDoAction\tWixUIValidatePath_A64\tNOT WIXUI_DONTVALIDATEPATH\t2", - }, results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); + Assert.Empty(results.Where(result => result.StartsWith("ControlEvent:") && result.Contains("DoAction")).ToArray()); } [Fact] diff --git a/src/ext/UI/wixext/UICompiler.cs b/src/ext/UI/wixext/UICompiler.cs index 5f2751c94..57a0dc169 100644 --- a/src/ext/UI/wixext/UICompiler.cs +++ b/src/ext/UI/wixext/UICompiler.cs @@ -56,6 +56,7 @@ private void ParseWixUIElement(Intermediate intermediate, IntermediateSection se var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); string id = null; string installDirectory = null; + YesNoType extendedPathValidation = YesNoType.No; foreach (var attrib in element.Attributes()) { @@ -69,6 +70,9 @@ private void ParseWixUIElement(Intermediate intermediate, IntermediateSection se case "InstallDirectory": installDirectory = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; + case "ExtendedPathValidation": + extendedPathValidation = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; @@ -87,7 +91,15 @@ private void ParseWixUIElement(Intermediate intermediate, IntermediateSection se else { var platform = this.Context.Platform == Platform.ARM64 ? "A64" : this.Context.Platform.ToString(); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, $"{id}_{platform}"); + + if (extendedPathValidation == YesNoType.No) + { + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, $"{id}_{platform}"); + } + else + { + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, $"{id}_ExtendedPathValidation_{platform}"); + } if (installDirectory != null) { diff --git a/src/ext/UI/wixlib/WixUI_Advanced.wxs b/src/ext/UI/wixlib/WixUI_Advanced.wxs index 2050dc247..338bcf2af 100644 --- a/src/ext/UI/wixlib/WixUI_Advanced.wxs +++ b/src/ext/UI/wixlib/WixUI_Advanced.wxs @@ -23,8 +23,22 @@ Todo: + + + + + + + + + + + + + + @@ -76,7 +90,6 @@ Todo: - @@ -95,7 +108,6 @@ Todo: - diff --git a/src/ext/UI/wixlib/WixUI_InstallDir.wxs b/src/ext/UI/wixlib/WixUI_InstallDir.wxs index bbe806bde..18f876e11 100644 --- a/src/ext/UI/wixlib/WixUI_InstallDir.wxs +++ b/src/ext/UI/wixlib/WixUI_InstallDir.wxs @@ -24,6 +24,17 @@ Patch dialog sequence: + + + + + + + + + + + diff --git a/src/ext/UI/wixlib/WixUI_Mondo.wxs b/src/ext/UI/wixlib/WixUI_Mondo.wxs index 4dd1148df..e6bb9ced1 100644 --- a/src/ext/UI/wixlib/WixUI_Mondo.wxs +++ b/src/ext/UI/wixlib/WixUI_Mondo.wxs @@ -25,6 +25,16 @@ Patch dialog sequence: + + + + + + + + + +