Skip to content

[Bug]: TaskItem normalises path to build platform, not target platform #10121

Open
@erikbra

Description

@erikbra

Issue Description

I've been working a bit on a bug in the dotnet/sdk#559, and stumbled upon something that might be considered a bug in either Microsoft.Build.Utilities.TaskItem, or Microsoft.Build.Shared.FileUtilities.FixFilePath. One might also argue that it's not a bug, and that it's the usage of it in Microsoft.NET.Build.Containers.Tasks.CreateNewImage that is wrong.

Anyway, the problem is, when publishing dotnet projects to containers, some properties are set on the CreateNewImage MSBuild task, that are needed runtime in the built container. So, the paths need to be compatible with the container target platform, not the platform it's built on. The properties in question are (at least) Entrypoint, EntrypointArgs, AppCommand, AppCommandArgs.

However, as the properties are of type ITaskItem, implemented by TaskItem, the paths are normalised when initialised. And, the normalisation uses the Path.DirectorySeparatorChar of the build platform, not the target.

Would you consider this a bug/shortcoming in the TaskItem, or are we/they using it in the wrong way in the MSBuild task?

Steps to Reproduce

Use a TaskItem in an MSBuild task, where you need the directory separator char of a different platform than the one you are building on (e.g. use C:\app\foo.exe when building on *nix)

Expected Behavior

The item should stay as C:\app\foo.exe

Actual Behavior

The path is changed to C:/app/foo.exe

Analysis

_itemSpec = FileUtilities.FixFilePath(itemSpec);

There is no way to tell either: 1) That you don't want normalisation of directory separator characters, or 2) which style of normalisation you want

Versions & Configurations

dotnet msbuild --version
17.11.0.25706

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: LanguageIssues impacting the MSBuild programming language.buggathering-feedbackThe issue requires feedback in order to be planned, please comment if the feature is useful for youtriagedxplat

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions