Ideas needed: Concise syntax for [System.IO.Path]::Combine()
See original GitHub issueCombining 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
Path1has 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!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Path.Combine Method (System.IO)
This method is intended to concatenate individual strings into a single string that represents a file path. However, if an argument other than...
Read more >How do I use Join-Path to combine more than two strings ...
You can use the .NET Path class: [IO.Path]::Combine('C:\', 'Foo', 'Bar').
Read more >System.IO.Path.Combine to merge File Path
Combine (sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, fileName); // To copy a folder's contents to a new location:
Read more >C# Tutorial - C# Path Combine(String, String)
Path Combine (String, String) Combines two strings into a path. Syntax. Path.Combine(String, String) has the following syntax. public static string Combine ...
Read more >Apache Beam Programming Guide
Apache Beam is an open source, unified model and set of language-specific SDKs for defining and executing data processing workflows, and also data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Is there any resolution for “extension methods” for properties? If so, one could make a method similar to how string instance methods can be used:
To make things more concise, is there a way you could you drop the
$([MSBuild]::).part and if there is no prefix/class imply[MSBuild]?Say:
$(::NormalizeDirectory($(Path1), $(Path2))