.NET Core Azure Function missing reference - nuget

I've added a Nuget-package to my .NET Core "Azure Function"-project:
Install-Package SharePointPnPCoreOnline -Version 2.22.1801
But I receive an error in my code:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: StoreInDatabase --->
System.IO.FileNotFoundException : Could not load file or assembly
'SharePointPnP.IdentityModel.Extensions, Version=1.2.3.0,
Culture=neutral, PublicKeyToken=5e633289e95c321a' or one of its
dependencies. The system cannot find the file specified.
This assembly should be included from the Nuget Package, but it doesn't.
As I'm new to .NET Core and Azure Functions, does anyone know how to solve this one?
Update
I see the package has another version number than in the error-details.
But still no idea how to solve this... any ideas?

Looking at the nuget package with the wrong version number, I saw that previous versions are "hidden" in NuGet...
https://www.nuget.org/packages/SharePointPnP.IdentityModel.Extensions/
I solved this by installing the latest version of the package
So in my case, I just ran the command:
Install-Package SharePointPnP.IdentityModel.Extensions -Version 1.2.3

Related

nuget package is not compatible with netcoreapp2.0

I created nuget package yet while
PS C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget> dotnet add package abhi.TaskQueueLib --version 1.0.0
Writing C:\Users\vicky\AppData\Local\Temp\tmp44DF.tmp
info : Adding PackageReference for package 'abhi.TaskQueueLib' into project 'C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget\Tes
tnuget.csproj'.
log : Restoring packages for C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget\Testnuget.csproj...
info : GET https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/index.json
info : OK https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/index.json 1139ms
info : GET https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/1.0.0/abhi.taskqueuelib.1.0.0.nupkg
info : OK https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/1.0.0/abhi.taskqueuelib.1.0.0.nupkg 1424ms
log : Installing abhi.TaskQueueLib 1.0.0.
error: Package abhi.TaskQueueLib 1.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package abhi.TaskQueueLib 1.0.0
supports: root (Root,Version=v0.0)
error: Package 'abhi.TaskQueueLib' is incompatible with 'all' frameworks in project 'C:\Users\vicky\Documents\ThreadBasedJobQueue\Testn
uget\Testnuget.csproj'.
The following documentation has the answers you are seeking:
https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks
Irrespective of whether you target one framework or multiple frameworks, you should create the ‘framework’ folder under the lib directory and then put the dll into that framework folder. This folder for the target framework is called Target Framework Moniker or TFM in short. List of all the allowed TFMs for NuGet is captured here:
https://learn.microsoft.com/en-us/nuget/schema/target-frameworks#supported-frameworks
Found the issue in lib folder i had to make folder by framework Name and then had to pack.
Un knowing i was keeping my Dll in Lib Folder
please refer https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package

Entity Framework 7 with Universal Windows Platform Add-Migration

I'm trying to implement Universal Windows Platform application with EntityFramework and SQLite (according to: http://ef.readthedocs.org/en/latest/platforms/uwp/getting-started.html) but I have problem with Add-Migration command.
Here is my setup:
Visual Studio 2015 Update 1
EntityFramework.SQLite: "7.0.0-rc1-final"
Error that I got while adding migrations is:
Could not load file or assembly 'System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Thanks in advance for your help!
It is clearly that you miss a dll "System.Collections.Immutable, Version=1.1.36.0" in your project.
To solve this problem, you can open the Nuget tool, and search for System.Collections.Immutable, then in the "Version" label select the Version 1.1.36, by default it is the latest version 1.1.37.
You can also try to update your VS tool, this possible may also solve your problem.

EF7: The term 'add-migration' is not recognized as the name of a cmdlet

I have framework version set to: dnx46 in project.json.
Also have the following packages:
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
}
However when I got into running enable-migrations command I get the following:
The term 'enable-migrations' is not recognized as the name of a cmdlet
Does anyone know how I get EF migrations running in latest .NET?
This is what worked for me to solve this issue:
Run:
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
In project.json add this (if not there already) to the "tools" section:
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final",
Useful reference: https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html
As ErikEJ mentioned, there is no "enable-migrations". You will need to use "Add-Migrations" instead. See official docs for EF Core's Powershell commands here: http://docs.efproject.net/en/latest/cli/powershell.html
There appears to be a bug in NuGet and Package Manager Console in some versions of Visual Studio. If cmdlets are not recognized after adding the Commands package, try restarting VS.
Also, dnx commands will not be supported after RC1. New (forthcoming) dotnet tooling will be available for RC2. See https://github.com/aspnet/EntityFramework/issues/3925
The only way I managed to get EntityFrameworkCore.Tools (which includes Add-Migration) working with the latest EF Core & VS 2015 was to manually call the init script from the Package Manager Console like so:
PM> %UserProfile%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview1-final\tools\init.ps1
To add a new migration in EF7 use this command :
dnx ef migrations add YourMigrationUniqueName
There is no "enable-migrations" command in EF Core (EF7).
Just use "add-Migration"
Currently EF migrations are not supported out of the box:
https://github.com/aspnet/EntityFramework/issues/4497
I Haved the same probleam, i was using the PowerShell for the comand, but he work in Package Manager Console.
Try to run in ->
Tools -> NuGet Package Manager -> Package Manager Console

Type or Namespace "Dapper" could not be found: in Hangfire Source code in Visual Studios?

I've imported the Hangfire Source code from Github into my existing VS 2013 solution. When I attempted to build all projects within my solution, I get several errors:
Error 6 The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Jerry_Dev\Documents\GitHub\Hangfire\src\Hangfire.SqlServer\SqlServerDistributedLock.cs 20 7 Hangfire.SqlServer
In Package Manager, when I do: "Install-Package Dapper", it says
'Dapper 1.38' already installed.
Hangfire.SqlServer already has a reference to 'Dapper 1.38'.
I see Dapper dot net installed in my Manage Nuget Packages Window in my Hangfire.SqlServer project
We don't store the packages folder under source control to reduce the source code size. Hangfire uses Automatic Package Restore in Visual Studio instead of obsolete MSBuild-integrated package restore. The Automatic Restore downloads missing packages automatically on each build, but it works only with NuGet ≥ 2.7, so you have the following options:
Update NuGet to the latest version
Please see the official docs.
Run the build script
Go to the root Hangfire directory and run the build.bat file. It will automatically restore all the missing packages.

Avoid dependency of a pure code snippet package

Example:
Nuget package A is a set of code snippets (it does not contain an assembly).
Nuget package B is a normal assembly and it is using package A - just for internal means.
Question: What can I do, to avoid, that package A is also installed, when somone installes package B?
Found something in documentation of nuget:
Starting from version 2.7, the pack command will ignore entries in the packages.config file which have an attribute developmentDependency set to true and will not include that package as a dependency in the created package. For example, consider the following packages.config file in the source project
That seems to solve the problem.