Skip to content

Deprecating -p for --project for dotnet run #24727

@KathleenDollard

Description

@KathleenDollard

This change is documented in Spec for resolving '-p' in 'dotnet run'

Deprecate -p

-p will no longer be a valid abbreviation for project. In .NET 6, users will receive a warning.

This warning will be from the CLI parser, so will not generally trigger WarningsAsErrors failures. However, if a wrapping MSBuild or CI process checks for the text "Warning" it will appear in that check.

Also, if --property is an option passed to the application being run, the -- syntax separator must be used.

Version introduced

.NET Core 6.0 Preview 6

Old behavior

  • -p previously indicated --project.
  • --property was not a valid option on dotnet run and was passed through to the underlying application, even if the -- syntax separator was not used.

New behavior

  • -p will retain this meaning for .NET 6, but will result in a warning that it is deprecated and to use the full --project. At some future point, we will remove the use of -p to indicate --project.
  • --property is now a valid option on dotnet run and this option will not be passed through to the underlying application, unless the -- syntax separator is used.

Reason for change

We are deprecating -p because of the close relationship dotnet run has with dotnet build and dotnet publish. This breaking change is the first step in aligning abbreviations for these commands.

Embracing Xamarin/Maui results in a need to pass MSBuild properties to MSBuild during the build portion of dotnet run. We want the option specifying this to be the same for dotnet run, dotnet build and dotnet publish.

Recommended action

If you encounter the new warning, please use --project. If you have a project argument that includes an = and use the -p abbreviation, it will be interpreted as --property and passed to MSBuild, so you will have to use --project to pass it to your application in all cases.

If you have an application that has an option called --property, you will need to use the syntax separator to pass the the value to your application:

dotnet run -- --property myPropertyValue

Please review any scripts that use dotnet run where you might overlook the warning if -p is used.

If you have any scripts that are using “dotnet run” and process the output you could encounter a break. dotnet run typically doesn’t output anything of its own if there are no errors, so you only get the output of the program that is being run. If you have a script or other program wrapping “dotnet run” and parsing the output, the warning would be unexpected text and may cause a failure.

Category

  • ASP.NET Core
  • C#
  • Code analysis
  • Core .NET libraries
  • Cryptography
  • Data
  • Debugger
  • Deployment
  • Globalization
  • Interop
  • JIT
  • LINQ
  • Managed Extensibility Framework (MEF)
  • MSBuild
  • Networking
  • Printing
  • SDK
  • Security
  • Serialization
  • Visual Basic
  • Windows Forms
  • Windows Presentation Foundation (WPF)
  • XML, XSLT

Affected APIs

Not detectable via API analysis


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 6Issues and PRs for the .NET 6 releasebreaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions