-
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
[Feature Request]: Make error message more helpful when TaskItem.ItemSpec
is not set
#10660
Comments
I think this could be solvable by introducing a more specific error message here - right now we have a generic 'could not bind property' message, but for something as important as the Identity/ItemSpec it makes sense to have a more directed message. |
@MangelMaxime can you confirm that you called We should document that that is not ever intended to be called in normal code, it's just there as a trap :( |
This is indeed what I am doing: this.CurrentRelease <- TaskItem()
this.CurrentRelease.ItemSpec <- version.Version.ToString()
this.CurrentRelease.SetMetadata("Version", version.Version.ToString()) Based on your message, I suppose |
Yeah that's completely fair! I'd recommend using . . . now we should make the docs say the same. And maybe even hide that "so this type is COM-createable" ctor from IntelliSense or something so it's less tempting? |
The doc comment mentioned that the parameterless constructor existed only for COM but it was still easy to find, causing problems like dotnet#10660. Hide it from IDE completion and extend the comment.
The doc comment mentioned that the parameterless constructor existed only for COM but it was still easy to find, causing problems like #10660. Hide it from IDE completion and extend the comment.
Summary
Hello,
Improve error message if
ItemSpec
is missing on aTaskItem
Background and Motivation
When creating a custom MSBuild task, it took me several hours to figure out why I was getting this error:
The reason was that I didn't set the
TaskItem.ItemSpec
value.Proposed Feature
Improve the error message to mention that ItemSpec should be set.
Alternative Designs
Another solution would be to change the constructor of
TaskItem
to take a mandatoryItemSpec
value, but I suspect it would be too big of a breaking change.The text was updated successfully, but these errors were encountered: