Enable overriding MSBuildSDKsPath with env var (#4885)

This commit is contained in:
Piotr Puszkiewicz 2016-12-01 14:45:55 -08:00 committed by GitHub
parent 8083a68944
commit e82ed6799d
3 changed files with 25 additions and 2 deletions

View file

@ -86,6 +86,13 @@ namespace Microsoft.DotNet.Tools.MSBuild
private static string GetMSBuildSDKsPath() private static string GetMSBuildSDKsPath()
{ {
var envMSBuildSDKsPath = Environment.GetEnvironmentVariable("MSBuildSDKsPath");
if (envMSBuildSDKsPath != null)
{
return envMSBuildSDKsPath;
}
return Path.Combine( return Path.Combine(
AppContext.BaseDirectory, AppContext.BaseDirectory,
ExtensionsDirectoryName); ExtensionsDirectoryName);

View file

@ -15,8 +15,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
{ {
private class FileInfoNuGetLock : IDisposable private class FileInfoNuGetLock : IDisposable
{ {
private FileStream _fileStream;
private CancellationTokenSource _cancellationTokenSource; private CancellationTokenSource _cancellationTokenSource;
private Task _task; private Task _task;

View file

@ -103,5 +103,23 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
cmd.ExitCode.Should().NotBe(0); cmd.ExitCode.Should().NotBe(0);
} }
[Fact]
public void When_MSBuildSDKsPath_is_set_by_env_var_then_it_is_not_overridden()
{
var testInstance = TestAssets.Get("MSBuildIntegration")
.CreateInstance()
.WithSourceFiles();
var cmd = new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.WithEnvironmentVariable("MSBuildSDKsPath", "AnyString")
.ExecuteWithCapturedOutput($"msbuild");
cmd.ExitCode.Should().NotBe(0);
cmd.StdOut.Should().Contain("Expected 'AnyString")
.And.Contain("to exist, but it does not.");
}
} }
} }