Sdk: Short form /p:PropertName doesn't work in git bash on windows

Created on 17 Sep 2018  路  5Comments  路  Source: dotnet/sdk

Steps to reproduce

  • Open git bash on windows

    • From git bash create new netstandard2.0 project:

mkdir ~/my-demo-lib
cd ~/my-demo-lib
dotnet new classlib
  • Run any dotnet command with short version of msbuild property: /p: . For example create a new NuGet package
dotnet pack /p:PackageVersion="1.0.0-dev"

Expected behavior

A new NuGet package should be created.

Actual behavior

Command fails with following output:

Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1009: Project file does not exist.
Switch: p:PackageVersion=1.0.0-dev

image

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.402
 Commit:    3599f217f4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.402\

Host (useful for support):
  Version: 2.1.4
  Commit:  85255dde3e

.NET Core SDKs installed:
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNe                                                                                            tCore.All]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNe                                                                                            tCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.                                                                                            App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.                                                                                            App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.                                                                                            App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.                                                                                            App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

git --version output

git version 2.14.3.windows.1

Details

The issue occurs only on git bash for windows. I was not able to reproduce it on windows cmd or Linux bash. Long form /property: works as expected in git bash. As suggested by @dasMulli short version in form -p: works fine.

I'd say it is a small issue, but it creates troubles because the official documentations uses /p: form. Probably it's better to update documentation or mention that /p: form doesn't work on all platforms.
The issue was created as result of discussion in dotnet/sdk#8232

Most helpful comment

Your explication makes perfect sense!
So, it is not dontnet cli issue and apparently not Cygwin - just /p: syntax has double meaning in context of Cygwin with msbuild.

Probably documentation should be updated to use -p: syntax instead of /p: to avoid confusions and because it works on all platforms.

At least Google will index this page and hopefully people will find it easily.

As a conclusion, alternative syntax, which works on all platforms, are:

-p:PackageVersion=1.0.0-dev
\"/p:PackageVersion=1.0.0-dev\"
-property:PackageVersion=1.0.0-dev
/property:PackageVersion=1.0.0-dev

All 5 comments

can you do a quick ls -l /p on the git bash?
I'm pretty sure there is an actual /p file or directory so msbuild will assume you mean that when passing /p as argument. this is expected behaviour for msbuild and also the main reason why CLI arguments are moved to use the dash (-*) form.

Hi,

No, there is no /p file. As I described in steps to reproduce I create a pretty new folder:

mkdir ~/my-demo-lib
cd ~/my-demo-lib
dotnet new classlib
dotnet pack /p:PackageVersion="1.0.0-dev"

You should be able to reproduce it if you copy-paste the commands above in git bash on windows.

So on a windows machine now, Cygwin (at least in git bash configuration) is trying to convert /p to P:\ (drive letter logic) but fails on /p: plus additional characters and will just pass the value without slash along.
The dotnet program only gets p:Foo=Bar without any slash and thus msbuild tries to parse it as a project file name (since no leading - or /).
if there are more characters between / and : it passes the entire value along.

Your best option at escaping is

dotnet pack \"/p:PackageVersion=1.0.0-dev\"

But other a lot of other arguments won't work as well.

Your explication makes perfect sense!
So, it is not dontnet cli issue and apparently not Cygwin - just /p: syntax has double meaning in context of Cygwin with msbuild.

Probably documentation should be updated to use -p: syntax instead of /p: to avoid confusions and because it works on all platforms.

At least Google will index this page and hopefully people will find it easily.

As a conclusion, alternative syntax, which works on all platforms, are:

-p:PackageVersion=1.0.0-dev
\"/p:PackageVersion=1.0.0-dev\"
-property:PackageVersion=1.0.0-dev
/property:PackageVersion=1.0.0-dev
Was this page helpful?
0 / 5 - 0 ratings