Skip to content

The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. #107

@pshrosbree

Description

@pshrosbree

When adding SourceLink to my project I get the following error.
I am using VSTS.
My environment is listed below,
Any help would be appreciated.

λ  dotnet build .\AppCenter.Core.csproj
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 32,51 ms for C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj.
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.RuntimeIdMap.GetNativeLibraryDirectoryName() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.GitLoaderContext.GetNativeLibraryDirectory() in /_/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs:line 55 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.GitLoaderContext.LoadUnmanagedDll(String unmanagedDllName) in /_/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs:line 30 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    --- End of inner exception stack trace --- [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Repository.Discover(String startingPath) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.RepositoryTasks.LocateRepository(LocateRepository task) in /_/src/Microsoft.Build.Tasks.Git.Operations/RepositoryTasks.cs:line 50 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.LocateRepository.Execute() in /_/src/Microsoft.Build.Tasks.Git/LocateRepository.cs:line 32 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in E:\A\_work\82\s\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 631 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() in E:\A\_work\82\s\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 787 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]

I have this .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Description">
    <Title>Visual Studio App Center Core</Title>
    <PackageId>AppCenter.Core</PackageId>
    <Description>Visual Studio App Center features that depend upon only .NET Framework, System Interactive, System Reactive, TPL Dataflow, Immutable Collections, Microsoft Extensions, RecyclableMemoryStream, ValueTuple and JetBrains.Annotations</Description>
    <RootNamespace>AppCenter</RootNamespace>
    <TargetFrameworks>netstandard2.0</TargetFrameworks>
  </PropertyGroup>

  <PropertyGroup Label="Packaging">
    <AssemblyName>$(PackageId)</AssemblyName>
    <Authors>Microsoft</Authors>
    <Company>Microsoft Corporation</Company>
    <Copyright>Copyright © Microsoft Corporation. All rights reserved.</Copyright>
    <IsPackable>true</IsPackable>
    <PackageProjectUrl>https://www.visualstudio.com/app-center/</PackageProjectUrl>
    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
    <PackageTags>Core;AppCenter</PackageTags>
    <Product>Visual Studio App Center</Product>
    <RepositoryType>git</RepositoryType>
    <RepositoryUrl>https://msmobilecenter.visualstudio.com/Mobile-Center/_git/appcenter</RepositoryUrl>
  </PropertyGroup>

  <PropertyGroup Label="Build">
    <DefineConstants>$(DefineConstants);CODE_ANALYSIS;JETBRAINS_ANNOTATIONS</DefineConstants>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    <IsTool>False</IsTool>
    <LangVersion>latest</LangVersion>
    <NeutralLanguage>en</NeutralLanguage>
    <OutputType>Library</OutputType>
    <PlatformTarget>x64</PlatformTarget>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <DefineConstants>TRACE</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <DefineConstants>TRACE;DEBUG</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Label="Sign">
    <SignAssembly>False</SignAssembly>
    <AssemblyOriginatorKeyFile>..\..\..\tools\build-dotnet\signing\AppCenter.snk</AssemblyOriginatorKeyFile>
  </PropertyGroup>

  <PropertyGroup Label="SourceLink Settings">
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Portable</DebugType>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
    <IncludeSource>True</IncludeSource>
    <IncludeSymbols>True</IncludeSymbols>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
  </PropertyGroup>

  <ItemGroup Label="SourceLink Packages">
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-63102-01" PrivateAssets="all" />
  </ItemGroup>
<!-- 
  <ItemGroup Label="Versioning">
    <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
  </ItemGroup>
 -->
  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <DocumentationFile>bin\Release\netstandard2.0\AppCenter.Core.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <DocumentationFile>bin\Debug\netstandard2.0\AppCenter.Core.xml</DocumentationFile>
  </PropertyGroup>

  <ItemGroup Label="Package References">
    <PackageReference Include="Castle.Core" Version="4.3.1" />
    <PackageReference Include="FluentAssertions" Version="5.4.1" />
    <PackageReference Include="Humanizer.Core" Version="2.4.2" />
    <PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
    <PackageReference Include="LanguageExt.Core" Version="3.0.18" />
    <PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.1.1" />
    <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.2.2" />
    <PackageReference Include="Serilog" Version="2.7.1" />
    <PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
    <PackageReference Include="System.Interactive" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Async" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Async.Providers" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Providers" Version="3.1.1" />
    <PackageReference Include="System.Reactive" Version="4.0.0" />
    <PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
  </ItemGroup>

</Project>

My dotnet environment is:

λ  dotnet --info
.NET Command Line Tools (2.1.101)

Product Information:
 Version:            2.1.101
 Commit SHA-1 hash:  6c22303bf0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.101\

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684

.NET Core SDKs installed:
  1.0.3 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0-preview2-006497 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.3 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.105 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]
  2.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0-preview2-25407-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions