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.

MarshalDirectiveException on unices with 2.2.3

See original GitHub issue

When I tried updating from 2.1.23 to 2.2.3 locally, I started seeing this failure repeated many times.

This does not reproduce on the same machine with a tiny repro project, only in the MSBuild repo in our projects. I’ve reproduced on Ubuntu 18.04 (with SDK 2.1.300 and 2.1.401) and macOS 10.13 (just SDK 2.1.300), but it seems to work fine on .NET Core on Windows.

At the moment I suspect a CoreCLR bug rather than a problem with GitVersioning or LibGit2Sharp, but I wanted to file this for awareness in case it’s more widespread.

10:41:29.576  1:19>Target "GetBuildVersion: (TargetId:201)" in file "/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets" from project "/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj" (target "GenerateAssemblyVersionInfo" depends on it):
                   Using "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task from assembly "/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/MSBuildCore/Nerdbank.GitVersioning.Tasks.dll".
                   Task "Nerdbank.GitVersioning.Tasks.GetBuildVersion" (TaskId:117)
                     Task Parameter:TargetsPath=/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/ (TaskId:117)
10:41:29.604  1:19>/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath. [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.git_repository_open(String path) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
/home/raines/.nuget/packages/nerdbank.gitversioning/2.2.3/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/home/raines/src/msbuild/src/Framework/Microsoft.Build.Framework.csproj]
                   Done executing task "Nerdbank.GitVersioning.Tasks.GetBuildVersion" -- FAILED. (TaskId:117)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:24 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AArnottcommented, Aug 25, 2018

Anyway, thanks for the suggestion, @bording. It looks like I’ll be able to publish this workaround very soon.

1reaction
rainersigwaldcommented, Aug 24, 2018

I’ve got more info and will look again tomorrow but it looks like the FilePath type there is being loaded twice from the same file (but different clr assembly pointers).

Read more comments on GitHub >

github_iconTop Results From Across the Web

C Dll Import throws Marshall Directive Exception in C# - ...
MarshallDirectiveException Cannot marshal 'return value': Invalid managed/unmanaged type combination (Int32/UInt32 must be paired with I4 or ...
Read more >
MarshalDirectiveException Class (System.Runtime. ...
The exception that is thrown by the marshaler when it encounters a MarshalAsAttribute it does not support.
Read more >
MarshalDirectiveException Class (System.Runtime. ...
Initializes a new instance of the MarshalDirectiveException class with a specified error message and a reference to the inner exception that is the...
Read more >
Guidance on Mental Health, Human Rights, and Legislation
Exceptions to the enjoyment of any rights based on mental health conditions or psychosocial disability constitute discrimination and should be ...
Read more >
Serious Harm
2.2.3 The creation of unwieldy exceptions ... Directive includes “physical or mental harm” in “acts of persecution”: Council Directive 2011/95/EU.
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