Skip to content

Commit

Permalink
Merge pull request #233 from filipw/bug/issue230
Browse files Browse the repository at this point in the history
Clear MSBuild related env variables before dotnet restore
  • Loading branch information
filipw committed Mar 6, 2018
2 parents 2738198 + 611fc2f commit 664f320
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Expand Up @@ -18,8 +18,8 @@ public DotnetRestorer(CommandRunner commandRunner, LogFactory logFactory)

public void Restore(string pathToProjectFile)
{
_logger.Debug($"Restoring {pathToProjectFile} using the dotnet cli.");
var runtimeIdentifier = RuntimeHelper.GetRuntimeIdentifier();
_logger.Debug($"Restoring {pathToProjectFile} using the dotnet cli. RuntimeIdentifier : {runtimeIdentifier}");
var exitcode = _commandRunner.Execute("dotnet", $"restore \"{pathToProjectFile}\" -r {runtimeIdentifier}");
if (exitcode != 0)
{
Expand Down
Expand Up @@ -11,7 +11,7 @@
<RepositoryUrl>https://github.com/filipw/dotnet-script.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>script;csx;csharp;roslyn;omnisharp</PackageTags>
<Version>0.4.0</Version>
<Version>0.5.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions src/Dotnet.Script.DependencyModel/Process/CommandRunner.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using Dotnet.Script.DependencyModel.Logging;

namespace Dotnet.Script.DependencyModel.Process
Expand Down Expand Up @@ -27,11 +28,20 @@ private static ProcessStartInfo CreateProcessStartInfo(string commandPath, strin
CreateNoWindow = true,
Arguments = arguments ?? "",
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardError = true,
UseShellExecute = false
};
RemoveMsBuildEnvironmentVariables(startInformation.Environment);
return startInformation;
}
private static void RemoveMsBuildEnvironmentVariables(IDictionary<string, string> environment)
{
// Remove various MSBuild environment variables set by OmniSharp to ensure that
// the .NET CLI is not launched with the wrong values.
environment.Remove("MSBUILD_EXE_PATH");
environment.Remove("MSBuildExtensionsPath");
}


private static void RunAndWait(System.Diagnostics.Process process)
{
Expand Down

0 comments on commit 664f320

Please sign in to comment.