dotnet / dotnet/msbuild

support unix/dotnet style switches

Open
#7,977 12 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

Probably there's existing discussion/ a dupe that I didn't find. https://github.com/dotnet/msbuild/issues/5714 seems somewhat related.

MSBuild switch syntax was not created with Unix ways in mind, and this has become more obvious in recent years on Unix, and also on Windows when using tools like dotnet.exe on Windows that prefer Unix conventions and aggregate MSBuild switches. For example. `build.cmd -ci -arch x64 -os windows -s clr.aot+libs -rc Release -lc Release /p:CrossBuild=false ` (an example of a command to build dotnet/runtime) and `dotnet build -c debug /t:test`

Ideally I could write `build.cmd -ci -arch x64 -os windows -s clr.aot+libs -rc Release -lc Release -p CrossBuild=false ` and `dotnet build -c debug -t test`

MSBuild already accepts `--XXX` for multi character switches and `-X` for single character ones. It also does not reject `--` but does not respect it either -- for example `nonexistent.csproj --` produces "Project file does not exist" even though I'd expect it to look like an invalid flag rather than a file. To be fully consistent it would need to (I think):

1. Allow "valued" switches to use space rather than colon
2. Ideally respect "--"

I'm wondering whether this could be possible without generally breaking existing scripts. If I have `dotnet build -c debug -t:test -p:configuration=debug my.csproj` and now write `dotnet build -c debug -t test -p configuration=debug my.csproj`, it should still be possible to unambiguously that the project was `my.csproj` and not `test`. However, optional-valued switches may be a problem. If `-m:4` becomes `-m 4`, is the 4 the project name or should it continue to implicitly build a project in the working directory?

Just curious whether there's been discussion about this, as the mixture of colon and space style is a bit ugly.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the related dotnet/msbuild#5714 discussion and the existing MSBuild switch handling; the issue names no files or tests. Reproduce the shown dotnet build and build.cmd command forms, then establish whether space-separated valued switches and -- can be supported without misidentifying project paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.