Skip to content

Commit

Permalink
[automated] Merge branch 'release/9.0.3xx' => 'main' (#46615)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-wuzhai authored Feb 8, 2025
2 parents b51e005 + b0d8a8d commit 755effb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/Cli/dotnet/commands/dotnet-sln/add/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ private async Task AddProjectsToSolutionAsync(string solutionFileFullPath, IEnum
foreach (var projectPath in projectPaths)
{
string relativePath = Path.GetRelativePath(Path.GetDirectoryName(solutionFileFullPath), projectPath);
// Add fallback solution folder
string relativeSolutionFolder = Path.GetDirectoryName(relativePath);
// Add fallback solution folder if relative path does not contain `..`.
string relativeSolutionFolder = relativePath.Split(Path.DirectorySeparatorChar).Any(p => p == "..")
? string.Empty : Path.GetDirectoryName(relativePath);

if (!_inRoot && solutionFolder is null && !string.IsNullOrEmpty(relativeSolutionFolder))
{
if (relativeSolutionFolder.Split(Path.DirectorySeparatorChar).LastOrDefault() == Path.GetFileNameWithoutExtension(relativePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public sealed class DotNetMSBuildSdkResolver : SdkResolver
{
public override string Name => "Microsoft.DotNet.MSBuildSdkResolver";

// Default resolver has priority 10000 and we want to go before it and leave room on either side of us.
// Default resolver has priority 10000 and we want to go before it and leave room on either side of us.
public override int Priority => 5000;

private readonly Func<string, string?> _getEnvironmentVariable;
private readonly Func<string>? _getCurrentProcessPath;
private readonly Func<string, string, string?> _getMsbuildRuntime;
private readonly NETCoreSdkResolver _netCoreSdkResolver;

private const string DotnetHost = "DOTNET_HOST_PATH";
private const string DotnetHostExperimentalKey = "DOTNET_EXPERIMENTAL_HOST_PATH";
private const string MSBuildTaskHostRuntimeVersion = "SdkResolverMSBuildTaskHostRuntimeVersion";

private static CachingWorkloadResolver _staticWorkloadResolver = new();
Expand Down Expand Up @@ -202,11 +202,11 @@ private sealed class CachedState
if (File.Exists(dotnetExe))
{
propertiesToAdd ??= new Dictionary<string, string?>();
propertiesToAdd.Add(DotnetHost, dotnetExe);
propertiesToAdd.Add(DotnetHostExperimentalKey, dotnetExe);
}
else
{
logger?.LogMessage($"Could not set '{DotnetHost}' because dotnet executable '{dotnetExe}' does not exist.");
logger?.LogMessage($"Could not set '{DotnetHostExperimentalKey}' because dotnet executable '{dotnetExe}' does not exist.");
}

string? runtimeVersion = dotnetRoot != null ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{
public class GivenAnMSBuildSdkResolver : SdkTest
{
private const string DotnetHost = "DOTNET_HOST_PATH";
private const string DotnetHostExperimentalKey = "DOTNET_EXPERIMENTAL_HOST_PATH";
private const string MSBuildTaskHostRuntimeVersion = "SdkResolverMSBuildTaskHostRuntimeVersion";

public GivenAnMSBuildSdkResolver(ITestOutputHelper logger) : base(logger)
Expand Down Expand Up @@ -208,7 +208,7 @@ public void ItReturnsHighestSdkAvailableThatIsCompatibleWithMSBuild(bool disallo
{
// DotnetHost is the path to dotnet.exe. Can be only on Windows.
result.PropertiesToAdd.Count.Should().Be(2);
result.PropertiesToAdd.Should().ContainKey(DotnetHost);
result.PropertiesToAdd.Should().ContainKey(DotnetHostExperimentalKey);
}
else
{
Expand Down Expand Up @@ -293,7 +293,7 @@ public void ItReturnsHighestSdkAvailableThatIsCompatibleWithMSBuildWhenVersionIn
{
// DotnetHost is the path to dotnet.exe. Can be only on Windows.
result.PropertiesToAdd.Count.Should().Be(4);
result.PropertiesToAdd.Should().ContainKey(DotnetHost);
result.PropertiesToAdd.Should().ContainKey(DotnetHostExperimentalKey);
}
else
{
Expand Down

0 comments on commit 755effb

Please sign in to comment.