
First, create a console app : dotnet new console
. Refer to this article for more: https://learn.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code
Then add the pnp framework package: dotnet add package PnP.Framework --version 1.4.0
The code would be like this:
using System;
using Microsoft.SharePoint.Client;
using PnP.Framework;
namespace CSOM
{
class Program
{
static void Main(string[] args)
{
string site = "https://tenant.sharepoint.com/sites/test";
string appId = "<app clientID>";
string appSecret = "<app secret>";
var authMgr=new AuthenticationManager();
var ctx=authMgr.GetACSAppOnlyContext(site,appId,appSecret);
var web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
//copy list here
}
}
}