Skip to content

Commit c7686b1

Browse files
committed
C#: First try pwsh and then powershell when calling dotnet-install.ps1
1 parent e003b04 commit c7686b1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certifi
209209
var psScriptFile = builder.Actions.PathCombine(builder.Options.RootDirectory, "install-dotnet.ps1");
210210
builder.Actions.WriteAllText(psScriptFile, psScript);
211211

212-
var install = new CommandBuilder(builder.Actions).
213-
RunCommand("powershell").
212+
BuildScript GetInstall(string pwsh) =>
213+
new CommandBuilder(builder.Actions).
214+
RunCommand(pwsh).
214215
Argument("-NoProfile").
215216
Argument("-ExecutionPolicy").
216217
Argument("unrestricted").
@@ -219,13 +220,14 @@ public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certifi
219220
Argument("-Version").
220221
Argument(version).
221222
Argument("-InstallDir").
222-
Argument(path);
223+
Argument(path).
224+
Script;
223225

224226
var removeScript = new CommandBuilder(builder.Actions).
225227
RunCommand("del").
226228
Argument(psScriptFile);
227229

228-
return install.Script & BuildScript.Try(removeScript.Script);
230+
return (GetInstall("pwsh") | GetInstall("powershell")) & BuildScript.Try(removeScript.Script);
229231
}
230232
else
231233
{

0 commit comments

Comments
 (0)