-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: MSB4028 "XmlQuery" task's outputs could not be retrieved from the "Values" parameter. Specified cast is not valid. #8864
Comments
I repro; likely related to #8645. The task in question references MSBuild 4.0 instead of 3.5 but that's still pretty stale. Unfortunately since it's 4.0 that means you lose the override-it-to-run-out-of-proc workaround for 3.5 tasks. |
Depending on the details of your |
Failing stack is
|
The MSBuildTasks NuGet package was last released in 2017. The project has been looking for a new maintainer since 2019. The tasks are built to .Net Framework v4.0. It appears that a .Net Framework application configuration file is being read with Looking at the source for
If you just need to cherry pick specific values, changing to Mapping the complete configuration file to an item collection might be implemented by using |
@jrdodds Thanks for the workaround suggestions. |
@rainersigwald Could the problem have been caused by this commit? 8ffc3fe Perhaps this should fallback to the prior behavior. Something like this:
|
@jehhynes I don't think that code is being hit with I think it is going down this path: https://github.com/dotnet/msbuild/blob/c6daff1259eb3c2a42d53f664f82c3c8a66c6166/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs#LL1374C1-L1381C30 |
It appears to me that the output is ITaskItem which may or may not be a TaskItem.
In the Execute() method of XmlQuery (https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Xml/XmlQuery.cs#L133), the case for XPathExpression.ReturnType of XPathResultType.NodeSet is adding values of type XmlNodeTaskItem which implements ITaskItem but does not inherit TaskItem (https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Xml/XmlNodeTaskItem.cs#L14).
Therefore I think it would actually be following this path: https://github.com/dotnet/msbuild/blob/c6daff1259eb3c2a42d53f664f82c3c8a66c6166/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs#LL1398C45-L1398C45
|
I had misread the class definition of |
I was very confused as to what was going on here. I asked internally and @stephentoub helped me understand: In the original code msbuild/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs Lines 1450 to 1453 in 698aac4
C# will, per its Inserting the LINQ changes things, because To play around with this, check out this minimized SharpLab repro. |
Team triage: we would like to write a test catching this issue. |
Backward-compatibility with KeyValuePair<string, string> metadata items [#8864]
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:
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
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
The text was updated successfully, but these errors were encountered: