Skip to content

Misleading error message when passing wrong argument to static method. #4619

Open
@maxbouchez

Description

@maxbouchez

Steps to reproduce

<!-- MultiplyValue either not defined or not a number -->
<!--<MultiplyValue></MultiplyValue>-->
<MultiplyResult>$([MSBuild]::Multiply(10000000, $(MultiplyValue)))</MultiplyResult>

Basically, using a static MSBuild method passing it an invalid argument.
In my case it was just not being defined because it was defined by another props file that wasn't included correctly.

Expected behavior

A new error message telling the user the issue is caused by the wrong argument being passed to the method instead of the generic error message telling me that the static method was not found.
I looked at the error message online and could only fine people talking about how MSBuild or Visual Studio needed to be repaired, uninstalled and reinstalled because for some reason it couldn't find the definition for the static method I was trying to call.

Actual behavior

Error message:

Invalid static method invocation syntax:
'[MSBuild]::Multiply(10000000, $(MultiplyValue))', Method '[MSBuild]::Multiply' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).

The ** Method X not found** piece is the confusing one because it makes it sound like MSBuild doesn't have a multiply method.
Everywhere I looked people said that usually happens when MSBuild is out of date or not installed correctly.

OS info:

Visual Studio Enterprise 2017 - Version 15.9.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: LanguageIssues impacting the MSBuild programming language.needs-designRequires discussion with the dev team before attempting a fix.triaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions