When globally installing a tool, a reference to Microsoft.SourceLink.AzureRepos.Git is added causing NU1211 & NU1212
See original GitHub issueDescribe 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:
- Created 3 months ago
- Comments:5
Top GitHub Comments
Is there a Directory.Build.props, Directory.Build.targets, or Directory.Packages.props file in the temp directory?
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.