Skip to content

[MSBuild]::MakeRelative fails with Unix paths #429

@rainersigwald

Description

@rainersigwald

This simple project:

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Build">
        <Warning Text="$([MSBuild]::MakeRelative('/bar/baz', '/foo'))" />
    </Target>
</Project>

Fails (on Linux/CoreCLR) with this error:

test.proj(3,12): error MSB4184: The expression "[MSBuild]::MakeRelative(/bar/baz, /foo)" cannot be evaluated. Invalid URI: The format of the URI could not be determined.

If the path is a valid Windows/DOS path, this error isn't thrown:

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Build">
        <Warning Text="$([MSBuild]::MakeRelative('c:\bar\baz', '/foo'))" />
    </Target>
</Project>
test.proj(3,3): warning : ../../foo

Thanks to @joperezr for the report.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions