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.

When globally installing a tool, a reference to Microsoft.SourceLink.AzureRepos.Git is added causing NU1211 & NU1212

See original GitHub issue

Describe the bug

In a Windows11 laptop, with latest .NET SDK, 7.0.302 when I try to install a .NET Tool, somehow the .NET SDK adds a reference to Microsoft.SourceLink.AzureRepos.Git and this triggers two issues: NU1211 & NU1212. error NU1211: Project restore must have a single package reference(s). C:.…\Local\Temp\e77043b8-a3d2-4c67-bfcb-40fffd2ba162\restore.csproj : error NU1212: Invalid project-package combination for Microsoft.SourceLink.AzureRepos.Git 1.1.1. DotnetToolReference project style can only contain references of the DotnetTool type The tool package could not be restored.

To Reproduce

Essentially to reproduce in my environment, I either install any tool globally or do it locally by:

  • dotnet new tool -n MySampleTool
  • editing the csproj file to make it a tool: <OutputType>Exe</OutputType> <TargetFramework>net7.0</TargetFramework> <PackAsTool>true</PackAsTool> <ToolCommandName>MySampleTool</ToolCommandName>
  • building with dotnet build
  • creating a NuGet package: dotnet pack --configuration Release --output ./nupkgs
  • Installing the package as a global tool: dotnet tool install -g --add-source ./nupkgs MySampleTool

That said I am unsure that this happens with due to the .NET SDK 7.0.302 or there is a misconfiguration anywhere… I used the .NET repair tool, updated Visual Studio to the latest version and uninstalled other SDK.

And it keeps happening… any help would be really welcome…

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
KalleOlaviNiemitalocommented, Jun 8, 2023

Is there a Directory.Build.props, Directory.Build.targets, or Directory.Packages.props file in the temp directory?

0reactions
joslatcommented, Jun 12, 2023

Finally got it!

It was a props file (Directory.Build.Props) hiding in my user’s directory root, after a long stream of files…

Found it by executing a powershell command to find any file containing this string. It took a while but it did the trick.

the script, for if it can help anybody: Get-ChildItem -Path .\ -Recurse -Include *.* -File -ErrorAction SilentlyContinue | Select-String -Pattern "Microsoft.SourceLink.AzureRepos.Git" -ErrorAction SilentlyContinue | ForEach-Object { $_.Path } | Out-File -Encoding utf8 -FilePath "c:\search_results.txt"

I removed that file and others with the same date-time stamp and all seems to work fine now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SourceLink Authentication error when using Microsoft. ...
I am trying to enable SourceLink for our internal NuGet packages and am running into a problem where I don't see how I...
Read more >
Producing Packages with Source Link - .NET Blog
In this post, we'll show you how to add Source Link to your projects. This is beneficial both for public and internal projects....
Read more >
c# - SourceLink Authentication error when using Microsoft. ...
A PackageReference to Microsoft.SourceLink.AzureRepos.Git, using the latest Version (1.0.0-beta2-19554-01); This project generates a package ...
Read more >
Microsoft.SourceLink.AzureRepos.Git 1.1.1
Generates source link for Azure Repos (formerly known as VSTS) Git repositories.
Read more >
How to Configure Visual Studio to Use SourceLink to Step into ...
By default SourceLink support is already enabled in Visual Studio, but source server support is not. Again, go to the Tools –> Options...
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