I need to interact with SharePoint (on premise) and decided to give a try to F#. It is or should be simple enough that I did it with CLI tools only.
I managed to interact with a site and get the info I needed. I struggled with the required DLL, but in the end
#if INTERACTIVE
#r @"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
#r @"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
// seems to be required
#r @"[...]\Microsoft.Online.SharePoint.Client.Tenant.dll.15.0.4615.1001\Microsoft.Online.SharePoint.Client.Tenant.dll"
#r @"[...]\SharePointPnPCoreOnline.3.8.1904\lib\net45\OfficeDevPnP.Core.dll"
#endif
worked out with Fsi REPL
or Fsi script.fsx
, but I cannot make it compile, wether as a fs file or with the fsx script.
My code is, say:
open Microsoft.SharePoint.Client;;
let main () =
let authnManager = OfficeDevPnP.Core.AuthenticationManager()
printfn "%A" authnManager
0
main()
Running with fsi:
PS> fsi script.fsx
OfficeDevPnP.Core.AuthenticationManager #OK!
Trying to compile:
PowerShell> fsc --warn:5 -r "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" `
>> -r "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" `
>> -r "absolute\path\to\Microsoft.Online.SharePoint.Client.Tenant.dll.15.0.4615.1001\Microsoft.Online.SharePoint.Client.Tenant.dll" `
>> -r "absolute\path\to\SharePointPnPCoreOnline.3.8.1904\lib\net45\OfficeDevPnP.Core.dll" .\script.fsx
Microsoft (R) F# Compiler version 10.4.0 for F# 4.6
Copyright (c) Microsoft Corporation. All Rights Reserved.
> .\script.exe
Exception non gérée (unmanaged exception) : System.IO.FileNotFoundException:
Impossible de charger le fichier ou l'assembly 'OfficeDevPnP.Core,
Version=3.8.1904.0, Culture=neutral, PublicKeyToken=5e633289e95c321a'
ou une de ses dépendances. Le fichier spécifié est introuvable.
à Script.main()
à <StartupCode$script>.$Script$fsx.main@()
Why this difference? What am I missing? How to load references with fsc (as nuget installed quite a few transitive dependencies) ? They must be managed as well with fsc as with fsi, for sure! (Unless there's a specific issue with OfficeDevPnP.Core.dll
...)