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
16 changes: 6 additions & 10 deletions src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static int Run(ParseResult parseResult)

// Fix for https://github.com/Microsoft/vstest/issues/1453
// Run dll/exe directly using the VSTestForwardingApp
if (ContainsBuiltTestSources(args))
if (ContainsBuiltTestSources(parseResult))
{
return ForwardToVSTestConsole(parseResult, args, settings, testSessionCorrelationId);
}
Expand Down Expand Up @@ -295,18 +295,14 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat
}
}

private static bool ContainsBuiltTestSources(string[] args)
private static bool ContainsBuiltTestSources(ParseResult parseResult)
{
for (int i = 0; i < args.Length; i++)
for (int i = 0; i < parseResult.UnmatchedTokens.Count; i++)
{
string arg = args[i];
if (arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
string arg = parseResult.UnmatchedTokens[i];
if (!arg.StartsWith("-") &&
(arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)))
{
var previousArg = i > 0 ? args[i - 1] : null;
if (previousArg != null && CommonOptions.PropertiesOption.Aliases.Contains(previousArg))
{
return false;
}
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,28 @@ public void PropertiesEndingWithDotDllShouldNotFail(string property)
result.ExitCode.Should().Be(1);
}

[Fact]
public void DistributedLoggerEndingWithDotDllShouldBePassedToMSBuild()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
.WithWorkingDirectory(testProjectDirectory)
.Execute(ConsoleLoggerOutputNormal.Concat(["-dl:my.dll"]));

if (!TestContext.IsLocalized())
{
// This ensures that this was passed to MSBuild and not vstest.console.
result.StdOut.Should().Contain("error MSB1021: Cannot create an instance of the logger my.dll.");
}
else
{
result.StdOut.Should().Contain("MSB1021");
}

result.ExitCode.Should().Be(1);
}

private string CopyAndRestoreVSTestDotNetCoreTestApp(object[] parameters, [CallerMemberName] string callingMethod = "")
{
// Copy VSTestCore project in output directory of project dotnet-vstest.Tests
Expand Down
Loading