Skip to content

Commit 664f320

Browse files
authored
Merge pull request dotnet-script#233 from filipw/bug/issue230
Clear MSBuild related env variables before dotnet restore
2 parents 2738198 + 611fc2f commit 664f320

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/Dotnet.Script.DependencyModel/Context/DotnetRestorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public DotnetRestorer(CommandRunner commandRunner, LogFactory logFactory)
1818

1919
public void Restore(string pathToProjectFile)
2020
{
21-
_logger.Debug($"Restoring {pathToProjectFile} using the dotnet cli.");
2221
var runtimeIdentifier = RuntimeHelper.GetRuntimeIdentifier();
22+
_logger.Debug($"Restoring {pathToProjectFile} using the dotnet cli. RuntimeIdentifier : {runtimeIdentifier}");
2323
var exitcode = _commandRunner.Execute("dotnet", $"restore \"{pathToProjectFile}\" -r {runtimeIdentifier}");
2424
if (exitcode != 0)
2525
{

src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<RepositoryUrl>https://github.com/filipw/dotnet-script.git</RepositoryUrl>
1212
<RepositoryType>git</RepositoryType>
1313
<PackageTags>script;csx;csharp;roslyn;omnisharp</PackageTags>
14-
<Version>0.4.0</Version>
14+
<Version>0.5.0</Version>
1515
</PropertyGroup>
1616

1717
<ItemGroup>

src/Dotnet.Script.DependencyModel/Process/CommandRunner.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics;
1+
using System.Collections.Generic;
2+
using System.Diagnostics;
23
using Dotnet.Script.DependencyModel.Logging;
34

45
namespace Dotnet.Script.DependencyModel.Process
@@ -27,11 +28,20 @@ private static ProcessStartInfo CreateProcessStartInfo(string commandPath, strin
2728
CreateNoWindow = true,
2829
Arguments = arguments ?? "",
2930
RedirectStandardOutput = true,
30-
RedirectStandardError = true,
31+
RedirectStandardError = true,
3132
UseShellExecute = false
3233
};
34+
RemoveMsBuildEnvironmentVariables(startInformation.Environment);
3335
return startInformation;
3436
}
37+
private static void RemoveMsBuildEnvironmentVariables(IDictionary<string, string> environment)
38+
{
39+
// Remove various MSBuild environment variables set by OmniSharp to ensure that
40+
// the .NET CLI is not launched with the wrong values.
41+
environment.Remove("MSBUILD_EXE_PATH");
42+
environment.Remove("MSBuildExtensionsPath");
43+
}
44+
3545

3646
private static void RunAndWait(System.Diagnostics.Process process)
3747
{

0 commit comments

Comments
 (0)