question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
grajdeansergheicommented, Sep 18, 2018

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
1reaction
dasMullicommented, Sep 18, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git-Bash Command Prompt won't open up after upgrading ...
I tried by reinstalling the git bash but re installation not works for me.it is due to the permission issue with the shell...
Read more >
Getting Started with Git Bash Commands on Windows
In this tutorial, you'll learn about Git Bash commands, install Git Bash on Windows, and run some basic Git Bash commands in a...
Read more >
Getting Python Shell To Work on Git Bash
This short post is for you. Getting Python IDLE to work on Git Bash might be a problem. Typing python into CMD or...
Read more >
Getting Started with Git Bash | Tower Blog
A guide on how to install Git Bash and get up and running with Git!
Read more >
What is Git Bash | Download a Terminal for Windows
Git bash is an application that provides a terminal for Windows. ... Git bash download and perform commands like how to open a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found