12

I'm trying to generate the Distributed SQL Server Cache for ASP.NET Core 2.0, using the CLI, but I only get an error. The instructions say to execute

dotnet sql-cache create <connection string>  <schema>  <table name>

but when I do, it simply responds with No executable found matching command "dotnet-sql-cache".

I have installed Microsoft.Extensions.Caching.SqlConfig.Tools 2.0.0 on that project. So it should work from the project root, no?

When I execute dotnet -h, I get .NET Command Line Tools (2.0.2), etc. Surprisingly enough, sql-cache is not listed there among the SDK commands, alongside new, restore, run, migrate, etc. Shouldn't it be?

David
  • 2,782
  • 4
  • 31
  • 47

3 Answers3

11

I faced many troubles installing this tool, the only solution which worked for me was the one from @PAS, but only after adding the exact .Net Core version to the package installer.

Installing the latest one or even a slightly different one like 3.1.2 failed miserably.

So, the command line became :

dotnet tool install --global dotnet-sql-cache --version 3.1.0
XavierAM
  • 1,627
  • 1
  • 14
  • 30
3

I have found installing certain Tools to be troublesome when I have used Nuget either by using the CLI or the package manager. In the past I have had to directly install a tool in the csproj file. Check your csproj file and see if the installation of the SqlConfig took hold. If it has not just add it and run a dotnet restore. Here is an example of how to "hard code" the tool. ```

<ItemGroup>
<DotNetCliToolReference 
     Include="Microsoft.Extensions.Caching.SqlConfig.Tools" 
     Version="2.0.0" />
</ItemGroup>

Also, here is a link to where a better explanation to the issue. It also recommends installing Microsoft.Extensions.Caching.SqlServer if you have not already done so but I would try this solution first. Hope this helps.

sjgallen
  • 239
  • 3
  • 8
  • My csproj file had an `ItemGroup` having `PackageReference`, but not one having `DotNetCliToolReference`. Adding the latter got this working for me. Great answer; thanks! – David Nov 19 '17 at 17:49
  • The Nuget seems a little bit outdated (Monday, May 7, 2018 (5/7/2018)). I guess installing `dotnet` is a better approach. – Marcel Melzig Jul 13 '21 at 14:53
0

For instance I used the command:

dotnet sql-cache create "Data Source=.\Ganimedes;Initial Catalog=DistCache;Integrated Security=True;" dbo SessionCache_Test

from PowerShell console. I t's not neccesary to stay in Visual Studio to do this. The command is part of .Net Core SDK and you can use it from command line console (cmd, powershell, pwsh).

I have .Net Core 2.1 installed, this is the result of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.502
 Commit:    c74ce8f29f

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

Host (useful for support):
  Version: 2.1.6
  Commit:  3f4f8eebd8

.NET Core SDKs installed:
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [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 [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.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
FcoJavier99
  • 321
  • 2
  • 8