Skip to content

Implementation of GetVsTestConsolePath in RunTests tool looks fragile #81570

@AlekseyTs

Description

@AlekseyTs

For whatever reason I had a pretty old SDK sitting in the folder and the tool was picking 'vstest.console.dll' from it for Desktop. That lead to zero tests being discovered in the test assemblies, and sometimes to some very unhelpful error. Nothing was pointing to the problem explicitly. Almost accidentally I noticed strange version number in the path for 'vstest.console.dll' in 'runtests_.log'. I had to delete that SDK folder to get the tool working. I didn't check what the tool was using for Core tests, but they were executed.

It looks like the problem is in the function below. It picks a "random" 'vstest.console.dll'. We should consider locating one from the "current" SDK, whatever that means.

        private static string GetVsTestConsolePath(string dotnetPath)
        {
            var dotnetDir = Path.GetDirectoryName(dotnetPath)!;
            var sdkDir = Path.Combine(dotnetDir, "sdk");
            var vsTestConsolePath = Directory.EnumerateFiles(sdkDir, "vstest.console.dll", SearchOption.AllDirectories).Last();
            return vsTestConsolePath;
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions