Skip to content

StrictFilePathMarshaler must be used on a FilePath #720

Closed

Description

@michaelnoonan

One of our developers was consistently getting this error when building in Visual Studio 2015: Could not determine assembly version: StrictFilePathMarshaler must be used on a FilePath

I can see some references to this in libgit2sharp, and one in #652.

The only remedy we could find under pressure was to re-clone the repository.

Unfortunately we needed to keep moving and don't have the repository to reproduce it any more. Hopefully if anyone else gets this error message we can narrow down the root cause.

Activity

  1. JakeGinnivan commented on Jan 17, 2016

    @JakeGinnivan
    Contributor

    Gathering this is on the GitVersionTask only? I wonder if it is another bug/error which is being triggered which stops the task from generating the version number and then causes this. Hopefully the underlying bug will get found via the exe and fixed then this goes away.

    I might close this issue for now, if anyone hits this then post and we can reopen to investigate.

  2. andrejohansson commented on Jan 19, 2016

    @andrejohansson

    I have this error now on a cleanly installed Windows 10 machine with latest stable git and Visual Studio 2015 enterprise.

    Suggestions how I can narrow it down?

  3. asbjornu commented on Jan 20, 2016

    @asbjornu
    Member

    @andrejohansson It would be nice to know if you use GitVersionTask or gitversion.exe. If you use the former, output from MSBuild would be nice. Run msbuild.exe from the command line if you don't get any valuable build output in Visual Studio. If you use the latter, it should give you build output directly that will be valuable. Any build output you can get your hands on, post it here in a comment.

  4. andrejohansson commented on Jan 21, 2016

    @andrejohansson

    I'm using the gitversiontask, this is from my csproj file:

      <Error Condition="!Exists('..\packages\GitVersionTask.3.1.2\Build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersionTask.3.1.2\Build\portable-net+sl+win+wpa+wp\GitVersionTask.targets'))" />
      </Target>
      <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
      <Import Project="..\packages\GitVersionTask.3.1.2\Build\portable-net+sl+win+wpa+wp\GitVersionTask.targets" Condition="Exists('..\packages\GitVersionTask.3.1.2\Build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
    

    Here is the build output from within visual studio;

    2>  Restoring NuGet packages...
    2>  To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
    2>  All packages listed in packages.config are already installed.
    2>MSBUILD : warning : WARN [01/21/16 21:07:32:03] Could not determine assembly version: StrictFilePathMarshaler must be used on a FilePath.
    2>MSBUILD : warning : WARN [01/21/16 21:07:32:04] Could not determine assembly version: StrictFilePathMarshaler must be used on a FilePath.
    2>MSBUILD : warning : WARN [01/21/16 21:07:32:04] Could not determine assembly version: StrictFilePathMarshaler must be used on a FilePath.
    2>  BokaMera.API.IntegrationTests -> C:\Dev\github-private\bokamera\api\BokaMera.API.IntegrationTests\bin\Debug\BokaMera.API.IntegrationTests.dll
    
  5. asbjornu commented on Jan 22, 2016

    @asbjornu
    Member

    @andrejohansson Could you please do msbuild <solution.sln> on the command line so we get the full build output? The lines written by GitVersionTask are the ones I'd like to see. Use the "Developer Command Prompt for VS2015" or similar for older versions of Visual Studio to have MSBuild added to your PATH.

  6. asbjornu commented on Jan 31, 2016

    @asbjornu
    Member
  7. michaelnoonan commented on Feb 5, 2016

    @michaelnoonan
    ContributorAuthor

    Hi everyone. I've just had this reoccur, and I realised that repo was still using GitVersionTask.3.1.0 which was lossy - it would just write ex.Message instead of the full exception with stack trace.

    Unfortunately upon upgrading to use GitVersionTask.3.4.1 the problem isn't happening any more. I say unfortunately because I was looking forward to getting to the bottom of this issue, but I can't tell for sure, because my git repository has changed state due to upgrading GitVersionTask.

    Next time this happens (if ever) I'll be sure to post more details.

  8. michaelnoonan commented on Feb 9, 2016

    @michaelnoonan
    ContributorAuthor

    Happy, but sad - it's failed again today! This is now running GitVersionTask.3.4.1.

    Interestingly, running a build from the command-line works perfectly, no warnings/errors: msbuild .\source\OctopusDeploy\OctopusDeploy.sln

    WriteVersionInfoToBuildLog:
      INFO [02/10/16 8:49:30:61] Project root is: c:\dev\OctopusDeploy
      INFO [02/10/16 8:49:30:64] Begin: Loading version variables from disk cache
        INFO [02/10/16 8:49:30:65] Begin: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml
        INFO [02/10/16 8:49:30:70] End: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml (Took: 44.12ms)
      INFO [02/10/16 8:49:30:70] End: Loading version variables from disk cache (Took: 55.00ms)
    UpdateAssemblyInfo:
      INFO [02/10/16 8:49:30:70] Project root is: c:\dev\OctopusDeploy
      INFO [02/10/16 8:49:30:71] Begin: Loading version variables from disk cache
        INFO [02/10/16 8:49:30:71] Begin: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml
        INFO [02/10/16 8:49:30:71] End: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml (Took: 1.07ms)
      INFO [02/10/16 8:49:30:71] End: Loading version variables from disk cache (Took: 4.00ms)
    GetVersion:
      INFO [02/10/16 8:49:30:72] Project root is: c:\dev\OctopusDeploy
      INFO [02/10/16 8:49:30:72] Begin: Loading version variables from disk cache
        INFO [02/10/16 8:49:30:72] Begin: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml
        INFO [02/10/16 8:49:30:74] End: Deserializing version variables from cache file c:\dev\OctopusDeploy\.git\gitversion_cache\1867B8AF8EDD13B4A7A7E7ED6E105D8EA5CDC98B.yml (Took: 12.01ms)
      INFO [02/10/16 8:49:30:74] End: Loading version variables from disk cache (Took: 13.01ms)
    

    But when running a Rebuild inside of Visual Studio we get this warning:

    3>Target "WriteVersionInfoToBuildLog" in file "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets" from project "C:\dev\OctopusDeploy\source\Octopus.Upgrader\Octopus.Upgrader.csproj" (target "CoreCompile" depends on it):
    3>Using "WriteVersionInfoToBuildLog" task from assembly "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\..\..\GitVersionTask.dll".
    3>Task "WriteVersionInfoToBuildLog"
    3>MSBUILD : warning : WARN [02/10/16 8:43:24:13] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath.
    3>MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj)
    3>MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.<>c__DisplayClass34.<git_repository_discover>b__33(GitBuf buf)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.git_repository_discover(FilePath start_path)
    3>MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath)
    3>MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory()
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication)
    3>Done executing task "WriteVersionInfoToBuildLog".
    3>Done building target "WriteVersionInfoToBuildLog" in project "Octopus.Upgrader.csproj".
    3>Target "UpdateAssemblyInfo" in file "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets" from project "C:\dev\OctopusDeploy\source\Octopus.Upgrader\Octopus.Upgrader.csproj" (target "CoreCompile" depends on it):
    3>Using "UpdateAssemblyInfo" task from assembly "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\..\..\GitVersionTask.dll".
    3>Task "UpdateAssemblyInfo"
    3>MSBUILD : warning : WARN [02/10/16 8:43:24:13] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath.
    3>MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj)
    3>MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.<>c__DisplayClass34.<git_repository_discover>b__33(GitBuf buf)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.git_repository_discover(FilePath start_path)
    3>MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath)
    3>MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory()
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication)
    3>Done executing task "UpdateAssemblyInfo".
    3>Done building target "UpdateAssemblyInfo" in project "Octopus.Upgrader.csproj".
    3>Target "GetVersion" in file "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets" from project "C:\dev\OctopusDeploy\source\Octopus.Upgrader\Octopus.Upgrader.csproj" (target "CoreCompile" depends on it):
    3>Using "GetVersion" task from assembly "C:\dev\OctopusDeploy\source\packages\GitVersionTask.3.4.1\build\dotnet\..\..\GitVersionTask.dll".
    3>Task "GetVersion"
    3>MSBUILD : warning : WARN [02/10/16 8:43:24:14] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath.
    3>MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj)
    3>MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.<>c__DisplayClass34.<git_repository_discover>b__33(GitBuf buf)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
    3>MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.git_repository_discover(FilePath start_path)
    3>MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath)
    3>MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory()
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
    3>MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication)
    3>Done executing task "GetVersion".
    3>Done building target "GetVersion" in project "Octopus.Upgrader.csproj".
    3>Target "CoreCompile" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets" from project "C:\dev\OctopusDeploy\source\Octopus.Upgrader\Octopus.Upgrader.csproj" (target "Compile" depends on it):
    3>Building target "CoreCompile" completely.
    3>Output file "obj\Debug\Octopus.Upgrader.exe" does not exist.
    3>Using "Csc" task from assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.CodeAnalysis.dll".
    3>Task "Csc"
    3>  C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceProcess.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Octopus.Upgrader.exe /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:exe /utf8output "..\Solution Items\SolutionInfo.cs" "..\Solution Items\VersionInfo.cs" SoftwareInstaller.cs Log.cs Program.cs Properties\AssemblyInfo.cs ServiceBouncer.cs "C:\Users\Michael\AppData\Local\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs" obj\Debug\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Debug\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Debug\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
    3>  Microsoft (R) Visual C# Compiler version 1.1.0.51204
    3>  Copyright (C) Microsoft Corporation. All rights reserved.
    3>Done executing task "Csc".
    

    I don't have much time to investigate further right now, but let me know if there's anything else I can do to help!

    Mike

  9. asbjornu commented on Feb 12, 2016

    @asbjornu
    Member

    @nulltoken Do you have any idea what might be causing this?

  10. nulltoken commented on Feb 12, 2016

    @nulltoken
    Contributor

    That reminds me of two ancient issues.

    How can one ensure GitVersionTask is actually leveraging the LibGit2Sharp version it's bundled with?

    /cc @ethomson @carlosmn @jamill @SimonCropp

  11. asbjornu commented on Jun 2, 2016

    @asbjornu
    Member

    @michaelnoonan Is this still a problem, or has it vanished in later versions of GitVersion?

  12. michaelnoonan commented on Jun 5, 2016

    @michaelnoonan
    ContributorAuthor

    We have had sporadic recurrences of this problem, but I'm hearing less than
    previously. I will update our develop branch to the latest GitVersion and
    will report back if it recurs again.

    On Thu, Jun 2, 2016 at 5:49 PM, Asbjørn Ulsberg [email protected]
    wrote:

    @michaelnoonan https://github.com/michaelnoonan Is this still a
    problem, or has it vanished in later versions of GitVersion?

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    #720 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe/ABjVvm_hfcduxmr2GjWGV36B61UjzPkNks5qHosAgaJpZM4GoGGf
    .

  13. asbjornu commented on Jun 15, 2016

    @asbjornu
    Member

    Seems like people are still having a problem with this, since #899 was reported just now. @nulltoken, what do you mean with:

    How can one ensure GitVersionTask is actually leveraging the LibGit2Sharp version it's bundled with?

    I guess that question is targeted at the CC-ed people @ethomson, @carlosmn, @jamill, and @SimonCropp, but it would be great to figure this one out as it doesn't seem to have vanished even though @michaelnoonan haven't seen it in a while.

  14. 8 remaining items

  15. droyad commented on Aug 26, 2016

    @droyad

    I just ran into this due to mixing 3.6.1 and 3.6.2 in the same solution.

  16. mkoertgen commented on Aug 26, 2016

    @mkoertgen
    Contributor

    Sorry, for being late. I'm back now and try to get to this today.

  17. gabri705 commented on Sep 20, 2016

    @gabri705

    Hey everyone I have this problem:

    The "GitVersion" task was not found. Check the following:
    1.) The name of the task in the project file is the same as the name of the task class.
    2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface.
    3.) The task is correctly declared with in the project file, or in the *.tasks files located in the
    "C:\Program Files (x86)\MSBuild\14.0\bin" directory.
    Barcoding.Jdl.Android
    C:\Users\engineering\Documents\Visual Studio 2015\Projects\SiteOne\Barcoding.Jdl.Android\Barcoding.Jdl.Android.csproj

  18. mkoertgen commented on Sep 23, 2016

    @mkoertgen
    Contributor

    I believe that @gabri705 issue is not related to this.

    Anyway, libgitsharp released a new prerelease which i'm gonna testing today

  19. mkoertgen commented on Oct 2, 2016

    @mkoertgen
    Contributor

    After updating 2 tests were breaking which seemed to be related to proxy settings. In a proxy-less environment, they run fine. The PR build failed because master evolved meanwhile and a merge was needed. Just did that and PR #1024 should now be ready to be merged in. Sorry, for the long delay.

  20. mkoertgen commented on Oct 11, 2016

    @mkoertgen
    Contributor

    The Travis CI build still fails at 1 test, i.e.

    I am not sure how i can contribute in stabilizing the build to get this issue fixed. Any suggestions @JakeGinnivan ?

  21. roryprimrose commented on Oct 12, 2016

    @roryprimrose

    This hits me when I have two different versions of GitVersionTask in the solution packages folder. Closing VS2015 then wiping out both GitVersionTask packages (plus any other packages that have duplicates), open and rebuild. This ensures that the packages folder now only contains the versions that should be there after nuget has restored the current references. Problem solved.

  22. forestb commented on Nov 1, 2016

    @forestb

    I stumbled across this thread while searching for some insight to this problem. I believe the problem may be as @roryprimrose indicated. I have a solution where several projects were referencing 3.6.2 and several were referencing 3.6.4. However restarting Visual Studio (2015, in this case) did not help, and it seemed to affect completely unrelated solutions/different repositories.

    Looking for the culprit, I noticed MSBuild.exe and MSBuildTaskHost.exe were still running under my Windows processes, despite closing Visual Studio and no longer building anymore. I force-killed those processes, ensured all my GitVersionTask library versions matched in the solution, and no longer experience the problem.

    As long as any projects had mismatched versions (at least the two versions specified above), I was able to consistently reproduce the problem.

  23. asbjornu commented on Nov 1, 2016

    @asbjornu
    Member

    @forestb, @roryprimrose: If what your experiences are infact the solution to this problem, that would be awesome. Ideas on how we can automate a check for different versions of GitVersion in the same solution?

    @mkoertgen: I think I have identified the problem with the test in GitTools/GitTools.Core#38. As soon as that's merged, released and upgraded in GitVersion, I hope we can get rid of this and the problem @cvpcs is having in #1070.

  24. jbaehr commented on Feb 20, 2018

    @jbaehr
    Contributor

    Today I ran into the same issue. Two instances of Visual Studio, each building unrelated sources from different git repos. Unfortunately at the same time on the same machine.
    On one side I have GitVersion-3.6.5, on the other GitVersion-4.0.0-beta12. As soon as I close one instance, the other works again; no matter in which order. This means, the v4-beta12 breaks when a v3.6.5 ran, and the other way round, too.

  25. threegerbils commented on Mar 21, 2019

    @threegerbils
  26. asbjornu commented on Mar 22, 2019

    @asbjornu
    Member

    Seems like dotnet/Nerdbank.GitVersioning#216 might be worth looking at.

  27. asbjornu commented on Jun 27, 2019

    @asbjornu
    Member

    After upgrading to LibGit2Sharp version 0.26 in #1713, this problem might be fixed. Can you please try the latest build and report back whether it fixes this problem or not? Please reopen this issue if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions