dotnet / dotnet/msbuild

Ideas needed: Concise syntax for [System.IO.Path]::Combine()

Open
#1,750 16 comments 8 reactions 0 assignees View on GitHub
needs-design
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

Combining paths is a common operation in a build system. Now that MSBuild is cross-platform, it's even more fraught with danger due to the vagaries of slash directions.

Most MSBuild projects just use `$(Path1)\$(Path2)`. This works and is concise but has some downsides:
* Has an explicit slash direction
* Can result in doubled slashes (if `Path1` has a trailing slash)
* Isn't obviously a path-combining expression--it's indistinguishable from string concatenation (because that's what it is).

The most-obviously-correct approach is `$([System.IO.Path]::Combine('$(Path1)', '$(Path2)'))`. That doesn't have any of those downsides, but is verbose and hard to read (and type).

It would be great if we could have a concise syntax that called the cross-platform supported system API, but wasn't unreadable. Ideas welcome!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.