Skip to content

Commit 8d81b88

Browse files
committed
C#: Unset Platform env variable when invoking vcvarsall.bat
1 parent b4fbfa0 commit 8d81b88

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

csharp/autobuilder/Semmle.Autobuild/CommandBuilder.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void NextCommand()
169169
arguments.Append(" &&");
170170
}
171171

172-
public CommandBuilder RunCommand(string exe, string argumentsOpt = null)
172+
public CommandBuilder RunCommand(string exe, string argumentsOpt = null, bool quoteExe = true)
173173
{
174174
var (exe0, arg0) =
175175
escapingMode == EscapeMode.Process && exe.EndsWith(".exe", System.StringComparison.Ordinal)
@@ -183,7 +183,10 @@ public CommandBuilder RunCommand(string exe, string argumentsOpt = null)
183183
}
184184
else
185185
{
186-
QuoteArgument(exe0);
186+
if (quoteExe)
187+
QuoteArgument(exe0);
188+
else
189+
Argument(exe0);
187190
}
188191
Argument(arg0);
189192
Argument(argumentsOpt);

csharp/autobuilder/Semmle.Autobuild/MsBuildRule.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ public BuildScript Analyse(Autobuilder builder, bool auto)
5757
var command = new CommandBuilder(builder.Actions);
5858

5959
if (vsTools != null)
60+
{
6061
command.CallBatFile(vsTools.Path);
62+
// `vcvarsall.bat` sets a default Platform environment variable,
63+
// which may not be compatible with the supported platforms of the
64+
// given project/solution. Unsetting it means that the default platform
65+
// of the project/solution is used instead.
66+
command.RunCommand("set Platform=&& type NUL", quoteExe: false);
67+
}
6168

6269
builder.MaybeIndex(command, MsBuild);
6370
command.QuoteArgument(projectOrSolution.FullPath);

0 commit comments

Comments
 (0)