dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.6k stars 1.03k forks source link

`dotnet build` and friends mangle invalid property specifications #37230

Open rainersigwald opened 7 months ago

rainersigwald commented 7 months ago

Originally filed as dotnet/msbuild#9475 by @forgind. There is a bug in MSBuild but it's exacerbated by a CLI behavior.

Issue Description

Specifying /p:Property:value instead of /p:Property=value leads to an aborted build when using dotnet build.

Steps to Reproduce

> dotnet new console
> dotnet build <csproj name> /p:UseRidGraph:false

Expected Behavior

One line for the MSBuild version followed by a line specifying that the property is not valid (MSB1006) then telling me which exactly was wrong like: MSBuild version 17.9.0-dev-23579-01+5fcddc790 for .NET Framework MSBUILD : error MSB1006: Property is not valid. Switch: UseRidGraph:false

For switch syntax, type "MSBuild -help"

Actual Behavior

It just told me the version with no errors: MSBuild version 17.8.3+195e7f5a3 for .NET

Analysis

I tried this with MSBuild.exe (from main, not 17.8.3), and it worked as expected. I tried dotnet MSBuild.dll with the MSBuild freshly built from main, and it worked as expected. I tried using MSBuild.exe from my VS preview (version 17.9.0-preview-23574-01+7b37a280a), and this bug still didn't reproduce. Then I built MSBuild main and used the deploy script to overwrite my 8.0.100 SDK, and this bug finally reproduced.

That means this may be Core-specific (a CLI bug?) or it may be specific to some component that MSBuild does not overwrite with the deploy script. Of note, it does still print out the version, which (I think) means MSBuild knows it's supposed to be executing and tries to execute but ultimately fails without logging anything further.

Versions & Configurations

8.0.100 SDK with MSBuild version above.

rainersigwald commented 7 months ago

Something in CLI argument parsing is seeing

/p:UseRidGraph:false

and substituting in

--property:UseRidGraph:false=

which exposes the user to https://github.com/dotnet/msbuild/issues/9475.

baronfel commented 7 months ago

It's probably a bug in our version of the property parser here.

ShreyasJejurkar commented 6 months ago

I just tried the repo steps in the original issue, but I did not get any error. image

Forgind commented 2 weeks ago

@ShreyasJejurkar, that's successfully reproducing the error. You should have seen error text because /p:UseRidGraph:false is incorrect syntax, but you didn't. That's the bug.

Forgind commented 2 weeks ago

Making this a bit more broad because of https://github.com/dotnet/sdk/issues/38645, which likely is the same issue but for dotnet pack.