[SOLVED] What does '/p:' on the Windows Command Line mean


I want to name the environment in the command line when using dotnet publish. I found this solution

dotnet publish -o site /p:EnvironmentName=Production

I’ve never seen that /p: argument before and want to know what exactly that is. I tried to google it but because of its syntax it was hard to find anything.

I especially want to know if I can use this command also on a Linux machine in bash.


Basically, it is passed to MSBuild and sets a variable/property called EnvironmentName to a value Production. Then MSBuild scripts can read that variable when performing various tasks. It’s moreless the same as setting a property in <PropertyGroup> in MSBuild script (also VisualStudio’s cpsroj file).

You can see it for example here

msbuild buildapp.csproj -t:HelloWorld -p:Configuration=Release

Note that -p: syntax is the same as /p: (also -t: and /t: and so on). The former is the new one, while the latter conforms to old "DOS" way of providing command line options in Windows. For quite a couple of years many newer developer tools from Microsoft accept both ways, but the - is preferred, as it can also be used in i.e. powershell or linux, while the older / can’t (or can, but cause some problems or need complicated escaping/quoting).

EDIT: ah yes, and I didn’t fully answer.. The -p or /p is NOT a "windows commandline thing". In your example, this is a parameter for the dotnet program, and what I described above is true only because dotnet happens to later call into msbuild program. if you spot such -p//p parameter anywhere else, in any other application, then it may do something completely different.

Lastly, on Linux – yes, you can use it with dotnet toolset on Linux as well (net core, mono, etc) ((and I’d strongly suggest using -p: version)). However, same rules apply. As long as it is used with this app called dotnet, it will have the effect of setting environmentname during build. In any other case, or any other app, such parameter can have other meanings. It’s all app-dependent, be it on Windows, or Linux.

Answered By – quetzalcoatl

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *