Starting with F# 4.5, the match! keyword allows you to inline a call to another computation expression and pattern match on its result
As far as I can tell, I am using F# 4.5.
However, VS2017 does not like the following code
let someAsyncIntOption = async{
return Some 1
}
let someAsyncString = async{
match! someAsyncIntOption with
|Some 1 -> return "Some one"
|_ -> return "None"
}
match! is not recognized as valid syntax.
What do I need to do to make this work?
F# 4.5 was released in VS 2017 v15.8 preview 5. It's not enough to target the F# 4.5 runtime; you also have to have the F# 4.5 compiler in order for that syntax to be accepted. And the F# 4.5 compiler comes with VS 15.8 preview 5; if you're running a Visual Studio version older than 15.8 preview 5, then you have an older F# compiler that doesn't know about the match! syntax.
According to...
https://blogs.msdn.microsoft.com/dotnet/2018/07/26/announcing-f-4-5-preview/
If you haven't already...
First, install:
A preview of the .NET SDK 2.1.400 to ensure you have the latest bits for for F# in .NET Core
Visual Studio 2017 update 15.8 Preview 5 if you are on Windows
If you create a .NET desktop F# project in Visual Studio (from the F# desktop development component), then you will need to update your FSharp.Core package to 4.5.2 with the NuGet UI.
Once you have installed the necessary bits, you can start developing F# 4.5 code with Visual Studio, Visual Studio for Mac, or Visual Studio Code with Ionide.
When .NET Core SDK 2.1.400 and Visual Studio 2017 version 15.8 are released, the referenced FSharp.Core will be 4.5.2 for all new projects and you will not need to perform this second step.
It may be that you need to be targeting .NET Core for this to work and only after updating your FSharp.Core package to 4.5.2.
I haven't tried any of this, but hope that helps.
Related
I have Visual Studio 2019 updated to the latest current version of 16.18.4 (see screenshot), the .NET 5.0 is installed (see screenshot made in visual studio installer) and yet when creating new projects or then changing
target framework, the .NET 5.0 framework is not available. In the about box Visual Studio displayed .NET 4.8, not .NET 5.0.
To help anyone else who might face a moment of confusion as I did, the following allows creating a .NET Framework Windows Forms project
while the following allows targeting either .NET Core 3.1 or the newer .NET 5.0
and, as said, you can't simply set from VS a .NET Framework project to target the new .NET 5.0.
I just installed the .Net Core 3.0 SDK (both 64 and 32 bit version) and yet, the .Net Standard 2.1 Targeting Pack is not shown in Visual Studio's list. It is going up until 2.0 only. What am I doing wrong?
Apologizing. The problem is that I had to update visual studio.
Interestingly enough, I had Visual Studio open for several hours, and even though an update existed, it didn't prompt me to update, leaving me with the impression that it was already in the most recent version.
I had to run Visual Studio Installer manually to request for an update
I have a extension which adds custom project template which is displayed under Installed -> Visual C# -> < type> in visual studio 2017.
but when i am using same extension in Visual studio 2019, on searching i get the template but without any label (like language, platform and project type).
and even if i select language filter in the wizard, i don't see the template in C#.
if any one can help, how to add language, platform, project type tag to the template.
Thanks
This is a VS 2019 issue. It has now been solved in visual studio 2019 version 16.1 Preview 2. However it has no backwards compatibility with previous visual studio versions.
For more information about the bug see: https://developercommunity.visualstudio.com/idea/422666/allow-custom-project-templates-for-custom-language.html
See https://learn.microsoft.com/en-us/visualstudio/ide/template-tags?view=vs-2019 for adding tags in visual studio 2019 Version > version 16.1 preview 2.
I am building an F# console application with Visual Studio 2013 Ultimate. The target framework is .Net 4.5
The version of FSharp.Core installed on my computer (presumably by installing VS 2013) is 4.3.1.0.
On NuGet there are two versions of FSharp.Core, 4.0.0 published April 12, 2012 and one with an ID of Fsharp.Core.3 verison 0.0.2 published March 5, 2013.
I am looking for guidance as to when one should use each of these versions, the version numbering is confusing me and I would have expected to find the latest production release on NuGet.
Am I missing something?
You should not be obtaining FSharp.Core from nuget. Microsoft does not publish any official F# bits to nuget today (though this could potentially change in the future). It's common for 3rd-party packages to bundle FSharp.Core (since presumably that's the version used for testing/validation of that 3rd-party component), but nuget should not currently be used as a mechanism for getting FSharp.Core updates or new versions.
The versioning story for FSharp.Core is sadly rather complex, and definitely not as simple as "higher version means newer." A key thing to realize is that there are 2 axes - what F# version does the runtime support, and what .NET framework version/profile does it target.
Below are the official FSharp.Core versions that ship with VS 2013 (find these dropped under %ProgramFiles(x86)%\Reference Assemblies\Microsoft\FSharp).
4.3.1.0 (F# 3.1/.NET 4) This is the most recent official version. Unless you have a requirement to target .NET 2, or you are using some legacy F# component that won't work with 3.1, this is the version you should use for any new desktop app.
4.3.0.0 (F# 3.0/.NET 4) These are the same bits that shipped with VS 2012. It is included so that you can continue working on F# 3.0 projects in VS 2013 without retargeting them to 3.1. You should use this if you have a legacy F# 3.0 desktop project that you are not ready to move to 3.1 yet.
2.3.0.0 (F# 3.0/.NET 2) These are the same bits that shipped with VS 2012. The only reason to use this is if you are targeting .NET 2. The .NET 2 side of things is not being developed further, btw - new features, versions, etc will be done for FSharp.Core targeting .NET 4+; the .NET 2 FSharp.Core is still fully supported, but it is frozen.
3.3.1.0 (F# 3.1/"Portable") This version targets .NET portable profile 7 (.NET 4.5/Windows Store). Use this if you are creating a component for a Windows store app and you don't care about Silverlight. This profile is newly supported in VS 2013.
2.3.5.1 (F# 3.1/"Portable (Legacy)") This version targets .NET portable profile 47 (.NET 4/Silverlight 5/Windows Store). Use this if you are creating a Silverlight component. This profile was also supported in VS 2012, and referred to at that time as simply "Portable."
2.3.5.0 (F# 3.0/"Portable (Legacy)") This version targets .NET portable profile 47 (.NET 4/Silverlight 5/Windows Store). These are the same bits that were included in VS 2012. Included in VS 2013 to enable you to continue working on F# 3.0 portable/silverlight projects.
.NET portable profiles are a big PITA and cause a ton of complexity. This site has a good summary to help understand: http://blog.stephencleary.com/2012/05/framework-profiles-in-net.html
So for your specific scenario (new console app) use 4.3.1.0.
Edit 7/2015:
Here's a table that probably explains the story better than the wall of text above. I've tried to use colors to indicate the motivation for the version numbers. You'll see the versioning of the portable libraries was a bit ad hoc and inconsistent in VS 2012 and 2013, but is finally consistent and predictable starting with VS 2015. This is up to date with F# 4.0, which just released.
Today I would probably rather follow these guidelines
In short, you can/should reference FSharp.Core from NuGet
I know I can download the "April CTP" to get F# 2.0 for .NET 2.0. But I need FSC and F# Interactive for .NET 4.0. On a machine with VS 2010 installed, it ends up in C:\Program Files (x86)\Microsoft F#\v4.0. Is there a redistributable for this?
If you installed Visual Studio 11 Beta or Visual Studio 2012, I recommend you check the following path, where you will find Fsi.exe and Fsc.exe.
C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0
Others have provided good answers; I'll summarize and add one more bit (2nd bullet):
We don't have any polished story here yet. We're working on one.
In the case of the compiler, you may be able to get by with the fsc.exe in the April CTP (it is capable of referencing .NET 4.0 assemblies and building .NET 4.0 assemblies, even though the compiler itself runs on 2.0). (Note that for building project files, you might also need the right Microsoft.FSharp.targets imported; I haven't worked all that through...)
If you were to copy the right assemblies and targets files from a VS2010 install to another machine, that would work, but offhand I don't know if that violates the VS license.
The existing downloadable "redist" does only contain FSharp.Core.dll.
(possibly see also this for a similar discussion but no extra info, as well as this Connect request)
The redistributable, for the F# runtime, is available at the following link, but unfortunately doesn't include the compiler or F# interactive:
http://www.microsoft.com/downloads/details.aspx?FamilyID=5f0a79f8-925f-4297-9ae2-86e2fdcff33c&displaylang=en
If you already have VS2010 installed on the machine there shouldn't be no need to install it, as the compiler, fsi, and F# runtime will be installed with VS. It should be just a matter of adding the directory containing the compiler to the path, so the shell can find it (if you want to use the compiler/fsc from the command-line).
This is an old question, but I came across it and thought that I'd add an update for people who find it through Google:
The current version of the F# CTP (April 2011) includes both .NET 2.0 and .NET 4.0 binaries, including FSI.exe. On my install...
.NET 2 = C:\Program Files (x86)\FSharp-2.0.0.0\bin\
.NET 4 = C:\Program Files (x86)\FSharp-2.0.0.0\v4.0\bin\
I think that there is no standalone installation of F# for .NET 4.0 (similar to the standalone installation for .NET 2.0). The reason probably is that F# for .NET 4.0 is simply meant to be distributed only as part of Visual Studio 2010 and not separately (just like other core Visual Studio languages).
If you need to use fsi.exe and fsc.exe for .NET 4.0 on a machine that doesn't have Visual Studio installed, you'll probably need to copy them together with the referenced libraries. This shouldn't be that difficult - you only need assemblies from "C:\Program Files (x86)\Microsoft F#\v4.0" together with FSharp.Core.dll (which should be added to the GAC) and (I think) also ISymWrapper.dll (but I'm not quite sure where this is located).