From c890f0e1a360d949d5e0b5d9ab619c4a78d9fbd3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 30 Dec 2023 22:53:21 -0500 Subject: [PATCH] Add a warning that VBScript is deprecated. --- .../wix/WixToolset.Data/WarningMessages.cs | 6 ++++ src/wix/WixToolset.Core/Compiler.cs | 5 ++++ .../CustomActionFixture.cs | 28 +++++++++++++++++++ .../CustomAction/VBScriptCustomAction.wxs | 27 ++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/CustomAction/VBScriptCustomAction.wxs diff --git a/src/api/wix/WixToolset.Data/WarningMessages.cs b/src/api/wix/WixToolset.Data/WarningMessages.cs index 790291e48..f3d469bf3 100644 --- a/src/api/wix/WixToolset.Data/WarningMessages.cs +++ b/src/api/wix/WixToolset.Data/WarningMessages.cs @@ -714,6 +714,11 @@ public static Message InvalidWixVersion(SourceLineNumber sourceLineNumbers, stri return Message(sourceLineNumbers, Ids.InvalidWixVersion, "Invalid WixVersion '{0}' in {1}/@'{2}'. Comparisons may yield unexpected results.", version, elementName, attributeName); } + public static Message VBScriptIsDeprecated(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.VBScriptIsDeprecated, "VBScript is a deprecated Windows component: https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features. VBScript custom actions might fail on some Windows systems. Rewrite or eliminate VBScript custom actions for best compatibility."); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); @@ -855,6 +860,7 @@ public enum Ids DiscardedRollbackBoundary2 = 1160, ExePackageDetectInformationRecommended = 1161, InvalidWixVersion = 1162, + VBScriptIsDeprecated = 1163, } } } diff --git a/src/wix/WixToolset.Core/Compiler.cs b/src/wix/WixToolset.Core/Compiler.cs index bfdf4fe84..7088cfba0 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs @@ -3447,6 +3447,11 @@ private void ParseCustomActionElement(XElement node) } } + if (targetType == CustomActionTargetType.VBScript) + { + this.Core.Write(WarningMessages.VBScriptIsDeprecated(sourceLineNumbers)); + } + // if we have an in-lined Script CustomAction ensure no source or target attributes were provided if (inlineScript) { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs index 091b7d53b..bb8333287 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs @@ -97,6 +97,34 @@ public void CanDetectCustomActionCycle() } } + [Fact] + public void WarnsOnVBScriptCustomAction() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "CustomAction", "VBScriptCustomAction.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + Assert.Equal(1163, result.ExitCode); + Assert.Equal(3, result.Messages.Length); + Assert.Equal(3, result.Messages.Where(m => m.Id == 1163).Count()); + } + } + [Fact] public void CanDetectCustomActionCycleWithTail() { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/CustomAction/VBScriptCustomAction.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/CustomAction/VBScriptCustomAction.wxs new file mode 100644 index 000000000..605ad3727 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/CustomAction/VBScriptCustomAction.wxs @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +