Deployment problem - error MSB4186: Invalid static method invocation syntax

Michael B 25 Reputation points
2024-04-11T14:05:02.25+00:00

I've got a .net core 8 app being deployed to a windows box and I'm getting the following errors no matter what I do after the pipeline completes successfully:

MSB4186: Invalid static method invocation syntax: "[MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.0')". Method '[MSBuild]::IsTargetFrameworkCompatible' 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.

Fought this for around 10 hour yesterday, ensuring the latest MSBuild was being used, latest sdk, latest version of nuget (also tried downgrading to a previous version of nuget as a test). I'd very much appreciate some ideas here.

The full results of the log:

Command: "C:\home\site\deployments\tools\deploy.cmd"

Handling ASP.NET Core Web Application deployment with MSBuild16.

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.

Build started 4/11/2024 4:40:29 AM.

Project "C:\home\site\repository*.*..csproj" on node 1 (Restore target(s)).

C:\home.nuget\microsoft.extensions.configuration.binder\8.0.1\buildTransitive\netstandard2.0\Microsoft.Extensions.Configuration.Binder.targets(20,17): error MSB4186: Invalid static method invocation syntax: "[MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.0')". Method '[MSBuild]::IsTargetFrameworkCompatible' 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:\home\site\repository*.*..csproj]

Done Building Project "C:\home\site\repository*.*..csproj" (Restore target(s)) -- FAILED.

Build FAILED.

"C:\home\site\repository*.*..csproj" (Restore target) (1) ->

(NETStandardCompatError_Microsoft_Extensions_Configuration_Binder target) ->

C:\home.nuget\microsoft.extensions.configuration.binder\8.0.1\buildTransitive\netstandard2.0\Microsoft.Extensions.Configuration.Binder.targets(20,17): error MSB4186: Invalid static method invocation syntax: "[MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.0')". Method '[MSBuild]::IsTargetFrameworkCompatible' 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:\home\site\repository*.*..csproj]

0 Warning(s)

1 Error(s)

Time Elapsed 00:00:05.95

Failed exitCode=1, command="C:\Program Files (x86)\MSBuild-16.4\MSBuild\Current\Bin\MSBuild.exe" /restore "C:\home\site\repository*.*..csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="C:\local\Temp\8dc59e180c31b6a"

An error has occurred during web site deployment.

\r\nC:\Program Files (x86)\SiteExtensions\Kudu\102.10305.001\bin\Scripts\starter.cmd "C:\home\site\deployments\tools\deploy.cmd"

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,384 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Robert John 0 Reputation points
    2024-04-17T18:24:35.12+00:00

    I am having the same issue. I was able to publish to Azure using VS2022 to publish directly to my deployment slot. However, this bypassed our normal CI/CD solution in Azure DevOps. So, this is a temporary process to get urgent updates to the user, but we will need our normal deployment fixed.

    0 comments No comments