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.

Build fails after including a library built with SourceLink

See original GitHub issue

I have a .NET Framework 4.7 project with a NuGet package reference of a .NET Standard 2.0 library I built with SourceLink. The build fails with:

C:\mysolution\packages\Microsoft.Build.Tasks.Git.1.0.0-beta-62925-02\build\Microsoft.Build.Tasks.Git.targets(20,5): error : Unable to locate repository containing directory ‘C:\mysolution\myproject’

This is due to the project I am trying to build not being under git source control.

To make this build I had to include the following in my project file:

<PropertyGroup>
    <RepositoryType>hg</RepositoryType>
</PropertyGroup>

This means that for anyone using my NuGet package, they would either need to be using git or make the manual change to their project file.

Here is where it defaults to git: https://github.com/dotnet/sourcelink/blob/74fc354e81dc6b7b33596c4f20a926c71ed41a68/src/Microsoft.Build.Tasks.Git.Operations/build/Microsoft.Build.Tasks.Git.targets#L24-L26

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tmatcommented, Jun 22, 2018

I don’t think Install-Package sets the PrivateAssets metadata.

0reactions
appcoreopccommented, Dec 14, 2018

Despite adding PrivateAssets=“All”, i am still getting “Unable to locate repository”.

The configuration i had in my csproj are as follows :-

<PackageReference Include="Microsoft.SourceLink.GitLab" Version="1.0.0-beta-63127-02"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding SourceLink nuget package causes build error
I've been following this documentation to enable SourceLink in an effort to be able to debug private nuget packages hosted on our Azure...
Read more >
Adding the appropriate SourceLink Nuget causes build to fail
The mere act of installing the appropriate nuget package (Microsoft.SourceLink.Vsts.Git) causes the build to fail with the following error:.
Read more >
Source Link and .NET libraries
Instructions for using Source Link can be found on the dotnet/sourcelink GitHub repository. You can use the NuGet Package Explorer desktop app ...
Read more >
Link /SOURCELINK option seems to do nothing
We are using SourceLink with c# projects and it is working just fine. ... that retrieving Source Link may fail even if it...
Read more >
NCrunch build breaks when building with SourceLink
NCrunch build breaks when building with SourceLink: Hi, when you include the SourceLink NuGet Package for VSTS.Git for Reference see here ...
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