Skip to content

Crossplat MSBuild and path representation #1024

Closed
@cdmihai

Description

@cdmihai

This is a part of #781 but focused on path separators and how path values flow through msbuild.

Path values get introduced in MSBuild's data flow from:

  • user input (command line properties, properties, items, metadata, task arguments, imports, using tasks, conditions)
  • glob expansions (discussed in Crossplat MSBuild and glob expansion #1026 )
  • task outputs
  • well known item metadata pertaining to paths (FullPath, RootDir, etc)

Paths values are consumed in:

  • Conditions (path comparisons, etc)
  • Tasks
  • Exec task

Path consumers can access paths via:

  • direct property / item reference (@(Compile), $(MyFile))
  • item file metadata (FullPath, Identity, etc)

Observations:

  • There is no distinction between strings and paths
  • Path value consumers can interpret the values either as plain strings (and MSBuild should not massage the value thinking it's a path), or as actual paths and thus do IO operations on them (when MSBuild is OK to normalize paths, etc)

Problems:

  • crossplatform MSBuild may break if path producers do not agree with path consumers. For example if producers and consumers use different slashes, trailing slashes, absolute vs relative paths, etc

Potential solutions:

  • msbuild could normalize all or some path producers in regards to separators to:
    • only use forward or backward slashes
    • use the file system specific path separator

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-designRequires discussion with the dev team before attempting a fix.triaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions