-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spec for resolving '-p' in 'dotnet run' #229
base: main
Are you sure you want to change the base?
Changes from 3 commits
b1e8eb2
6a183ec
2f8c3cf
6b0fdb3
8748947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,49 @@ | ||||||||||
# Syntax for passing properties to MSBuild in `dotnet run` | ||||||||||
|
||||||||||
Kathleen Dollard | Status: Draft | ||||||||||
|
||||||||||
The .NET CLI passes all command line arguments that are not explicitly handled through to MSBuild for `dotnet build` and `dotnet publish`. This does not work for `dotnet run` because there are three sets of arguments: | ||||||||||
|
||||||||||
* CLI arguments for `dotnet run` itself. | ||||||||||
* Arguments for the resulting application, identified by `--`. | ||||||||||
* MSBuild arguments, which are not currently supported. | ||||||||||
|
||||||||||
To support the Xamarin/Maui workloads, we need to pass a property to MSBuild that specifies the device to target. This is being solved by adding a `--property` option to `dotnet run`. This will route to MSBuild as `-p:<delimited list>. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
**Note:** A long term approach to managing “device” selection is planned for a later release. In .NET 6 CLI usage of these workloads is expected to just be CI, so this is not considered critical, and the design work is expected to include adjacent problems of specifying containers, and x64 emulation). | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: get rid of smart quotes
Suggested change
|
||||||||||
|
||||||||||
A problem arises in the abbreviation. `-p`. It is currently used to specify the `--project` for `dotnet run`. This proposal is a course to change `-p` from meaning `--project` to `--property` in order to be consistent with the similar commands - `dotnet build` and ` dotnet publish`. This proposal balances backward compatibility and consistency with other commands, which we can do because the usages can be distinguished syntactically. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
During a deprecation phase, which will be at least the length of .NET 6, older usage of `-p` as `--project` will be recognized as when there is no trailing colon (`-p:`) and the argument is not legal for MSBuild. Users will receive a warning that the abbreviation is deprecated. | ||||||||||
|
||||||||||
We will identify usage as `--property` when the argument is legal MSBuild syntax. Legal MSBuild syntax will be defined as: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
* A comma or semi-colon delimited strings of values in the format <name>=<value> or <name>:<value> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to worry that it's a comma or semi-colon delimited list for detecting whether it's legal for MSBuild, because many usages will only have one property name and hence won't have a delimiter. So we should just say we look to see whether there is an |
||||||||||
|
||||||||||
## Goals | ||||||||||
|
||||||||||
We believe that in the long term `-p` should be used consistently across `dotnet build`, `dotnet publish` and `dotnet run` because of similarity between these commands. | ||||||||||
|
||||||||||
### Design | ||||||||||
|
||||||||||
The basic design is described in the opening: | ||||||||||
|
||||||||||
* `-p` with syntax that is valid for MSBuild properties will be treated as `--property`. | ||||||||||
* `-p:` will be passed to MSBuild so the an MSBuild error is displayed when the argument is illegal. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should drop the distinction between |
||||||||||
* Any other usage will be treated as `--project` and will receive a warning that this use is deprecated. | ||||||||||
* Usage in the form `-p:` will be allowed but not encouraged or documented. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per prior comment, probably this line can be dropped. |
||||||||||
* At some future point, we will remove `-p` for `--project`. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we need to commit to eventually removing
Suggested change
|
||||||||||
|
||||||||||
### Warning text | ||||||||||
|
||||||||||
When -p is used (with no colon) in .NET 6, the following warning will be displayed: | ||||||||||
|
||||||||||
*“The abbreviation of -p for --project is deprecated. Please use --project.”* | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm not sure about the exact formatting we should use for the warning and error code. |
||||||||||
|
||||||||||
### Implementation notes | ||||||||||
|
||||||||||
We are displaying a deprecation warning for `-p` in .NET 6 and hope to do the additional work to support `-p`. However, once the deprecation is in place, we can add the abbreviation in a feature band (quarterly) release. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
|
||||||||||
## Q & A | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
--
to identify arguments for the resulting application, but you don't have to. Unrecognized arguments will be passed through. So part of the difference betweendotnet run
and other commands is thatdotnet run
passes unrecognized arguments to the app it runs, while other commands pass them through to MSBuild.This also means that any parameters we add to
dotnet run
are breaking changes, as if an app was previously using those parameters and they were being passed through to it without--
, then the app will no longer get them.