pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
416 stars 643 forks source link

Azure Function V1 with SharePointPnPCoreOnline #2552

Open ravick4u opened 4 years ago

ravick4u commented 4 years ago

Category

Describe the bug

I am creating my first Azure Function(V1) with SharePointPnPCoreOnline package and Visual Studio 2019/2017. When I created a function project without SharePointPnPCoreOnline its working without any error.

But when I added SharePointPnPCoreOnline its started giving me warning message like below

NU1608: Detected package version outside of dependency constraint: Microsoft.Data.Services.Client 5.6.4 requires Microsoft.Data.OData (= 5.6.4) but version Microsoft.Data.OData 5.8.4 was resolved. NU1107: Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 11.0.1 directly to project CRB.Functions to resolve this issue. Functions -> SharePointPnPCoreOnline 3.18.2002 -> Newtonsoft.Json (>= 11.0.1) CRB.Functions -> Microsoft.NET.Sdk.Functions 1.0.24 -> Newtonsoft.Json (= 9.0.1). Package restore failed. Rolling back package changes for 'Functions'.

Upon my research, I came across with below post from elio where the solution has been suggested for this problem.

https://www.eliostruyf.com/using-the-latest-sharepoint-pnp-core-online-dependency-in-your-azure-functions/

Based on a recommendation from this post, the solution to this problem is to install "Newtonsoft.Json" package before installing "SharePointPnPCoreOnline".

When I install "Newtonsoft.Json 12.0.1" I got below warning.

NU1608 Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.24 requires Newtonsoft.Json (= 9.0.1) but version Newtonsoft.Json 12.0.1 was resolved.

Steps to reproduce

  1. Open Visual Studio and create new Azure Function project
  2. Add reference of "SharePointPnPCoreOnline"

github repo with sample code https://github.com/ravick4u/AzureFunV1WithPnP

Expected behavior

Reference of "SharePointPnPCoreOnline" should get added.

Developer environment

Additional context

This has already been discussed in the past with SharePoint/sp-dev-docs#3364 but with that no one discussed about warning message.

Thanks for your contribution! Sharing is caring.

msft-github-bot commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

jimmywim commented 4 years ago

Have you tried installing Newtonsoft.Json after installing pnp? That usually works for me.

ravick4u commented 4 years ago

@jimmywim The problem is the warning message. I can still build the solution but the warning message will never go away. Recently when I tried XMLSharePointTemplateProvider.GetTemplate() got the same message but this time it was an error. So I am worried that this warning message will cause an issue down the line. I also have repo(https://github.com/ravick4u/AzureFunV1WithPnP) created so you can give it a try if that works for you.

ravick4u commented 4 years ago

@jimmywim If I install SharePointPnPCoreOnline without installing Newtonsoft.json then getting below error.

Package restore failed. Rolling back package changes for 'FunctionAppV1'.

Error NU1107 Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 11.0.1 directly to project FunctionAppV1 to resolve this issue. FunctionAppV1 -> SharePointPnPCoreOnline 3.19.2003 -> Newtonsoft.Json (>= 11.0.1) FunctionAppV1 -> Microsoft.NET.Sdk.Functions 1.0.24 -> Newtonsoft.Json (= 9.0.1). FunctionAppV1 C:\Ravi\Source\github\AzureFunV1WithPnP\FunctionApp\FunctionAppV1\FunctionAppV1.csproj 1

I also tried new PnP release(SharePointPnPCoreOnline - 3.19.2003) but that is also giving me the same error.