Package restore failed when I use a portable library - sqlite

I am trying to install the nuget pacakge EntityFramwork.Sqlite in a portable library which targets are .net 4.6 and windows universal 10.0. If I do that, I get an error that says package restore failed.
If I create project library that is for .net 4.6 then I can add the package and if I create a universal portable library only for windows 10 applications, I can add the package too.
So, if I can use the package in .net 4.6 projects and windows universal projects, why can I not use it in a portable library that targets this kind of projects?
Thanks.

EF7 currently targets netstandard1.3 (aka dotnet5.4) and .NET 4.5.1. As of today (Jan 14, 2016), there is no PCL profile to includes both of these. (see http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY).
See also https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/standard-platform.md

Related

The current .NET SDK does not support targeting .NET Core 3.1

I have downloaded and install Visual Studio 2019 and have dotnet core 3.1 installed.
As I am starting to play around with VS, I have just created a simple project using VS built-in Web App Template and try to run without debugging.
It gives the error of "The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1."
May I know how it can be resolved?
Thanks.
Regards,
Andrew
If you already have the correct .NET Core 3.1 SDK installed it could be caused by a file called global.json. This file allows to configure which SDK is used:
The global.json file allows you to define which .NET Core SDK version
is used when you run .NET Core CLI commands. Selecting the .NET Core
SDK is independent from specifying the runtime your project targets.
The .NET Core SDK version indicates which versions of the .NET Core
CLI is used.
Delete the file or change the defined SDK to 3.1:
{
"sdk": {
"version": "3.1.100",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}
If you already have VS 2019 version more then v16.4, then magicandre1981 answer will be helpful.
But, I would suggest you to check your VS version as well. as I have invested lots of hours and checked my version much later.
Minimum compatibility visual studio version for .net Core 3.1 is Visual Studio 2019 (v16.4). I updated it and it worked.
Release update:
https://dotnet.microsoft.com/download/dotnet-core/3.1
For me, it was an environment variable. Not sure what set it (maybe some lame chocolatey package or something.)
I had environment variable MSBuildSDKsPath set as C:\Program Files\dotnet\sdk\2.0.3\Sdks
Removing that environment variable fixed the issue for me. (Actually, I renamed the environment variable to OLD_MSBuildSDKsPath, just in case ;) )
I was having vs 17 vs 19 both
I was trying to open code developed in visual studio 2019 into 2017.
Opening that project in VS 19 solved the issue for me
I am using VS 2022 and have a parallel installation of VS 2019 on my PC.
And I noticed that .NET 3.1 SDK (LTS) had to be installed (both 32 and 64 bit packages) to support an existing EF code first project (running with EF 3.x). Without it, the migration did not work and I got an error message like the one mentioned in the question.
Note that they can be installed in parallel with other versions (I have .NET 5 and .NET 6 on my PC installed as well).
You can find the required packages here: https://aka.ms/dotnet-download

Unable to install Nuget package in my Xamarin Cross Platform Application

I am developing a xamarin cross platform that is composed of following projects
1)Portable
2)IOS
3)Android
4)UWP
I am facing an issue while installing NuGet package for the xamarin portable project. Actually the NuGet that i am trying to install is targeted on .net Framework version 4.5.2. So we need the .net Version 4.5.2 or higher in our application in order to install this library. However when i try to change target framework version in my project properties to 4.6 then also i am facing the compatibility error that given package is not compatible with .net 4.5.
So what is the correct way that to set the .Net framework version in the project so that i can install it any project.
I have also referred to this doc by Microsoft
https://learn.microsoft.com/en-gb/dotnet/standard/net-standard#comparison-to-portable-class-libraries
that shows compatibility matrix.
I think it is related to .net standard 2.0. use these links
https://xamarinhelp.com/upgrade-pcl-net-standard-class-library/
https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-standard-2-0/

Need to build Roslyn Analyzer targeting .NET Standard \ Core rather than .NET Portable

I'm using default Roslyn SDK templates that came with Visual Studio 2017. The projects they create target .NET Framework Portable. I'm assuming Roslyn extensibility projects can target .NET Standard \ Core instead of Portable and I'm looking for templates or a sample of Roslyn Analyzer \ Refactoring project that I could study.
Sample of converted analyzer from default analyzer template is available here. There is original analyzer for comparison along with TestAnalyzerStandard which targets .NET standard.
Steps to make it work:
Create new .NET Standard library
Library must target .NET Standard 1.3. This is required if you wish to run analyzer as extension inside VS (extensions target .NET 4.6). Mapping between standard versions and full framework versions is available here. Also if you try to target lower version than 1.3, you will not be able to include required analyzer packages.
Add nuget package for Microsoft.Composition latest version. This is needed by Microsoft.CodeAnalysis.CSharp.Workspaces. If you try to add workspaces first, you will get error that referenced composition package is not compatible.
Add nuget package for Microsoft.CodeAnalysis.CSharp (I'm using latest 1.* version)
Add nuget package for Microsoft.CodeAnalysis.Csharp.Workspaces (version should match the version of Microsoft.CodeAnalysis.CSharp).
At this point you can copy code from portable project and build it. There should be no errors (you may have to close and reopen solution if VS is still displaying red squiggles).
To make VS extension work, just open source.extension.vsixmanifest, go to assets tab and change reference to .NET standard library
To create .nuget package just execute nuget pack Diagnostic.nuspec .. Diagnostic.nuspec is valid for Nuget 2.x. If you are using nuget via package management console in VS 2017 you will have to change <file src="*.dll" ..." to <file src="bin\*\netstandard1.3\*.dll" ....
Those steps are result of my experimentation with analyzers (I previously played with creating DLL which targeted full framework instead of being portable library). They are not by any means official.
I started working on a new Roslyn project and built things one by one instead of using template. https://github.com/IKoshelev/Roslyn.AutoLogging/commit/1f88e3e49141e0fa425c51fdcb3457a7c3d6dcaa
I managed to have the following targeting:
Refactoring project - .NET Standard 1.3 (this .dll will be distributed, version kept to minimum)
UnitTests project - .NET Core 2.0
VSIX project - .NET Framework 4.6 (I believe, only full Visual Studio supports VSIX, so that is okay)
Update Versioning of Roslyn is a bit more complicated right now, i.e. if you want to use your extensions with Visual Studio 2015 you will have to use PCL libraries. More info at the end of this article article on Roslyn

Using SQLite with Xamarin.Forms cross-platform project

I have used Visual Studio 2017 Community edition to create a plain vanilla cross platform PCL project, and would like to use SQLite. The only thing done to the project(s) was the use of Nuget to update all packages that needed updating.
Then, following the instructions on the Xamarin website at
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/
I used Nuget to install sqlite-net-pcl,
It all seemed to work OK, except at the end the following error appears.
I presume the documentation is slightly dated. Should I change the target .NET framework. If so, to what?
As of v1.3 SQLite-Net-PCL is actually no longer a PCL, it is a .Net standard library.
You need to install version 1.2.0 of the NuGet package to use it inside a PCL - from the nuget package manager you can select a version so install v1.2.0 into all your projects.
The library above worked OK as a PCL library, but what I disliked was that the platforms were split out in to separate DLLs so you had a different dependency for each platform.
This library is for .NET Standard and only has a single DLL for all platforms:
https://github.com/MelbourneDeveloper/SQLite.Net.Standard
It does not support the ORM like functionality in the above library though.

Error installing System.IdentityModel.Token.Jwt in Xamarin.Forms

I'm trying to use the System.IdentityModel.Token.Jwt NuGet package for my Xamarin.Forms app. When I try to add the package to my PCL, it installs in my Android and iOS projects, but I get the following error when adding it to the shared code project:
Could not install package 'System.IdentityModel.Tokens.Jwt 5.1.3'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile44', 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.
Does anyone know how to get around this? I think it has to do with what my project targets but I've tried a few combinations and all of them have produced the same error, just with a different profile listed.
Unfortunately the System.IdentityModel.Tokens.Jwt 5.1.3 NuGet package only contains assemblies that support:
.NET Framework 4.5.1
.NET Standard 1.4
No portable class library profile supports .NET Standard 1.4. The highest they support is .NET Standard 1.2.
So unless you can find another NuGet package that does support portable class libraries you are left with trying to compile the Jwt source code for the portable class library profile you need, or converting your portable class library project into a .NET Standard project and target at least 1.4. You should be able to convert your portable class library project into a .NET Standard project in the project options.

Resources