A number of the nuget packages in a solution I have are out of date, so I went through them one by one and updated them to the latest version or nearest.
After building and testing the solution I attempted to check it in. The build server returned an error.
I undid every change that I had made and got the latest version from source control this is the last version that successfully built on the build server.
I added a space character to a file and tried a test check-in. This failed for the exact same reason!
I even tried opening up the project in an old version of Visual Studio, and it would not check in from that either.
Thinking it may be an issue on the build server I tried the same test in a different project. This checked-in without issue.
Here is an example of the line in the build server process where it's failing...
C:\Windows\ServiceProfiles\NetworkService\.nuget\packages\microsoft.extensions.apidescription.server\6.0.5\build\Microsoft.Extensions.ApiDescription.Server.targets(5,38):
error MSB4186: Invalid static method invocation syntax:"[MSBuild]::VersionLessThanOrEquals('$(TargetFrameworkVersion)', '2.0')".
Method '[MSBuild]::VersionLessThanOrEquals' not found.
Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
Check that all parameters are defined, are of the correct type, and are specified in the right order.
[C:\vstsagent\vsts-agent-win-x86-2.142.1\_work\11\s\project\project.csproj]
I've seen some similar issues on Stack Overflow and none are quite the same, plus I don't really understand what the error is trying to tell me.
I don't understand why the check-in is failing when the only difference between the latest version and the version I am trying to check in is a space character.
How can I fix this?
Edit to add: I found a question that seemed to match my issue, but like the last poster I don't know where to do this... https://learn.microsoft.com/en-us/answers/questions/1353483/invalid-static-method-invocation-syntax-(msbuild) Downgrading nuget seems like an odd option given that it hasn't been upgraded previously, at least on the server.
New Edit:
I think it may be related to a package because of this entry...
error MSB4186:
Invalid static method invocation syntax: "[MSBuild]
::VersionLessThanOrEquals('$(TargetFrameworkVersion)', '2.0')".
Method '[MSBuild]::VersionLessThanOrEquals' not found.
Static method invocation should be of the form:
$([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
Check that all parameters are defined, are of the correct type, and
are specified in the right order.
[C:\vstsagent\vsts-agent-win-x86-2.142.1\_work\11\s\API\API.csproj]
I'm really not sure how to go about debugging this.
Well after a couple of days investigating this I seem to have fixed it.
As part of my testing I created a brand new pipeline, copied exactly from the original with the intent of tinkering with some settings without altering the original.
When I ran this project through the new pipeline it worked perfectly.
I've double-checked all the settings and both pipelines are identical except one has a new suffix in its name.
If anyone sees this and can comment as to why this worked I would be most interested!