Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private IEnumerable<string> SearchPaths
{
if (_searchPaths == null)
{
var searchPaths = new List<string> { AppContext.BaseDirectory };
var searchPaths = new List<string> { SdkPaths.SdkDirectory };

searchPaths.AddRange(Environment
.GetEnvironmentVariable("PATH")?
Expand Down
33 changes: 33 additions & 0 deletions test/dotnet-aot.Tests/EnvironmentProviderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.DotNet.Cli.Utils;

namespace Microsoft.DotNet.Cli.Tests;

[TestClass]
public class EnvironmentProviderTests
{
[TestMethod]
public void CommandSearchStartsInVersionedSdkDirectory()
{
string sdkDirectory = Path.Combine(Path.GetTempPath(), "dotnet", "sdk", $"test-version-{Guid.NewGuid():N}");
string commandName = $"sdk-command-{Guid.NewGuid():N}";
string commandPath = Path.Combine(sdkDirectory, commandName);
Directory.CreateDirectory(sdkDirectory);
File.WriteAllText(commandPath, string.Empty);

try
{
using var _ = new SdkDirectoryScope(sdkDirectory);

Assert.AreEqual(
commandPath,
new EnvironmentProvider().GetCommandPath(commandName, string.Empty));
}
finally
{
Directory.Delete(sdkDirectory, recursive: true);
}
}
}
Loading