diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs
index e5702ab16d..630149957a 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs
@@ -459,7 +459,8 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
if (testHostPath.IsNullOrEmpty())
{
- throw new TestPlatformException("Could not find testhost");
+ string message = string.Format(CultureInfo.CurrentCulture, Resources.CouldNotFindTesthost, sourcePath, sourceDirectory);
+ throw new TestPlatformException(message);
}
// We silently force x64 only if the target architecture is the default one and is not specified by user
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs
index 746b193bc5..4b3c612666 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.Designer.cs
@@ -70,7 +70,18 @@ internal static string MultipleFileVersions {
return ResourceManager.GetString("MultipleFileVersions", resourceCulture);
}
}
-
+
+ ///
+ /// Looks up a localized string for testhost not found with path and directory info.
+ ///
+ internal static string CouldNotFindTesthost
+ {
+ get
+ {
+ return ResourceManager.GetString("CouldNotFindTesthost", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Unable to find {0}. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk"..
///
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.resx b/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.resx
index 8ea0055bda..a5850f83c6 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.resx
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/Resources.resx
@@ -127,6 +127,16 @@
Unable to find {0}. Please publish your test project and retry.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+
Could not find '{0}' host for the '{1}' architecture.
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.cs.xlf
index 256626d298..6f9ac6d0a5 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.cs.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.cs.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.de.xlf
index 2967eba3cd..d5e2aa90bd 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.de.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.de.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.es.xlf
index 1baa96fce9..30c3be333c 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.es.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.es.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.fr.xlf
index 6bc1c4ece8..20154e025a 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.fr.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.fr.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.it.xlf
index 28a9ab558a..2b0566b9e3 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.it.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.it.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ja.xlf
index 77a6d4fa7a..dc6f36571c 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ja.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ja.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ko.xlf
index bc1dea8896..f34e7ed501 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ko.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ko.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pl.xlf
index 167d6f7382..ce8f35bb1f 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pl.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pl.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pt-BR.xlf
index 2c6e6e4e81..9a31b11620 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pt-BR.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.pt-BR.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ru.xlf
index e8b38482c5..a79062e49a 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ru.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.ru.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.tr.xlf
index b66a5a4d50..a0082a7960 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.tr.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.tr.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hans.xlf
index 29ea7524b7..59e19341bb 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hans.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hans.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hant.xlf
index 9f370fae8a..cda4d529d9 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hant.xlf
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Resources/xlf/Resources.zh-Hant.xlf
@@ -2,6 +2,23 @@
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ Could not find testhost for test source '{0}'.
+
+Verify that:
+ - The test project references the 'Microsoft.NET.Test.Sdk' NuGet package.
+ - The project has been built and the output is in '{1}'.
+ - The project's target framework matches the installed .NET runtime.
+
+ '{0}' is the path to the test source (DLL/EXE), '{1}' is the directory where testhost was searched.
+ Multiple versions of same extension found. Selecting the highest version.
{0}
diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs
index c181459315..c4b5c3375f 100644
--- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs
+++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs
@@ -543,6 +543,23 @@ public void GetTestHostProcessStartInfoShouldThrowExceptionWhenDotnetIsNotInstal
Assert.ThrowsExactly(action);
}
+ [TestMethod]
+ public void GetTestHostProcessStartInfoShouldIncludeSourcePathInExceptionMessageWhenTesthostNotFound()
+ {
+ var sourcePath = Path.Combine(_temp, "mytest.dll");
+ var sourceDirectory = Path.GetDirectoryName(sourcePath)!;
+
+ // Ensure no testhost.dll exists anywhere
+ _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(false);
+
+ Action action = () => _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo);
+
+ var exception = Assert.ThrowsExactly(action);
+ Assert.Contains(sourcePath, exception.Message);
+ Assert.Contains(sourceDirectory, exception.Message);
+ }
+
+
[TestMethod]
public void GetTestHostProcessStartInfoShouldIncludeSourceDirectoryAsWorkingDirectory()
{