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
9 changes: 5 additions & 4 deletions src/Cli/dotnet/Commands/CliCommandStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,11 @@ The default is to publish a framework-dependent application.</value>
<value>Couldn't find a project to run. Ensure a project exists in {0}, or pass the path to the project using {1}.</value>
</data>
<data name="RunCommandExceptionUnableToRun" xml:space="preserve">
<value>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}'.</value>
<value>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}'.</value>
<comment>{0} is project file path. {1} is dotnet framework version. {2} is the project output type.{Locked="OutputType"}{Locked="Exe"}</comment>
</data>
<data name="RunCommandExceptionUnableToRunSpecifyFramework" xml:space="preserve">
<value>Unable to run your project
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/dotnet/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}

Expand Down
43 changes: 28 additions & 15 deletions src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -230,23 +229,37 @@ public static IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModule
}

string targetFramework = project.GetPropertyValue(ProjectProperties.TargetFramework);
RunProperties runProperties = GetRunProperties(project, loggers);
string projectFullPath = project.GetPropertyValue(ProjectProperties.ProjectFullPath);


// dotnet run throws the same if RunCommand is null or empty.
// In dotnet test, we are additionally checking that RunCommand is not dll.
// In any "default" scenario, RunCommand is never dll.
// If we found it to be dll, that is user explicitly setting RunCommand incorrectly.
if (string.IsNullOrEmpty(runProperties.Command) || runProperties.Command.HasExtension(CliConstants.DLLExtension))
// Only get run properties if IsTestingPlatformApplication is true
RunProperties runProperties;
if (isTestingPlatformApplication)
{
throw new GracefulException(
string.Format(
CliCommandStrings.RunCommandExceptionUnableToRun,
"dotnet test",
"OutputType",
project.GetPropertyValue("OutputType")));
}
runProperties = GetRunProperties(project, loggers);

string projectFullPath = project.GetPropertyValue(ProjectProperties.ProjectFullPath);
// dotnet run throws the same if RunCommand is null or empty.
// In dotnet test, we are additionally checking that RunCommand is not dll.
// In any "default" scenario, RunCommand is never dll.
// If we found it to be dll, that is user explicitly setting RunCommand incorrectly.
if (string.IsNullOrEmpty(runProperties.Command) || runProperties.Command.HasExtension(CliConstants.DLLExtension))
{
throw new GracefulException(
string.Format(
CliCommandStrings.RunCommandExceptionUnableToRun,
projectFullPath,
Product.TargetFrameworkVersion,
project.GetPropertyValue("OutputType")));
}
}
else
{
// For VSTest test projects, create minimal RunProperties
runProperties = new RunProperties(
project.GetPropertyValue(ProjectProperties.TargetPath),
null,
null);
}

// TODO: Support --launch-profile and pass it here.
var launchSettings = TryGetLaunchProfileSettings(Path.GetDirectoryName(projectFullPath)!, Path.GetFileNameWithoutExtension(projectFullPath), project.GetPropertyValue(ProjectProperties.AppDesignerFolder), buildOptions, profileName: null);
Expand Down
12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading