Cannot install System.Data.SqlClient from NuGet or Dotnet cli

Damian Young 0 Reputation points
2023-07-25T14:11:53.16+00:00

Hi everyone I have tried searching how and low for a response to this but to no avail.

I am trying to install System.Data.SqlClient for a backend server. When I open Visual Studio (Community Edition) and follow the regular workflow to install NuGet packages (Solution -> Manage NuGet Packages For Solution) System.Data.SqlClient is not displayed in the Browse section. When I run the command from the dotnet cli

dotnet add package System.Data.SqlClient --version 4.8.5

I get the error

C:\Users\Damian\source\repos\Doorpack2.0\Doorpack2.0.csproj(256,3): error MSB4019: The imported project "C:\Program Files (x86)\dotnet\sdk\7.0.109\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\ProgramFiles(x86)\dotnet\sdk\7.0.109\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.Unable to create dependency graph file for project 'C:\Users\Damian\source\repos\Doorpack2.0\Doorpack2.0.csproj'. Cannot add package reference.

In the Microsoft folder in the stacktrace the folder VisualStudio\v17.0 does not exist so I wonder if this is why?

If so does anyone know any resolutions for this error? If you need any further clarification please let me know I've tried to be in depth.

Developer technologies .NET Other
Developer technologies ASP.NET Other
Developer technologies .NET .NET CLI
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.