I have a Xamarin Forms solution, containing several F# portable class libraries.
In order to use the latest version (4.0.0) of Microsoft.Azure.MobileClient, I need to upgrade to FSharp.Core 4.2.1, but this appears to be incompatible with Profile 78:
Could not install package 'FSharp.Core 4.2.1'. You are trying to
install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile78', 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.
It is possible to use .NET Standard class libraries from Xamarin projects, but is it possible to create a .NET Standard class library in F#?
What is the best way forward here?
What the error message is telling you is that the project is targeting a PCL target. FSharp.Core 4.2.x does not have a PCL target anymore, and only contains .NET Framework and .NET Standard 1.6 binaries. Neither is compatible with the PCL target F# is using here.
The release notes for FSharp.Core were recently updated with developer guidance: https://www.nuget.org/packages/FSharp.Core/
This is the important bit for your project:
For existing packages targeting .NET Frameworks 4.0 or lower and PCLs, use FSharp.Core 4.1 or lower.
.NET Standard (as of this time) has not proliferated across all things .NET yet. As #Foole says, you can indeed create a .NET Standard class library with F# today. But it's not compatible with the rest of the .NET ecosystem until .NET Standard is fully supported on all flavors of .NET.
You can try to convert your Xamarin.Forms (and your F#) project from .NET Portable to .NET Standard 2.0, since both packages can be added to .NET Standard.
How to convert Xamarin.Forms to .NET Standard
Create new Xamarin.Forms project (skip for already created project)
Create new .NET Standard library project in the same solution
Add reference to Xamarin.Forms package
Copy your content from Xamarin.Forms shared project to the new library project
Change all references (from Android, iOS, UWP) to point to the library project instead of the shared project
Source: Xamarin Blog
Related
I am trying to build a .NET 4.8 Class Library that I can make COM-Visible as a support library from an Access application.
There are no prompts for the version of .NET Framework when I create the solution.
When I look at the Project Properties, the .NET Framework is set to 5.0.
Although I have the .NET Framework 4.8 installed, it does not appear in the combo-box for the Target framework. The only options are shown below.
I have also noticed that the Startup object combobox does not reflect the selected startup assembly.
Do I need to drop back to Visual Studio 2017 to create a .NET Framework 4.8 library?
Which SDK is installed?
If you only have the .net 5 SDK installed, it might suffice for making a .net core 3 app but it will not cover .net Framework.
Install the .net Framework SDK for the version you want to target.
And/or install a targeting pack if you want to target .net 4.8 and 4.7.2 for example.
(Maybe helpful: What's the difference between the .NET Framework SDK and the Targeting pack)
This happened to me because I had choosen the wrong kind of project.
I had choosen a project library for C#, Windows Linux, macOS.
By this the same thing, that one could only had .NET 5.0 and higher as Framework.
I had to create a new library project with only C# and Windows.
Than I could choose all installed .NET frameworks
I've seen this question asked for C# projects but not F#.
I have a solution that is composed of multiple C# and F# projects all using framework .NET Framework 4.7.2. I've been trying to upgrade them to .NET 5 and used the Microsoft tools to do this, the .NET API Analyzer and the .NET Upgrade assistant.
I've had no problems with the C# projects (aside from some third party dependency issues), all are now upgraded but the .NET Upgrade assistant did not touch the F# projects when I ran it against the solution and won't recognise their file type .fsproj when I try to run it against them separately. So I now have a solution containing multiple frameworks which of course throws the error
"This project target a different framework"
My question is, has anyone upgraded F# projects to .NET 5? Do you have any advice on how to do this? Are there any tools to do this? I've been searching all day and have not been able to find any advice, guidance or any tools, only information around creating new F# projects but not upgrading existing ones.
My solution
I ended up using the try-convert instead of the Upgrade Assistant and that worked. I almost went with manually recreating the projects which I am sure would have worked also.
I am trying (unsuccessfully) to create a Console Application that targets .Net 5.0 so that I can use C# Version 9.0.
Although I have installed the .Net 5.0 I am unable to select it when creating a project.
I would like to use some of the new features of C# 9 but this requires version 5.0 of .Net as I understand it.
I am using Visual Studio 2019 Version 16.8.3
Thanks
Right click on the csproj and make sure it looks like this:
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net5.0</TargetFrameworks>
...
</PropertyGroup>
If you don't see .NET 5 in the Target Frameworks for a .NET Core Application, you don't have the installation correct. Here's what mine looks like
C# 9 is only available on .NET 5 (which is .NET Core not .NET Framework).
C# 9.0 is supported only on .NET 5 and newer versions.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version
.NET 5.0 is the next major release of .NET Core following 3.1. We
named this new release .NET 5.0 instead of .NET Core 4.0 for two
reasons:
We skipped version numbers 4.x to avoid confusion with .NET Framework
4.x.
We dropped "Core" from the name to emphasize that this is the main implementation of .NET going forward. .NET 5.0 supports more
types of apps and more platforms than .NET Core or .NET Framework.
https://learn.microsoft.com/en-us/dotnet/core/dotnet-five
I installed nuget package: EntityFramework 6 in .NET Standard2.0 Class library. On building the project I am getting the below warning message:
NU1701:Package 'EntityFramework 6.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Does it mean that we cannot use EntityFramework 6 in .NETStandard 2.0 class library?
Can anyone help me here by providing their inputs
[...]. This package may not be fully compatible with your project.
Entity Framework 6 will be compatible with a project that target .NET Framework but will not be compatible with a project that target .NET Core
The answer is yes, you can use EF6 with .NET Standard 2.0 class library as long as you plan to only support .NET Framework
Microsoft already announced they plan to release a version of EF6 that support .NET Core at the end of 2019.
Disclaimer: I'm the owner of the project Entity Framework Classic
Entity Framework Classic is an EF6 fork. It's everything you like about EF6, but with better performance, must-have features, .NET Core support, and more.
It's currently the only option available to use a EF6 fork on a project that target NET Core
There is a free Community version that includes pretty much everything and an Enterprise version that include additional features.
I am trying to determine/understand if I need to reference the .Net 3.5 library in Xamarin for iOS projects.
Each time I open up a solution that contains a MonoTouch project for iOS I am prompted to include the .NET Framework 3.5. I would prefer not to intall this if possible. I can see that some of the Cirrious.MvvmCross dlls such as Cirrious.MvvmCross.Binding.Touch are dependent upon Runtime Version of v2.0.50727 - and I guess this is why it is probably prompting me. However, I can quite happily ignore the reference and it will work.
I would like to know what I can't do if I don't include the .Net 3.5 (2.n etc) so that I can safely ignore the dependency.
Secondly - if I can ignore this dependency - how do I go about this?
Thanks
Alan.