Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InvokeTestingPlatformTask to handle running with msbuild.exe and 'Test' target #4840

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -23,7 +23,7 @@ namespace Microsoft.Testing.Platform.MSBuild;
public class InvokeTestingPlatformTask : Build.Utilities.ToolTask, IDisposable
{
private const string MonoRunnerName = "mono";
private const string DotnetRunnerName = "dotnet";
private static readonly string DotnetRunnerName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dotnet.exe" : "dotnet";

private readonly IFileSystem _fileSystem;
private readonly PipeNameDescription _pipeNameDescription;
Expand Down Expand Up @@ -90,7 +90,7 @@ protected override string ToolName
if (TargetPath.ItemSpec.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase))
{
Log.LogMessage(MessageImportance.Low, $"Target path is a dll '{TargetPath.ItemSpec}'");
return DotnetRunnerName + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty);
return DotnetRunnerName;
}

// If the target is an exe and we're not on Windows we try with the mono runner.
Expand Down Expand Up @@ -182,8 +182,7 @@ protected override string GenerateCommandLineCommands()

if (IsNetCoreApp)
{
string dotnetRunnerName = ToolName;
if (dotnetRunnerName != MonoRunnerName && Path.GetFileName(_currentProcess.MainModule!.FileName!).Equals(dotnetRunnerName, StringComparison.OrdinalIgnoreCase))
if (ToolName == DotnetRunnerName)
{
builder.AppendSwitch("exec");
builder.AppendFileNameIfNotNull(TargetPath.ItemSpec);
Expand Down
Loading