MarshalDirectiveException on unices with 2.2.3
See original GitHub issueWhen 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:
- Created 5 years ago
- Comments:24 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Anyway, thanks for the suggestion, @bording. It looks like I’ll be able to publish this workaround very soon.
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).