question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetBuildVersion task fails with `System.MissingMethodException` when building with Mono MSBuild on macOS

See original GitHub issue

Version information

Component Version
Nerdbank.GitVersioning 2.3.125
Mono.Framework 5.16.0
Visual Studio for Mac 7.8.2 (build 1)
MSBuild 16.0.40-preview+ge6c3a1f9e4
.NET Core SDK 2.2.104
macOS 10.14.3 (Mojave)

Repro Steps

  1. Create a new .NET Standard class library in Visual Studio for Mac
  2. Add the Nerdbank.GitVersioning NuGet package
  3. Create a simple version.json file (see below)
  4. Build > Build All (or msbuild /t:restore && msbuild from a Terminal outside VSMac)

(Note: I also tried installing the nbgv tool and doing nbgv install… the same error/behaviour surfaces. I don’t think this is a solution/project configuration issue.)

Expected behaviour The build is successful 😄

Actual behaviour Build error 😢

System.MissingMethodException: Method not found: void Newtonsoft.Json.Converters.StringEnumConverter.set_NamingStrategy

Curiously, when using the .NET Core CLI toolchain then the build succeeds (dotnet build rather than msbuild, the latter being what VSMac uses).

Build output

/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.MissingMethodException: Method not found: void Newtonsoft.Json.Converters.StringEnumConverter.set_NamingStrategy(Newtonsoft.Json.Serialization.NamingStrategy)
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Nerdbank.GitVersioning.VersionFile.TryReadVersionJsonContent (System.String jsonContent) [0x00000] in <60a3cf7da8fe4c9d80305de7a36e73b4>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Nerdbank.GitVersioning.VersionFile.GetVersion (LibGit2Sharp.Commit commit, System.String repoRelativeProjectDirectory) [0x000eb] in <60a3cf7da8fe4c9d80305de7a36e73b4>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Nerdbank.GitVersioning.VersionOracle..ctor (System.String projectDirectory, LibGit2Sharp.Repository repo, LibGit2Sharp.Commit head, Nerdbank.GitVersioning.ICloudBuild cloudBuild, System.Nullable`1[T] overrideBuildNumberOffset, System.String projectPathRelativeToGitRepoRoot) [0x000a8] in <60a3cf7da8fe4c9d80305de7a36e73b4>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Nerdbank.GitVersioning.VersionOracle.Create (System.String projectDirectory, System.String gitRepoDirectory, Nerdbank.GitVersioning.ICloudBuild cloudBuild, System.Nullable`1[T] overrideBuildNumberOffset, System.String projectPathRelativeToGitRepoRoot) [0x0001f] in <60a3cf7da8fe4c9d80305de7a36e73b4>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner () [0x000c5] in <b9250c5c0ff64d0facfbd2c9542bc589>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at MSBuildExtensionTask.ContextAwareTask.Execute () [0x0005e] in <b9250c5c0ff64d0facfbd2c9542bc589>:0 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573 
/Users/<user>/.nuget/packages/nerdbank.gitversioning/2.3.125/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784 
    0 Warning(s)
    1 Error(s)

version.json

{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "1.0-beta",
  "publicReleaseRefSpec": [
    "^refs/heads/master$"
  ]
}

Project file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Nerdbank.GitVersioning">
      <Version>2.3.125</Version>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>

Solution file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "netstandardlib", "netstandardlib\netstandardlib.csproj", "{B1FA5F49-E24B-4D73-9FA5-E961A67811CB}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{B1FA5F49-E24B-4D73-9FA5-E961A67811CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{B1FA5F49-E24B-4D73-9FA5-E961A67811CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{B1FA5F49-E24B-4D73-9FA5-E961A67811CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{B1FA5F49-E24B-4D73-9FA5-E961A67811CB}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
EndGlobal

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mjcheethamcommented, Mar 8, 2019

If you use package version 2.3.38 then the issue does not reproduce, meaning that it is something that has changed since then to 2.3.125.

1reaction
AArnottcommented, Jun 19, 2019

Great. I’ll merge and push to nuget.org then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Exception: Did not find MSBuild for runtime Mono
1 Answer 1 ... Mono 4.0.2 did not have msbuild , it was included in 4.8.0+ . Check where does /Library/Frameworks/Mono.framework/Versions/Current ...
Read more >
Incompatible versions of Mono MSBuild and .NET Core ...
NET Core SDK are incompatible on Linux and macOS. If you use such combinations, it will be impossible to build your project in...
Read more >
Error: Unknown MSBuild failure. Please try building the ...
Exception: MSBuild operation failed ---> System.MissingMethodException: Method 'Microsoft.Build.Construction.ProjectRootElement.
Read more >
Customize the MSBuild system in Visual Studio for Mac
This article is a brief introduction to the MSBuild build system used by Visual Studio for Mac.
Read more >
Godot Mono cannot build my project on MacOS
I installed all the possible build tools and sdks for C# and i keep getting MSBuild error: EditorPlugin callback failed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found