Merge pull request #3199 from hvitved/csharp/vsvars-unset-platform

C#: Unset `Platform` env variable when invoking `vcvarsall.bat`
This commit is contained in:
Calum Grant
2020-04-22 09:18:20 +01:00
committed by GitHub
2 changed files with 13 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -169,7 +169,7 @@ namespace Semmle.Autobuild
arguments.Append(" &&");
}
public CommandBuilder RunCommand(string exe, string? argumentsOpt = null)
public CommandBuilder RunCommand(string exe, string? argumentsOpt = null, bool quoteExe = true)
{
var (exe0, arg0) =
escapingMode == EscapeMode.Process && exe.EndsWith(".exe", System.StringComparison.Ordinal)
@@ -183,7 +183,10 @@ namespace Semmle.Autobuild
}
else
{
QuoteArgument(exe0);
if (quoteExe)
QuoteArgument(exe0);
else
Argument(exe0);
}
Argument(arg0);
Argument(argumentsOpt);

View File

@@ -57,7 +57,14 @@ namespace Semmle.Autobuild
var command = new CommandBuilder(builder.Actions);
if (vsTools != null)
{
command.CallBatFile(vsTools.Path);
// `vcvarsall.bat` sets a default Platform environment variable,
// which may not be compatible with the supported platforms of the
// given project/solution. Unsetting it means that the default platform
// of the project/solution is used instead.
command.RunCommand("set Platform=&& type NUL", quoteExe: false);
}
builder.MaybeIndex(command, MsBuild);
command.QuoteArgument(projectOrSolution.FullPath);