Enable overriding MSBuildSDKsPath with env var (#4885)
This commit is contained in:
parent
8083a68944
commit
e82ed6799d
3 changed files with 25 additions and 2 deletions
|
@ -86,6 +86,13 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
|
||||
private static string GetMSBuildSDKsPath()
|
||||
{
|
||||
var envMSBuildSDKsPath = Environment.GetEnvironmentVariable("MSBuildSDKsPath");
|
||||
|
||||
if (envMSBuildSDKsPath != null)
|
||||
{
|
||||
return envMSBuildSDKsPath;
|
||||
}
|
||||
|
||||
return Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
ExtensionsDirectoryName);
|
||||
|
|
|
@ -15,8 +15,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
private class FileInfoNuGetLock : IDisposable
|
||||
{
|
||||
private FileStream _fileStream;
|
||||
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
private Task _task;
|
||||
|
|
|
@ -103,5 +103,23 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue