Skip to content

[Bug]: MSB4028 "XmlQuery" task's outputs could not be retrieved from the "Values" parameter. Specified cast is not valid. #8864

@jehhynes

Description

@jehhynes

Issue Description

After upgrading Visual Studio from 17.5.4 to 17.6.2, I am now encountering an error in our project's build. We are using MSBuildTasks and have the following target:

	<Target Name="SetConfig">
		<XmlQuery XmlFileName="$(ProjectDir)\test.xml" XPath="//add">
			<Output TaskParameter="Values" ItemName="ConfigSettings" />
		</XmlQuery>
	</Target>

When building/rebuilding the project, I get an error for this line stating the following:

MSB4028 The "XmlQuery" task's outputs could not be retrieved from the "Values" parameter. Specified cast is not valid.

I have included a zipped project with minimal code to reproduce the issue.
PLEASE NOTE: In the attached sample project, I was not always able to reproduce by using Build in Visual Studio, but using Rebuild did consistently generate this error.

XmlQueryError.zip

Steps to Reproduce

  • Unzip XmlQueryError.zip (attached)
  • Open the project in Visual Studio (I'm using version 17.6.2)
  • Rebuild the project (Please Rebuild rather than Build)
  • Note that the build fails.

Expected Behavior

An error should not occur.

Actual Behavior

The build fails. The Output window states: XmlQueryError\XmlQueryError.csproj(24,4): error MSB4028: The "XmlQuery" task's outputs could not be retrieved from the "Values" parameter. Specified cast is not valid.

Analysis

This same issue occurs on at least 3 separate solutions my company has.
I've reproduced it using the following versions of MSBuildTasks: 1.4.0.88, 1.5.0.235.
The error does not occur in VS 17.5.x but does occur in VS 17.6.x

See: https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Xml/XmlQuery.cs#L70
The Values property is any array ITaskItem[].

Versions & Configurations

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: EngineIssues impacting the core execution of targets and tasks.Priority:2Work that is important, but not critical for the releasebacklogbugregressiontriaged

    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