NuGet unabled to install Grpc.Tools in existing project

876 Views Asked by At

I'm trying to install the NuGet package Grpc.Tools alongside Grpc, Grpc.Core and Google.Protobuf using VS 2017 Enterprise. Installation of all packages except Grpc.Tools works. If I try to install Grpc.Tools I dont get the corresponding folder inside packages/. The package manager command line issues the following output:

"Grpc.Tools 1.4.1" wird installiert.
Das NuGet-Paket "Grpc.Tools 1.4.1" wird installiert.
Commit für Wiederherstellung wird ausgeführt...
Die Sperrdatei wird auf den Datenträger geschrieben. Pfad: C:\Users\User\Documents\Visual Studio 2017\Projects\Muffelsausen\CommInterface\obj\project.assets.json
Wiederherstellung in "5,06 sec" für "C:\Users\User\Documents\Visual Studio 2017\Projects\Muffelsausen\CommInterface\CommInterface.csproj" abgeschlossen.
"Grpc.Tools 1.4.1" wurde erfolgreich auf "CommInterface" installiert.
Commit für Wiederherstellung wird ausgeführt...
Die Assetdatei wurde nicht geändert. Das Schreiben der Assetdatei wird übersprungen. Pfad: C:\Users\User\Documents\Visual Studio 2017\Projects\Muffelsausen\CodeOfPointsHost\obj\project.assets.json
Wiederherstellung in "14,87 ms" für "C:\Users\User\Documents\Visual Studio 2017\Projects\Muffelsausen\CodeOfPointsHost\CodeOfPointsHost.csproj" abgeschlossen.

Verwendete NuGet-Konfigurationsdateien:
    C:\Users\User\AppData\Roaming\NuGet\NuGet.Config
    C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

Verwendete Feeds:
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
    https://api.nuget.org/v3/index.json
Das Ausführen von NuGet-Aktionen hat 1,75 sec gedauert.
Verstrichene Zeit: 00:00:06.8978688
========== Abgeschlossen ==========

NuGet-Pakete werden wiederhergestellt...
Verstrichene Zeit: 00:00:00.7245861
========== Abgeschlossen ==========

I don't see any errors. However, no Grpc.Tools subfolder is added in packages/. Hence, I don't have the protoc compiler. The odd thing is, if I repeat the same process within an new, empty project the tools are actually installed. Any idea why VS 2017 fails in my case?

I have several projects in my solution: * Multiple .NET Core 2.0 class libraries * One .NET Core 2.0 console application * .NET 4.6.2 WPF desktop project * .NET 4.6.2 XAML resource dictionary project

The only workaround is manually copy/pasting the Grpc.Tools folder.

1

There are 1 best solutions below

0
On BEST ANSWER

NuGet unabled to install Grpc.Tools in existing project

You must install Grpc.Tools to your .net core project. The default packages directory for .net core projects is %USERPROFILE%/.nuget/packages. If you install this package to your WPF project, you will see this package exists in the packages folder.

That is why you noticed that VS actually installs the package into your user profile instead of using your local packages folder. That because .Net Core projects rely on so many NuGet packages. Almost hovering around 1GB. I do not think you will want to set all those packages for each solution. So NuGet team using the globe directory for .net core projects.

If you still want this package exist in your local folder (Not recommended), you can set "NUGET_PACKAGES" environment variable. Just Set "NUGET_PACKAGES" = "c:\teampackages". Or you can place a NuGet.Config file next to the solution with the following content:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <config>
      <add key="globalPackagesFolder" value=".\packages" />
    </config>
  </configuration>

For the detail info, you can refer to the same issue on GitHub.