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.69k stars 1.06k forks source link

Display appropriate error message when providing syntactically incorrect MSBUILD flags to dotnet pack #38645

Closed Matheos96 closed 3 months ago

Matheos96 commented 8 months ago

Is your feature request related to a problem? Please describe.

This had me baffled for a while. Basically I was trying to package a nuget package using dotnet pack by replicating what we do in our CI/CD pipeline. I did not copy the commands correctly, so when running the dotnet pack command I had a small syntactical error in providing the MsBuild PackageVersion property... See it?
image
I did not see anything wrong with this for quite some time. Obviously it should be -p:PackageVersion=8.0.0.0 with an equals sign, not a semi-colon. I noticed it when I actually copied the command straight off but I had the faulty one in my CLI history and could not figure out why it would be there if not working...

The dotnet pack output tells me close to nothing. I even tried running it with -v diag verbosity to see EVERYTHING but that still did not indicate anything what could have gone wrong...

image

Describe the solution you'd like

Please consider adopting some syntactical checking for these -p:PropertyName=Value flags. At the very least tell me that something went wrong, even if I would not know what. There is no error, no red text, nothing. Only through experience I knew I expected more of an output (and of course the .nupkg itself). The console output in no way indicates an error has occurred.

Additional context

I realise it may be a challenge to get a very friendly syntax related error message done, probably due to how the command is parsed? I would like to see something though, even just red text saying it failed. Imagine this being in a pipeline and you quickly go through everything trying to figure out why your package has not been published. There is no blatant error anywhere

dotnet-issue-labeler[bot] commented 8 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

Forgind commented 3 months ago

@Matheos96,

Thanks for filing this! I actually caught an almost identical bug a while ago. Can you clarify what version of the SDK/MSBuild you're using? I believe this should be 90% better after https://github.com/dotnet/msbuild/pull/9570, and for the remaining 10%, it's essentially the same as https://github.com/dotnet/sdk/issues/37230.

Closing in favor of #37230, but I'll make that one a little more broad. And if you're seeing this with a recent version of MSBuild, it might be good to let the MSBuild team know 🙂

Matheos96 commented 3 months ago

Can you clarify what version of the SDK/MSBuild you're using?

@Forgind Ok, great! As you can see from the screenshots, I used .NET 8.0.101 SDK.

I can't see from the PR, maybe just missing it, but what SDK version will include https://github.com/dotnet/msbuild/pull/9570?

Forgind commented 3 months ago

Can you clarify what version of the SDK/MSBuild you're using?

@Forgind Ok, great! As you can see from the screenshots, I used .NET 8.0.101 SDK.

🤦 I can be blind sometimes; you're totally right

I can't see from the PR, maybe just missing it, but what SDK version will include dotnet/msbuild#9570?

That looks like it was merged in January, so it most likely ended up in 17.10 MSBuild, which went into the 8.0.3xx SDK.