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
In the old .csproj, you could set the following properties on an
<OutputType>Library</OutputType>project:And when you F5'd in VS, it would launch the
StartProgramas expected.In the
Microsoft.NET.Sdk, it translates these properties to the newRunCommand,RunArgumentsandRunWorkingDirectoryproperties that are used as the contract between the MSBuild project and both VS anddotnet runfor 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>.project-system/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Debug/ConsoleDebugTargetsProvider.cs
Lines 228 to 235 in 47787b3
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
StartActionandStartProgramshould "just work" in the new project system./cc @BillHiebert