diff --git a/src/Cli/dotnet/Commands/CliCommandStrings.resx b/src/Cli/dotnet/Commands/CliCommandStrings.resx index f23cf44e4f8a..47e67b2f714e 100644 --- a/src/Cli/dotnet/Commands/CliCommandStrings.resx +++ b/src/Cli/dotnet/Commands/CliCommandStrings.resx @@ -1775,10 +1775,11 @@ The default is to publish a framework-dependent application. Couldn't find a project to run. Ensure a project exists in {0}, or pass the path to the project using {1}. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/Run/RunCommand.cs b/src/Cli/dotnet/Commands/Run/RunCommand.cs index b87c16bc78fc..d0991769c546 100644 --- a/src/Cli/dotnet/Commands/Run/RunCommand.cs +++ b/src/Cli/dotnet/Commands/Run/RunCommand.cs @@ -511,8 +511,8 @@ internal static void ThrowUnableToRunError(ProjectInstance project) throw new GracefulException( string.Format( CliCommandStrings.RunCommandExceptionUnableToRun, - "dotnet run", - "OutputType", + project.GetPropertyValue("MSBuildProjectFullPath"), + Product.TargetFrameworkVersion, project.GetPropertyValue("OutputType"))); } diff --git a/src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs b/src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs index 8b3ad0e55eb9..9d73f9a7c3eb 100644 --- a/src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs +++ b/src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.CommandLine; using System.Diagnostics; using Microsoft.Build.Evaluation; using Microsoft.Build.Execution; @@ -230,23 +229,37 @@ public static IEnumerable - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Projekt se nedá spustit. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Projekt se nedá spustit. Ověřte prosím, že máte spustitelný typ projektu, a zajistěte, aby tento projekt podporoval {0}. Cílem spustitelného projektu by mělo být TFM (například net5.0) a jeho OutputType by měl být Exe. Aktuální {1} je {2}. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf index 6f29b52fb838..8e5f70fbc85d 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf @@ -2678,15 +2678,15 @@ Standardmäßig wird eine Framework-abhängige Anwendung veröffentlicht. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Ihr Projekt kann nicht ausgeführt werden. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Ihr Projekt kann nicht ausgeführt werden. Stellen Sie sicher, dass der Projekttyp ausführbar ist und "{0}" dieses Projekt unterstützt. Ein ausführbares Projekt muss ein ausführbares TFM (z. B. net5.0) und den OutputType "Exe" verwenden. {1} lautet aktuell "{2}". - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf index 49091a34d4be..dffe40158ffb 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf @@ -2678,15 +2678,15 @@ El valor predeterminado es publicar una aplicación dependiente del marco. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - No se puede ejecutar el proyecto. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + No se puede ejecutar el proyecto. Asegúrese de tener un tipo de proyecto ejecutable y asegúrese de que "{0}" admita este proyecto. Un proyecto ejecutable debe tener como destino un TFM ejecutable (por ejemplo, net5.0) y tener como OutputType "Exe". El valor actual de {1} es "{2}". - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf index 1f3d6ea0feaa..20c1298f1012 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf @@ -2678,15 +2678,15 @@ La valeur par défaut est de publier une application dépendante du framework. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Impossible d'exécuter votre projet. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Impossible d'exécuter votre projet. Vérifiez que vous avez un type de projet exécutable et que '{0}' prend en charge ce projet. Un projet exécutable doit cibler un TFM exécutable (par exemple, net5.0) et avoir OutputType 'Exe'. Le {1} actuel est '{2}'. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf index 55c1ca7f75cf..7efc22a0b482 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf @@ -2678,15 +2678,15 @@ Per impostazione predefinita, viene generato un pacchetto dipendente dal framewo - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Non è possibile eseguire il progetto. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Non è possibile eseguire il progetto. Assicurarsi che sia presente un tipo di progetto eseguibile e che '{0}' supporti tale progetto. Un progetto eseguibile deve essere destinato a un TFM eseguibile, ad esempio net5.0, inoltre OutputType deve essere impostato su 'Exe'. Il valore corrente di {1} è '{2}'. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf index 8b535547cc24..8b97cdc8eb8e 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf @@ -2678,15 +2678,15 @@ The default is to publish a framework-dependent application. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - プロジェクトを実行できません。 + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + プロジェクトを実行できません。 プロジェクト タイプが実行可能であること、このプロジェクトが '{0}' でサポートされていることを確認してください。 実行可能なプロジェクトは実行可能な TFM (たとえば、net5.0) を対象としている必要があり、OutputType 'Exe' が必要です。 現在の {1} は '{2}' です。 - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf index 729b384a6a12..8460be6b1d57 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf @@ -2678,15 +2678,15 @@ The default is to publish a framework-dependent application. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - 프로젝트를 실행할 수 없습니다. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + 프로젝트를 실행할 수 없습니다. 실행 가능한 프로젝트 형식이 있고 '{0}'에서 이 프로젝트를 지원하는지 확인하세요. 실행 가능한 프로젝트는 실행 가능한 TFM(예: net5.0)을 대상으로 하고 OutputType 'Exe'가 있어야 합니다. 현재 {1}은(는) '{2}'입니다. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf index 21d3e0a1e63c..602d6cfca56e 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf @@ -2678,15 +2678,15 @@ Domyślnie publikowana jest aplikacja zależna od struktury. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Nie można uruchomić projektu. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Nie można uruchomić projektu. Upewnij się, że używany typ projektu umożliwia uruchamianie oraz że element „{0}” obsługuje ten projekt. Projekt z możliwością uruchamiania musi mieć moniker TFM z możliwością uruchomienia (np. net5.0) i typ OutputType „Exe”. Bieżący element {1}: „{2}”. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf index 2d060e3f72fc..81f18778f821 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf @@ -2678,15 +2678,15 @@ O padrão é publicar uma aplicação dependente de framework. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Não é possível executar o projeto. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Não é possível executar o projeto. Verifique se você tem um tipo de projeto executável e se '{0}' dá suporte a esse projeto. Um projeto executável deve ter como destino um TFM executável (por exemplo, o net5.0) e ter o OutputType 'Exe'. O {1} atual é '{2}'. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf index 34fa50682e5a..b09ed29f55e4 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf @@ -2678,15 +2678,15 @@ The default is to publish a framework-dependent application. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Не удалось запустить проект. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Не удалось запустить проект. Убедитесь, что тип проекта поддерживает запуск и что "{0}" поддерживает этот проект. Запускаемый проект должен быть предназначен для TFM с поддержкой запуска (например, net5.0) и иметь тип выходных данных "EXE". Текущий {1} — "{2}". - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf index 08f18f98d955..e08f7234716c 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf @@ -2678,15 +2678,15 @@ Varsayılan durum, çerçeveye bağımlı bir uygulama yayımlamaktır. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - Projeniz çalıştırılamıyor. + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + Projeniz çalıştırılamıyor. Çalıştırılabilir bir proje türüne sahip olduğunuzdan ve bu projenin '{0}' tarafından desteklendiğinden emin olun. Çalıştırılabilir proje, çalıştırılabilir bir TFM’yi (örneğin, net5.0) hedeflemeli ve OutputType değeri 'Exe' olmalıdır. Geçerli {1}: '{2}'. - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf index 7f29149cd68f..c3c642422395 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf @@ -2678,15 +2678,15 @@ The default is to publish a framework-dependent application. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - 无法运行项目。 + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + 无法运行项目。 请确保你具有可运行的项目类型且“{0}”支持此项目。 可运行的项目应面向可运行的 TFM (例如 net5.0)且其 OutputType 为 "Exe"。 当前的 {1} 为“{2}”。 - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf index 4555110d63c8..c2d51eb74018 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf @@ -2678,15 +2678,15 @@ The default is to publish a framework-dependent application. - Unable to run your project. -Ensure you have a runnable project type and ensure '{0}' supports this project. -A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. -The current {1} is '{2}'. - 無法執行您的專案。 + Unable to proceed with project '{0}'. +Ensure you have a runnable project type. +A runnable project should target a runnable TFM (for instance, net{1}) and have OutputType 'Exe'. +The current OutputType is '{2}'. + 無法執行您的專案。 請確定您有可執行的專案類型,並確定 '{0}' 支援此專案。 可執行的專案應以可執行的 TFM (例如 net5.0) 為目標,且 OutputType 應為 'Exe'。 目前的 {1} 為 '{2}'。 - + {0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"} Unable to run your project diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/AnotherTestProject.csproj b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/AnotherTestProject.csproj new file mode 100644 index 000000000000..b1a47ffa11df --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/AnotherTestProject.csproj @@ -0,0 +1,11 @@ + + + + + $(CurrentTargetFramework) + enable + enable + true + + + \ No newline at end of file diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/Operations.cs b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/Operations.cs new file mode 100644 index 000000000000..549c1916e76d --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/AnotherTestProject/Operations.cs @@ -0,0 +1,9 @@ +namespace Calculator.Core; + +public class Operations +{ + public double Add(double a, double b) => a + b; + public double Subtract(double a, double b) => a - b; + public double Multiply(double a, double b) => a * b; + public double Divide(double a, double b) => a / b; +} \ No newline at end of file diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects.sln b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects.sln new file mode 100644 index 000000000000..027f72f15fbe --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35415.258 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtherTestProject", "OtherTestProject\OtherTestProject.csproj", "{8683AE78-764B-46C2-98D4-8A3031CBA27E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnotherTestProject", "AnotherTestProject\AnotherTestProject.csproj", "{2604B2BA-D36A-461D-9BB3-207E4253051C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8683AE78-764B-46C2-98D4-8A3031CBA27E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8683AE78-764B-46C2-98D4-8A3031CBA27E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8683AE78-764B-46C2-98D4-8A3031CBA27E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8683AE78-764B-46C2-98D4-8A3031CBA27E}.Release|Any CPU.Build.0 = Release|Any CPU + {2604B2BA-D36A-461D-9BB3-207E4253051C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2604B2BA-D36A-461D-9BB3-207E4253051C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2604B2BA-D36A-461D-9BB3-207E4253051C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2604B2BA-D36A-461D-9BB3-207E4253051C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/OtherTestProject.csproj b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/OtherTestProject.csproj new file mode 100644 index 000000000000..661f82496256 --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/OtherTestProject.csproj @@ -0,0 +1,20 @@ + + + + + Exe + $(CurrentTargetFramework) + enable + enable + true + + + + + + + + + + + diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/Program.cs b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/Program.cs new file mode 100644 index 000000000000..5785dc473c5b --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/OtherTestProject/Program.cs @@ -0,0 +1,105 @@ +//See https://aka.ms/new-console-template for more information + +//Opt -out telemetry + +using Microsoft.Testing.Platform.Builder; +using Microsoft.Testing.Platform.Capabilities.TestFramework; +using Microsoft.Testing.Platform.Extensions.Messages; +using Microsoft.Testing.Platform.Extensions.TestFramework; + +var testApplicationBuilder = await TestApplication.CreateBuilderAsync(args); + +//testApplicationBuilder.AddMSTest(() => new[] { Assembly.GetEntryAssembly()! }); +testApplicationBuilder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, __) => new DummyTestAdapter()); + +using var testApplication = await testApplicationBuilder.BuildAsync(); +return await testApplication.RunAsync(); + +public class DummyTestAdapter : ITestFramework, IDataProducer +{ + public string Uid => nameof(DummyTestAdapter); + + public string Version => "2.0.0"; + + public string DisplayName => nameof(DummyTestAdapter); + + public string Description => nameof(DummyTestAdapter); + + public Task IsEnabledAsync() => Task.FromResult(true); + + public Type[] DataTypesProduced => new[] { + typeof(TestNodeUpdateMessage), + typeof(SessionFileArtifact), + typeof(FileArtifact), }; + + public Task CreateTestSessionAsync(CreateTestSessionContext context) + => Task.FromResult(new CreateTestSessionResult() { IsSuccess = true }); + + public Task CloseTestSessionAsync(CloseTestSessionContext context) + => Task.FromResult(new CloseTestSessionResult() { IsSuccess = true }); + + public async Task ExecuteRequestAsync(ExecuteRequestContext context) + { + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test0", + DisplayName = "Test0", + Properties = new PropertyBag(new DiscoveredTestNodeStateProperty()), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test0", + DisplayName = "Test0", + Properties = new PropertyBag(new PassedTestNodeStateProperty("OK")), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test1", + DisplayName = "Test1", + Properties = new PropertyBag(new SkippedTestNodeStateProperty("OK skipped!")), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test2", + DisplayName = "Test2", + Properties = new PropertyBag(new FailedTestNodeStateProperty(new Exception("this is a failed test"), "not OK")), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test3", + DisplayName = "Test3", + Properties = new PropertyBag(new TimeoutTestNodeStateProperty(new Exception("this is a timeout exception"), "not OK")), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test4", + DisplayName = "Test4", + Properties = new PropertyBag(new ErrorTestNodeStateProperty(new Exception("this is an exception"), "not OK")), + })); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test5", + DisplayName = "Test5", + Properties = new PropertyBag(new CancelledTestNodeStateProperty(new Exception("this is a cancelled exception"), "not OK")), + })); + + await context.MessageBus.PublishAsync(this, new FileArtifact(new FileInfo("file.txt"), "file", "file description")); + + await context.MessageBus.PublishAsync(this, new SessionFileArtifact(context.Request.Session.SessionUid, new FileInfo("sessionFile.txt"), "sessionFile", "description")); + + await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode() + { + Uid = "Test6 id", + DisplayName = "Test6", + Properties = new PropertyBag(new PassedTestNodeStateProperty("OK"), new FileArtifactProperty(new FileInfo("testNodeFile.txt"), "testNodeFile", "description")), + })); + + context.Complete(); + } +} diff --git a/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/dotnet.config b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/dotnet.config new file mode 100644 index 000000000000..28daa0a28213 --- /dev/null +++ b/test/TestAssets/TestProjects/ClassLibraryWithIsTestProjectAndOtherTestProjects/dotnet.config @@ -0,0 +1,2 @@ +[dotnet.test.runner] +name= "Microsoft.Testing.Platform" \ No newline at end of file diff --git a/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs b/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs index 54476f213d0d..059d1ea06800 100644 --- a/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs @@ -265,6 +265,26 @@ public void RunTestProjectsWithHybridModeTestRunners_ShouldReturnExitCodeGeneric result.ExitCode.Should().Be(ExitCodes.GenericFailure); } + [InlineData(TestingConstants.Debug)] + [InlineData(TestingConstants.Release)] + [Theory] + public void RunTestProjectsWithClassLibraryHavingIsTestProjectAndMTPProject_ShouldReturnExitCodeGenericFailure(string configuration) + { + TestAsset testInstance = _testAssetsManager.CopyTestAsset("ClassLibraryWithIsTestProjectAndOtherTestProjects", Guid.NewGuid().ToString()) + .WithSource(); + + CommandResult result = new DotnetTestCommand(Log, disableNewOutput: false) + .WithWorkingDirectory(testInstance.Path) + .Execute(TestingPlatformOptions.ConfigurationOption.Name, configuration); + + if (!TestContext.IsLocalized()) + { + result.StdOut.Should().Contain(string.Format(CliCommandStrings.CmdUnsupportedVSTestTestApplicationsDescription, "AnotherTestProject.csproj")); + } + + result.ExitCode.Should().Be(ExitCodes.GenericFailure); + } + [InlineData(TestingConstants.Debug)] [InlineData(TestingConstants.Release)] [Theory]