Azure Function Adding Reference to Sharepoint.dll Failing - c#

I am getting an error when I attempt to add a reference to the Microsoft.Sharepoint.dll into my Azure function class. It keeps giving me the following error:
Package Sharepoint 15.0.0 is not compatible with net462 (.NetFramework, Version=v4.6.2). Package Sharepoint 15.0.0 supports microsoftsharepoint (Microsoft.SharePoint,version=v0.0).
Also the Microsoft.Sharepoint.Client.Runtime has a similar issue.
Given this I have followed other advice to switch the targeting framework to 4 and 4.5 but all of these seem to fail similarly. What is the supported framework for this and how can I add it into an azure function. Also I am dealing with an on-prem instance of sharepoint so I cannot connect via the online apis.

The Microsoft.Sharepoint.dll have no dependencies so, it it no matter with framework. I test in my site and could install it correctly.
You could try to use the Package Manager console in Visual Studio to install instead of the Manager Packages tool for the project.
And if you use Manage Nuget Packages, delete Nuget's cache from the packages' manager configuration.

Related

nuget not resolving dependency using what specified in nuget package for Microsoft.Extensions.Logging

Background:
I have created a class library for .net core (targetting v2.2), and I have a .net core application as well (targetting v2.2).
I am trying to export the library as nuget package and install it in my application.
Here is the dependencies for my library
I am able to export it as nuget package and for now I am storing it in local nuget repo.
But when I try to install this library package in my application it's not getting installed due to package version conflict for Microsoft.Extensions.Logging. Here's package manager console output.
Issue:
I have specified the exact version for Microsoft.Extensions.Logging i.e. [2.2.0] as we could confirm that in the screenshot showing dependency for my library, then why it's getting resolved to version 3.0.0?
How could I resolve this issue?
Details about the environment:
NuGet product used (Package Manager Console): Package Manager Console Host Version 5.3.1.6268
VS version (if appropriate): Microsoft Visual Studio Community 2019 Version 16.3.8
OS version (i.e. win10 v1607 (14393.321)): Windows 10 Enterprise Version: 1809
How could I resolve this issue?
To resolve the strange behavior in your side, you should clean the nuget cache before installing that package in your current project.
(To make sure the cache is cleaned up, I suggest you go %userprofile%\.nuget\packages to check if there exists Com.lib folder within the Packages folder)
I have specified the exact version for Microsoft.Extensions.Logging
i.e. [2.2.0] as we could confirm that in the screenshot showing
dependency for my library, then why it's getting resolved to version
3.0.0?
I think the one(Com.Mylib) you want to install is not the first one you pack. I mean that you may actually build and pack several different Com.Mylib package with different content. And all of their names is Com.lib.1.0.0.nupkg.
Nuget stores all nuget cache in %userprofile%\.nuget\packages. So if I once install one PackageA in any project. The cache of PackageA is stored there. And if I open a new project trying to install the PackageA with same version(1.0.0), it actually installs the one from cache. So we will meet this strange behavior:
Nuget can recognize the Com.lib package depends on other 2.2.0 packages. But when it tries to install that package, it finds the package has existed in cache. Then he tries to install the one from cache, and I guess content of the one in cache is different from your latest one, then the issue occurs.
Suggestions:
1.When developing locally, use project reference instead of Nuget packages.
2.If you need to test the nuget package every time after packing, please make sure the package version has increased.(1.0.0=>1.0.1=>1.0.3... or beta-1.0.12, preview-xxx)
3.If you have special reason do use same version 1.0.0, please clean the cache to avoid previous cache affects current project.
Hope all above helps :)

Adding SourceLink nuget package causes build error

I've been following this documentation to enable SourceLink in an effort to be able to debug private nuget packages hosted on our Azure DevOps account, but have run into an issue.
The mere act of installing the appropriate nuget package (Microsoft.SourceLink.Vsts.Git) causes the build to fail with the following error:
1>vbc : error BC2001: file 'C:\Users\USER\AppData\Local\Temp\.NETStandard' could not be found
1>vbc : error BC2001: file 'C:\Projects\TheApp\TheLibrary\TheLibrary\Version=v2.0.AssemblyAttributes.vb' could not be found
This makes me think I'm missing some SDK or have the wrong version of VS2017, but it all seems ok: I'm on VS2017 15.8.7, have the .NET Core SDK 2.1.403 installed and the project is a .NET Standard 2.0 library.
Removing the nuget package makes the build pass again, but obviously removes the SourceLink support as well.
It turns out the issue was with the VB compiler. The SourceLink guide tells you that you can optionally include a <EmbedUntrackedSources>true</EmbedUntrackedSources> in the project file, but this causes the build to fail. An issue has been created to fix this in the compiler, but for now Microsoft advised me to just not inlcude that switch. Removing it let my build pass and SourceLink now works as advertised.

How to install Microsoft.Azure.Devices NuGet package for Unity?

I was working with Unity and Hololens and tried to establish connection to Azure Iot Hub via MQTT protocol. Microsoft provides a tutorial for getting started with Azure IoT Hub in C#, but unfortunately, I encountered a problem with the tutorial:
In the picture above, I have selected Microsoft.Azure.Device NuGet package for installation. I have tried version 1.0.0 and also the latest one available, 1.2.4. The projects were automatically generated by Unity and that is probably the reason, why I do encounter this problem. Which problem? After I try to install the selected NuGet, I encounter the following error:
Could not install package 'Microsoft.Azure.Devices 1.2.4'. You are
trying to install this package into a project that targets
'.NETFramework,Version=v3.5,Profile=Unity Full v3.5', but the package
does not contain any assembly references or content files that are
compatible with that framework. For more information, contact the
package author.
I was like, "Hmm, I must have wrong .NET framework version. I wonder if I can change that..." I tried to go to project properties like this
Microsoft advises changing .NET framework from Properties context menu item:
https://technet.microsoft.com/fi-fi/library/bb772098(v=vs.90).aspx (4.24.2017)
https://msdn.microsoft.com/en-us/library/bb398202(v=vs.100).aspx (4.24.2017)
However, this feature must be blocked by something, because the view that is supposed to open flashes white and disappears immediately. I suppose Unity doesn't like people tinkering with project properties, but what else can I do? Incompatible .NET framework issue needs to be resolved, so that the NuGet package can be installed, but how do I do that?
In short, how to install Microsoft.Azure.Devices NuGet package for Unity?
Sorry, this isn't possible due Unity's restriction to .net 3.5.
To be exactly, they use a custom version of mono-2.
You could try the new (experimental) .net 4.6 settings in Unity 5.6.
https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/

Can we deploy a C# 7 web app to Azure using Kudu?

Since Visual Studio 2017 is released and we can use the new C# 7 features I expected this will work when deploying on Azure Web apps.
Unfortunately we're seeing compile errors when using continuous deployment (kudu git deploy) so it seems Azure doesn't support the new toolchain yet.
Is there anything we can do to get this to work now (besides publishing the assemblies directly)?
since we don't yet have msbuild15 in Azure.
if you want to use c#7 features with continuous integration, you may need some workaround
for dotnet core web solution, you can build it in Azure out of the box. (it uses its own dotnet msbuild.dll) [repository sample]
for asp.net web solution, you need to add Microsoft.Net.Compilers 2.0+ nuget package to the project where the new language feature is applied. For example, if a class library in the solution is using the new syntax, you need to add nuget package to that lib project. (the new c# compiler is thus imported if you refer this nuget package) [repository sample]
finally for mixed solution (dotnet core web app + .NET framework class lib), you need to run nuget restore for the .NET framework lib project independently since dotnet restore is not backwards compatible, it cannot retore project from the old build system. I did this by hacking my deploy.cmd [repository sample]
these workarounds either try to
imitate msbuild15 (case1: dotnet msbuild.dll, case2: compiler as a nuget package)
or imitate nuget4.0 (case 3: run both dotnet restore and nuget3.5 restore)
we are in the process of building these tools for Azure, they should be out soon. you can stay updated on github
Adding the Microsoft.Net.Compilers NuGet package fixes the issue.
As pointed out by #joshuanapoli in a comment to the accepted answer Scenario #2 works only with Microsoft.Net.Compilers v2.4.0 and below.
Took me a couple of hours to notice and figure it out.

.Net Micro with Microsoft Azure

I'm trying to make a Netduino communicate with Azure. I've found several other projects and in their source code they use the package Microsoft.WindowsAzure like any other Azure project. In my project, though, it claims that the package name cannot be resolved.
I found somewhere that I had to go into Manage NuGet Packages and install it, but when I try, it halts the installation at JSON and rolls it all back.
This is the error message I get:
Adding 'Newtonsoft.Json 5.0.8' to Netduino.
Uninstalling 'Newtonsoft.Json 5.0.8'.
Successfully uninstalled 'Newtonsoft.Json 5.0.8'.
Install failed. Rolling back...
Could not install package 'Newtonsoft.Json 5.0.8'.
You are trying to install this package into a project that targets '.NETMicroFramework,Version=v4.2',
but the package does not contain any assembly references or content files that are compatible with that framework.
For more information, contact the package author.
What haven't I done? What am I doing wrong?
You can use NETMF.Json if you are running NETMF 4.2 or later
NETMF.Json on GitHub
I use it in my realtime pub/sub client for NetDuino here XSockets NetMF client
AFAIK Newtonsoft.Json is not compatible with .NET Microframework
"Supports .NET 2, .NET 3.5, .NET 4, Silverlight, Windows Phone and Windows 8" (from http://json.codeplex.com/ )
Infact you get this error:
You are trying to install this package into a project that targets '.NETMicroFramework,Version=v4.2',
but the package does not contain any assembly references or content files that are compatible with that framework.

Categories