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
2 changes: 1 addition & 1 deletion eng/Version.Details.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This file should be imported by eng/Versions.props
<!-- dotnet-core-setup dependencies -->
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>2.0.0</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
<!-- dotnet-dotnet dependencies -->
<MicrosoftDiagnosticsNETCoreClientPackageVersion>0.2.0-preview.26157.103</MicrosoftDiagnosticsNETCoreClientPackageVersion>
<MicrosoftDiagnosticsNETCoreClientPackageVersion>0.2.0-preview.26165.107</MicrosoftDiagnosticsNETCoreClientPackageVersion>
<!-- dotnet-runtime dependencies -->
<MicrosoftExtensionsDependencyModelPackageVersion>6.0.2</MicrosoftExtensionsDependencyModelPackageVersion>
<!-- dotnet-symreader-converter dependencies -->
Expand Down
6 changes: 3 additions & 3 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<Source Uri="https://github.com/dotnet/dotnet" Mapping="vstest" Sha="ee56b9a0106c983775a0691bde4a4a988f4351d3" BarId="305114" />
<Source Uri="https://github.com/dotnet/dotnet" Mapping="vstest" Sha="5ff448a6425ec6980e08b5c9a35e454c8a843c35" BarId="306238" />
<ProductDependencies>
<Dependency Name="Microsoft.Internal.CodeCoverage" Version="18.6.0-preview.26156.6">
<Uri>https://dev.azure.com/devdiv/DevDiv/_git/vs-code-coverage</Uri>
<Sha>82ffff0e0402fe4e9ac7e101132617e12df660f8</Sha>
</Dependency>
<Dependency Name="Microsoft.Diagnostics.NETCore.Client" Version="0.2.0-preview.26157.103">
<Dependency Name="Microsoft.Diagnostics.NETCore.Client" Version="0.2.0-preview.26165.107">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>ee56b9a0106c983775a0691bde4a4a988f4351d3</Sha>
<Sha>5ff448a6425ec6980e08b5c9a35e454c8a843c35</Sha>
</Dependency>
<!-- Necessary for source-build. This allows the live version of the package to be used by source-build. -->
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="6.0.2">
Expand Down
13 changes: 13 additions & 0 deletions src/Microsoft.TestPlatform.Build/Tasks/TestTaskUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.IO;

using Microsoft.Build.Utilities;

Expand Down Expand Up @@ -237,4 +238,16 @@ public static string CreateCommandLineArguments(ITestTask task)

return builder.ToString();
}

/// <summary>
/// Resolves the full path to the dotnet host from the DOTNET_HOST_PATH environment variable.
/// </summary>
/// <returns>
/// The resolved full path to the dotnet host, or <see langword="null"/> if the variable is not set or empty.
/// </returns>
internal static string? ResolveDotnetPath()
{
var dotnetHostPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH");
return StringUtils.IsNullOrEmpty(dotnetHostPath) ? null : Path.GetFullPath(dotnetHostPath);
}
}
4 changes: 1 addition & 3 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class VSTestTask : Task, ITestTask
{
private int _activeProcessId;

private const string DotnetExe = "dotnet";

[Required]
public ITaskItem? TestFileFullPath { get; set; }
public string? VSTestSetting { get; set; }
Expand Down Expand Up @@ -73,7 +71,7 @@ public override bool Execute()

var processInfo = new ProcessStartInfo
{
FileName = DotnetExe,
FileName = TestTaskUtils.ResolveDotnetPath() ?? "dotnet",
Arguments = TestTaskUtils.CreateCommandLineArguments(this),
UseShellExecute = false,
};
Expand Down
33 changes: 1 addition & 32 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -282,37 +281,7 @@ private bool TryGetMessage(string singleLine, out string name, out string?[] dat

protected override string? GenerateFullPathToTool()
{
if (!ToolPath.IsNullOrEmpty())
{
return Path.Combine(Path.GetDirectoryName(Path.GetFullPath(ToolPath))!, ToolExe);
}

//TODO: https://github.com/dotnet/sdk/issues/20 Need to get the dotnet path from MSBuild?

var dhp = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH");
if (!dhp.IsNullOrEmpty())
{
var path = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(dhp))!, ToolExe);
if (File.Exists(path))
{
return path;
}
}

if (File.Exists(ToolExe))
{
return Path.GetFullPath(ToolExe);
}

var values = Environment.GetEnvironmentVariable("PATH");
foreach (var p in values!.Split(Path.PathSeparator))
{
var fullPath = Path.Combine(p, ToolExe);
if (File.Exists(fullPath))
return fullPath;
}

return null;
return TestTaskUtils.ResolveDotnetPath();
}

/// <summary>
Expand Down
Loading