Skip to content

[Bug]: Wrong parameters in XslTransformation MSB3094 error when XmlContent does not match OutputPaths  #8642

Closed
@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

Issue Description

When the XslTransformation task is called such that the XmlContent parameter is specified and OutputPaths does not have exactly one item, it fails with an MSB3094 error that shows the wrong number of items in each parameter.

Steps to Reproduce

Build this project:

<Project>
  <Target Name="Main">
    <XslTransformation XmlContent="&lt;dummy/&gt;" XslInputPath="dummy.xslt" OutputPaths="out1;out2" />
  </Target>
</Project>

(The dummy.xslt file need not exist.)

Expected Behavior

error MSB3094: "XmlContent" refers to 1 item(s), and "OutputPaths" refers to 2 item(s). They must have the same number of items.

or

error MSB3094: "XmlContent" is specified, and "OutputPaths" refers to 2 item(s). It must have exactly one item.

Actual Behavior

error MSB3094: "XmlContent" refers to 2 item(s), and "OutputPaths" refers to 1 item(s). They must have the same number of items.

Analysis

// Check if OutputPath has 1 parameter if xmlString is specified.
if (XmlContent != null && _outputPaths.Length != 1)
{
Log.LogErrorWithCodeFromResources("General.TwoVectorsMustHaveSameLength", _outputPaths.Length, 1, "XmlContent", "OutputPaths");
return false;
}

The bug has been there ever since the first public commit.

Versions & Configurations

MSBuild 17.6.0-preview-23108-10+51df47643 from .NET SDK 8.0.100-preview.1.23115.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: LoggingArea: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.bugtriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions