0

I'm just starting out with a new Console Application project in VS Code and I need to add a reference to my project for Microsoft.SharePoint.Client using:

dotnet add package Microsoft.SharePoint.Client.dll --version 15.0.4420.1017

However the console returns the following and the .csproj file does not change:

  Determining projects to restore...
  Writing C:\Users\usr1\AppData\Local\Temp\tmpC9C5.tmp
info : Adding PackageReference for package 'Microsoft.SharePoint.Client.dll' into project 'C:\Users\usr1\repo\TstApi\TstApi.csproj'.
info : Restoring packages for C:\Users\usr1\repo\TstApi\TstApi.csproj...
error: NU1101: Unable to find package Microsoft.SharePoint.Client.dll. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Package 'Microsoft.SharePoint.Client.dll' is incompatible with 'all' frameworks in project 'C:\Users\usr1\repo\TstApi\TstApi.csproj'.

Any assistance with this error would be appreciated:

error: NU1101: Unable to find package Microsoft.SharePoint.Client.dll. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

EDIT:

Here's the build error:

dotnet build
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Users\usr1\repo\TstApi\Program.cs(2,17): error CS0234: The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\usr1\repo\TstApi\TstApi.csproj]

Build FAILED.

C:\Users\usr1\repo\TstApi\Program.cs(2,17): error CS0234: The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\usr1\repo\TstApi\TstApi.csproj]
    0 Warning(s)
    1 Error(s)

And here's my csproj and the beginning of my program.cs:

enter image description here

enter image description here

1 Answer 1

0

I rolled back my version of dotnet from 5.0.401 to 3.1.413 and it seems to have worked.

First check which version I'm using:

dotnet --version
5.0.401

Then get my installed SDK versions:

dotnet --info

Get my version number for 3.x i.e. "3.1.413":

.NET SDKs installed:
  3.1.413 [C:\Program Files\dotnet\sdk]
  5.0.303 [C:\Program Files\dotnet\sdk]
  5.0.401 [C:\Program Files\dotnet\sdk]

Then switch to that version:

dotnet new globaljson --sdk-version 3.1.413 --force

Then confirm my new version:

dotnet --version
3.1.413

Now when I run my add package it adds the reference to my project and my csproj file reflects the change:

dotnet add package Microsoft.SharePoint.Client.dll --version 15.0.4420.1017

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.