@joebigelow / wix-1 / commits / c890f0e1

Add a warning that VBScript is deprecated.

Bob Arnson committed Dec 30, 2023 at 22:53 UTC c890f0e1a360d949d5e0b5d9ab619c4a78d9fbd3
4 files changed +66
src/api/wix/WixToolset.Data/WarningMessages.cs
+6
@@ -714,6 +714,11 @@ namespace WixToolset.Data
714 return Message(sourceLineNumbers, Ids.InvalidWixVersion, "Invalid WixVersion '{0}' in {1}/@'{2}'. Comparisons may yield unexpected results.", version, elementName, attributeName);
715 }
716
717 + public static Message VBScriptIsDeprecated(SourceLineNumber sourceLineNumbers)
718 + {
719 + 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.");
720 + }
721 +
722 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
723 {
724 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
@@ -855,6 +860,7 @@ namespace WixToolset.Data
860 DiscardedRollbackBoundary2 = 1160,
861 ExePackageDetectInformationRecommended = 1161,
862 InvalidWixVersion = 1162,
863 + VBScriptIsDeprecated = 1163,
864 }
865 }
866 }
src/wix/WixToolset.Core/Compiler.cs
+5
@@ -3447,6 +3447,11 @@ namespace WixToolset.Core
3447 }
3448 }
3449
3450 + if (targetType == CustomActionTargetType.VBScript)
3451 + {
3452 + this.Core.Write(WarningMessages.VBScriptIsDeprecated(sourceLineNumbers));
3453 + }
3454 +
3455 // if we have an in-lined Script CustomAction ensure no source or target attributes were provided
3456 if (inlineScript)
3457 {
src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs
+28
@@ -97,6 +97,34 @@ namespace WixToolsetTest.CoreIntegration
97 }
98 }
99
100 + [Fact]
101 + public void WarnsOnVBScriptCustomAction()
102 + {
103 + var folder = TestData.Get(@"TestData");
104 +
105 + using (var fs = new DisposableFileSystem())
106 + {
107 + var baseFolder = fs.GetFolder();
108 + var intermediateFolder = Path.Combine(baseFolder, "obj");
109 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
110 +
111 + var result = WixRunner.Execute(new[]
112 + {
113 + "build",
114 + Path.Combine(folder, "CustomAction", "VBScriptCustomAction.wxs"),
115 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
116 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
117 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
118 + "-intermediateFolder", intermediateFolder,
119 + "-o", msiPath
120 + });
121 +
122 + Assert.Equal(1163, result.ExitCode);
123 + Assert.Equal(3, result.Messages.Length);
124 + Assert.Equal(3, result.Messages.Where(m => m.Id == 1163).Count());
125 + }
126 + }
127 +
128 [Fact]
129 public void CanDetectCustomActionCycleWithTail()
130 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/CustomAction/VBScriptCustomAction.wxs new
+27
@@ -0,0 +1,27 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Fragment>
3 + <ComponentGroup Id="ProductComponents">
4 + <ComponentGroupRef Id="MinimalComponentGroup" />
5 + <Component Directory="INSTALLFOLDER">
6 + <File Id="VBScript.vbs" Source="test.txt" />
7 + </Component>
8 + </ComponentGroup>
9 +
10 + <Binary Id="Binary1" SourceFile="test.txt" />
11 + <CustomAction Id="Action1" VBScriptCall="EntryPoint1" BinaryRef="Binary1" />
12 + <CustomAction Id="Action1J" JScriptCall="EntryPoint1" BinaryRef="Binary1" />
13 + <CustomAction Id="Action2" VBScriptCall="EntryPoint1" FileRef="VBScript.vbs" />
14 + <CustomAction Id="Action2J" JScriptCall="EntryPoint1" FileRef="VBScript.vbs" />
15 + <CustomAction Id="Action3" Script="vbscript" ScriptSourceFile="test.txt" />
16 + <CustomAction Id="Action3J" Script="jscript" ScriptSourceFile="test.txt" />
17 +
18 + <InstallExecuteSequence>
19 + <Custom Action="Action1" After="AppSearch" />
20 + <Custom Action="Action1J" After="Action1" />
21 + <Custom Action="Action2" After="Action1J" />
22 + <Custom Action="Action2J" After="Action2" />
23 + <Custom Action="Action3" After="Action2J" />
24 + <Custom Action="Action3J" After="Action3" />
25 + </InstallExecuteSequence>
26 + </Fragment>
27 +</Wix>