-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
To better support the upcoming file-based apps scenario coming in .NET 10 with dotnet run app.cs
, the run
command should be updated to support loading launch profiles from new JSON files based on the application name. This allows for multiple file-based apps to be located in the same directory and have separate launch profile configuration files. It also allows project-based apps to simplify their file structure by not needing to have a Properties
directory to put the launchSettings.json
file in. The naming scheme chooses to re-use the run
command's name in the file naming scheme so that it's more compact but the context the file applies in is still clear.
For example, when running a file-based app like app.cs
, the run
command should by default attempt to load launch profiles from a file named app.run.json
in the same directory as app.cs
. Additionally, project-based apps would get the same new behavior, so that a project like MyApp.csproj
should by default attempt to load launch profiles from a file named MyApp.run.json
in the project directory. In both cases, these files should only be loaded after the existing location of ./Properties/launchSettings.json
is attempted and the file does not exist. This is to ensure the established location has priority to ensure existing behavior is not changed. If however both files are present, a warning should be logged to the appropriate output so that it is clear which launch profiles file is being used.
A directory with a file-based app can look like the following:
- myapp/
- app.cs
- app.run.json
instead of:
- myapp/
- Properties/
- launchSettings.json
- app.cs
A directory with multiple file-based apps can look like the following:
- myapps/
- foo.cs
- foo.run.json
- bar.cs
- bar.run.json
When combined with dotnet/runtime#114302 and dotnet/aspnetcore#61343, a directory with multiple file-based apps can look like the following:
- myapps/
- foo.cs
- foo.run.json
- foo.settings.json
- bar.cs
- bar.run.json
- bar.settings.json
Alternatives
Instead of using the file name format [ApplicationName].run.json
, we could consider keeping the existing launchSettings.json
name and use [ApplicationName].launchSettings.json
instead, e.g.:
- myapp/
- app.cs
- app.launchSettings.json
While this loses the compactness and symmetry with the run
command name of the main proposal, it keeps the established name.