Using the new Package Reference syntax in F# scripts - .net-core

According to this Microsoft blog post section, Package references in F# scripts
, I should be able to use the following syntax in an fsx script:
#r "nuget: FSharp.Data"
Unfortunately, the compiler gives me the following error:
The package management feature requires language version 5.0 use /langversion:preview F# Compiler(3302)
I believe I have dotnet.core 5.0 installed correctly:
dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829
Runtime Environment:
OS Name: Mac OS X
OS Version: 11.0
OS Platform: Darwin
RID: osx.11.0-x64
Base Path: /usr/local/share/dotnet/sdk/5.0.100/
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
5.0.100-rc.1.20452.10 [/usr/local/share/dotnet/sdk]
5.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-downloa
How can I get this working correctly? Currently, the fsx script inside a dotnet core solution if that makes any difference. I'm using vscode with the ionide plugin to write F#.

Ionide doesn't yet support F#5.

As Isaac Abraham pointed out in his answer, the Ionide vscode package, at the time of this post, doesn't support F# 5.0 quite yet. However, the Ionide package helpfully does give the user the ability to enable a preview of F# 5.0 language features.
I fixed this compiler error by opening up the User's settings.json file and adding the following lines:
"FSharp.fsiExtraParameters": [
"--langversion:preview"
]

Related

.net core packages and dependency to the .net runtimes

Assuming I'm already using the NuGet Package
Microsoft.AspNetCore.Components 5.0.3
Can I upgrade it to 5.0.5 without having the 5.0.5 runtime installed (dotnet --list-runtimes)?
If I look at the dependencies in Nuget it just states:
net5.0 (no specific sdk, nor runtime)
-> Microsoft.AspNetCore.Components.Analyzers (>= 5.0.5)
-> Microsoft.AspNetCore.Authorization (>= 5.0.5)
Is there a specific reason to upgrade to 5.0.5 from 5.0.3? If its because you need something specific added in 5.0.5, then, while it might work, chances are it wont, as Andy says

Unable to find package Microsoft.NETCore.App with version (>= 3.1.0)

I have .NET Core SDK 3.1.200 installed on my local machine.
I create a Asp.Net Core app (using Visual Studio) targeting netcoreapp3.1. I test it and it works fine.
But when I commit it to CI the build fails to get the nuget package:
##[error]The nuget command failed with exit code(1) and error(NU1102: Unable to find package Microsoft.NETCore.App with version (>= 3.1.0)
- Found 81 version(s) in MyGet [ Nearest version: 3.0.0-preview8-28405-07 ]
- Found 73 version(s) in NuGet [ Nearest version: 2.2.8 ]
.NET Core 3.1 was released in December 2019 so why is the package not on nuget?
What am I missing?
Update
The CI is Azure Devops Pilelines and the agents are Windows machines that have Visual Studio 2017 installed. .Net core sdk 3.1 is not installed on the agents
Method 1:
Add the following task in your yaml
steps:
- task: UseDotNet#2
displayName: 'Use .Net Core sdk 3.1.x'
inputs:
version: 3.1.x
Method 2:
If using template editor, add Use .Net Core task and provide the version over there
Note: Make sure this should be the first task of the pipeline configured

Unit tests work in Resharper but not MSTests

We recently moved to .NET Core 3.1, and then back to 2.2 until we could update some dependencies that did not work under 3.1. After this, tests in MS Test would not run due to the reason below.
[1/2/2020 1:32:44.790 PM] ---------- Discovery started ----------
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.2.0' was not found.
- The following frameworks were found:
3.0.1 at [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
3.1.0 at [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.2.0&arch=x86&rid=win10-x86
. Please check the diagnostic logs for more information.
The tests run in Resharper.
I reinstalled .NET Core 2.2.8 SDK from here but that did not help. After installation I noticed that C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App did not have a folder for 2.2.8.
How do I get the tests to run in MS Test and/or get that folder populated (and why wasn't it populated after installing that version for that matter)?

Combine Microsoft nuget with lower dotnet core version

I have a dotnet core 2.1 lts docker image and I need to have a timestamp in the log. The Microsoft.Extensions.Logging preview for dotnet core 3.0 has this feature. Of course this package will not have long term support.
Can I combine a nuget package, which share the version of dotnet core, with a lower version of the dotnet core framework or does that result into in unsupported setup?
You didn't specify what your applications uses, so I need to write a somewhat generic answer.
The package Microsoft.Extensions.Logging targets netstandard 2.0, which means it will work on dotnet core 2.1
This issue you will have, is that it will force the dependencies it uses to upgrade too:
Microsoft.Extensions.Configuration.Binder (>= 3.0.0-preview4.19216.2)
Microsoft.Extensions.DependencyInjection (>= 3.0.0-preview4.19216.2)
Microsoft.Extensions.Logging.Abstractions (>= 3.0.0-preview4.19216.2)
Microsoft.Extensions.Options (>= 3.0.0-preview4.19216.2)
And those have dependencies too... in the end it might upgrade quite a lot of your project dependencies with packages which are in preview. (thus not supported)
I would not advice you to do this, but in the end it simply depends on what functionality you are using in your application. If only your code depends on the Microsoft.Extensions.Logging functionality you should be okay, although currently not supported. As soon as you use other packages which use one of the upgrade Microsoft.Extensions package the major version change should tell you that this might cause issues.

Cloudfoundry buildpack .net version error

When I deploy my .net core 2.1.0 project, I get the following error:
-----> Installing dotnet-framework 2.0.3
**ERROR** DEPENDENCY MISSING IN MANIFEST:
Version 2.0.3 of dependency dotnet-framework is not supported by this buildpack.
The versions of dotnet-framework supported in this buildpack are:
- 1.0.5
- 1.0.10
- 1.0.11
- 1.1.2
- 1.1.7
- 1.1.8
- 2.0.0
- 2.0.7
- 2.1.0
All solutions in my project is targeting the .net core framework 2.1.0, so I don't understand why this is.
I have dependencies in my project, and some of the them, like NETStandard.Library and Microsoft.NETCore.DotNetAppHost, are version 2.0.3, but does that really matter? (Also I don't think a version higher than 2.0.3 exist of NetStandard.Library.)
The project runs fine on my local machine, and ran fine on the host before we upgraded the buildpack and target .net framework, as well as various dependencies through NuGet.
Here is the full log:
https://1drv.ms/t/s!Ar81AKlFywcPhapTJdjZEnrcGrZS4A
You can try to pin the RuntimeFrameworkVersion to a specific one:
<RuntimeFrameworkVersion>2.0.7</RuntimeFrameworkVersion>

Resources