Skip to content

Setting RunCommand/StartProgram on ClassLibrary doesn't work in new project system #3684

@eerhardt

Description

@eerhardt

In the old .csproj, you could set the following properties on an <OutputType>Library</OutputType> project:

  • StartAction = Program
  • StartProgram
  • StartArguments
  • StartWorkingDirectory

And when you F5'd in VS, it would launch the StartProgram as expected.

In the Microsoft.NET.Sdk, it translates these properties to the new RunCommand, RunArguments and RunWorkingDirectory properties that are used as the contract between the MSBuild project and both VS and dotnet run for how to execute/run the project.
See https://github.com/dotnet/sdk/blob/0af8aa984773c32752634a62c87edcceedcb93e3/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L387-L397

However, the project-system explicitly blocks F5'ing an project with <OutputType>Library</OutputType>.

// If we're launching for debug purposes, prevent someone F5'ing a class library
if (validateSettings && await IsClassLibraryAsync().ConfigureAwait(false))
{
throw new Exception(VSResources.ProjectNotRunnableDirectly);
}
// Get the executable to run, the arguments and the default working directory
Tuple<string, string, string> runData = await GetRunnableProjectInformationAsync(configuredProject).ConfigureAwait(false);

This kind of limiting shouldn't be done by the project-system. If the project returns a valid RunCommand, the project-system should run it, no matter what the <OutputType> is set to.

This is a breaking change from the old project system to the new. Setting StartAction and StartProgram should "just work" in the new project system.

/cc @BillHiebert

Metadata

Metadata

Assignees

Labels

Feature-DebuggingLaunching an application via F5, setting debug properties and launch profiles.Resolution-FixedThe bug has been fixed, refer to the milestone to see in which release it was fixed.

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions