Are F# Anonymous Records not supported with .NET Core SDK 2.2.108 in Linux? - linux

I am using linux (Manjaro) and .NET Core 2.2.108 and seems the F# anonymous records are not supported while it is indicated that it is the case for example here
now available with .NET Core 2.2
I have the following F# dummy project:
ConsoleApp.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs"/>
</ItemGroup>
</Project>
Containing this file:
Program.fs:
[<EntryPoint>]
let main argv =
let a = {| A = "Michelle" |}
0
dotnet information:
$ dotnet --version
2.2.108
$ dotnet --list-runtimes
Microsoft.NETCore.App 2.2.6 [/opt/dotnet/shared/Microsoft.NETCore.App]
$ dotnet --list-sdks
2.2.108 [/opt/dotnet/sdk]
The compilation gives me:
$ dotnet build
Microsoft (R) Build Engine version 15.9.20.63311 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for /home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj...
Generating MSBuild file /home/perret/Desktop/ConsoleApp/ConsoleApp/obj/ConsoleApp.fsproj.nuget.g.props.
Restore completed in 172.04 ms for /home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj.
/home/perret/Desktop/ConsoleApp/ConsoleApp/Program.fs(3,14): error FS0010: Unexpected symbol '|' in expression [/home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj]
/home/perret/Desktop/ConsoleApp/ConsoleApp/Program.fs(3,13): error FS0604: Unmatched '{' [/home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj]
Build FAILED.
/home/perret/Desktop/ConsoleApp/ConsoleApp/Program.fs(3,14): error FS0010: Unexpected symbol '|' in expression [/home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj]
/home/perret/Desktop/ConsoleApp/ConsoleApp/Program.fs(3,13): error FS0604: Unmatched '{' [/home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj]
0 Warning(s)
2 Error(s)
Is it normal?
[EDIT]
I thought Rider did update FSharp.Core from 4.5.2 to 4.7.0 but in fact, not really:
$ sudo dotnet add ConsoleApp.fsproj package FSharp.Core -v 4.7.0
Writing /tmp/tmpBQmP0N.tmp
info : Adding PackageReference for package 'FSharp.Core' into project 'ConsoleApp.fsproj'.
log : Restoring packages for /home/perret/Desktop/ConsoleApp/ConsoleApp/ConsoleApp.fsproj...
info : Package 'FSharp.Core' is compatible with all the specified frameworks in project 'ConsoleApp.fsproj'.
error: Error while performing Update for package 'FSharp.Core'. Cannot edit items in imported files -
error: Item 'PackageReference' for 'FSharp.Core' in Imported file '/opt/dotnet/sdk/2.2.108/FSharp/Microsoft.FSharp.NetSdk.props'.

The main issue: the .NET Core SDK Version
#EhouarnPerret if I test it with dotnet sdk version 2.2.2xx, 2.2.3xx, 2.2.4xx, it works fine for me. If I change the sdk to 2.2.1xx, I get the same error as yrs.
Was partially the key.
I basically had to setup the last version available in AUR:
aspnet-runtime-preview 3.0.0+100+preview.013656-2
dotnet-host-preview 3.0.0+100+preview.013656-2
dotnet-runtime-preview 3.0.0+100+preview.013656-2
dotnet-sdk-preview 3.0.0+100+preview.013656-2
Otherwise I was stuck with the version provided in the community packages which are:
aspnet-runtime 2.2.6+108-1
dotnet-host 2.2.6+108-1
dotnet-runtime 2.2.6+108-1
dotnet-sdk 2.2.6+108-1
And there is nothing available between those two out of the box.
I also would like to point out that the version of the package didn't match the version of the SDK:
Package dotnet-sdk 2.2.6+108-1 => Actual .NET Core SDK version 2.2.108 [/opt/dotnet/sdk]
About How to update the FSharp.Core version?
By the way the issue I had about updating the FSharp.Core package to the right version came from this: https://github.com/dotnet/fsharp/issues/3656
Basically the fsproj needs to see:
<FSharpCoreImplicitPackageVersion>4.7.0</FSharpCoreImplicitPackageVersion> in <PropertyGroup>.
(With whatever version you want to have)
Updating the FSharp.Core with nuget explicitly does not work.
[EDIT]
Actually it does, it just needs a little thing, see here
<PackageReference Update="FSharp.Core" Version="4.7.0"/> is what you need to add in *.fsproj, otherwise the build will be confused about which FSharp.Core to reference. This is by design w.r.t how the SDK works.
So basically if you are using the udpate attribute like this here <PackageReference Update="FSharp.Core" Version="4.7.0"/> in <ItemGroup> it's also working.
I believe, this is actually much cleaner and standard than the previous approach.
If you don't any of those above, the version that would be used is the one "assigned" by default with the .NET Core SDK version.
| Arch Package | Actual SDK Version | Default `FSharp.Core` version |
| -----------------------------| ---------------------------- | ----------------------------- |
| `2.2.6+108-1` | `2.2.108` | `4.5.2` |
| `3.0.0+100+preview.013656-2` | `3.0.100-preview8-013656` | `4.6.2` |
So even with the package dotnet-sdk 2.2.6+108-1 and with the version 4.7.0 setup properly for FSharp.Core the anonymous records won't compile since they are part of the 4.6 language version which is not carried by the version of the SDK in that particular package version.
Does the referenced version of FSharp.Core really matter?
In conclusion I just needed to have a more recent version of the .NET Core, the version of FSharp.Core didn't really matter. As a matter of fact:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.5.0"/>
</ItemGroup>
</Project>
and a Program.fs like below:
[<EntryPoint>]
let main argv =
let a = {| Diameter = 10; Area = 10; Circumference = 10 |}
0
Still compile while referencing the version 4.5.0 of FSharp.Core.
It seems a bit weird considering that the F# version required for anonymous records is 4.6.0: https://github.com/fsharp/fslang-design/blob/master/FSharp-4.6/FS-1030-anonymous-records.md
Now is F# language version and FSharp.Core relate to the same thing?
Not really.

Related

How to fix: "ABI filter 'arm64-v8a' is no longer supported in NDK version x"

I'm setting up an android project from another company which involves selfmade C++ cross platform libraries. For an older version of these libraries an complete app project was made in java with a jni interface to access these libraries, which are stored as their own modules with gradle.build files. The goal is to get the app compiling for arm64-v8a architecture because of the Google requirements for app update.
The project is set up with:
gradle experimental plugin 0.11.0
gradle plugin 4.1
boost 1.64.0 for armeabi-v7a (got arm64-v8a precompiled libraries as replacement)
opencv 2.4.13.2
ndk r15c
I checked all dependencies for getting a arm64 pendant, which was only needed for the boost dependencies.
I tried changing the ABI list which is used for every project to include all architectures or all seperatly. I tried using other ndk versions. What might help but i didn't accomplish was changing the experimental gradle plugin to the normal plugin but i couldn't get that right.
I expected some compiling or linking errors but it only tells me "ABI filter 'arm64-v8a' is no longer supported in NDK version r15.2.4203891.". If i try other architectures i get the same error, but instead of the 'arm64-v8a' the current selected architecture. If i give an invalid architecture it changes to "Target ABI 'hello' is not supported.", so it recognizes the architecture i think.
Stacktrace of first error:
A problem occurred configuring project ':app'.
Exception thrown while executing model rule: NdkComponentModelPlugin.Rules#configureNativeLibrary(ModelMap, NdkConfig, NdkHandler, ModelMap, File, ServiceRegistry) > create(livestage) > withType()
Exception thrown while executing model rule: NdkComponentModelPlugin.Rules#configureNativeLibrary(ModelMap, NdkConfig, NdkHandler, ModelMap, File, ServiceRegistry) > create(lib-jni-cxx) > withType()
Exception thrown while executing model rule: NdkComponentModelPlugin.Rules#configureNativeBinary(BinaryContainer, ModelMap, NdkConfig, NdkHandler) > withType()
ABI filter 'arm64-v8a' is no longer supported in NDK version r15.2.4203891.
The experimental plugin hasn't been supported for years, so it's no surprise that it doesn't work. Migrate to externalNativeBuild: https://developer.android.com/studio/projects/add-native-code

Trouble building yesod/amazonka dependencies in a Haskell Stack project

I'm trying to use the excellent AWS SDK amazonka in the backend portion of an API built using the equally excellent web framework yesod, but I am having great difficulty getting the dependencies for these two libraries to work together.
I started the scaffolded yesod project with
stack new my-project yesod-mongo
which populated my cabal file with the most recent version of yesod (1.6.0). Naively adding the dependencies amazonka-core and amazonka-ssm (for example) to my cabal file comes back with
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for my-project-0.0.0:
amazonka-core must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
amazonka-ssm must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
needed since my-project is a build target.
As suggested, I tried adding amazonka-core-1.5.0 and amazonka-ssm-1.5.0 to my stack.yaml file under extra-deps, but this doesn't work:
Warning: WARNING: /home/ubuntu/my-project/my-project.cabal was modified manually.
Ignoring package.yaml in favor of cabal file. If you want to use package.yaml
instead of the cabal file, then please delete the cabal file.
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for amazonka-core-1.5.0:
conduit-1.3.0.2 from stack configuration does not match >=1.1 && <1.3 (latest
matching version is 1.2.13.1)
needed due to my-project-0.0.0 -> amazonka-core-1.5.0
After a bit of digging, it seems that the snapshot that the yesod template was built off of is lts-11.6, but the most recent snapshot that the amazonka library is included in is lts-10.9. So, I tried building the project again from the yesod-mongo template, but this time specifying an older snapshot:
ubuntu:~$ stack new my-project yesod-mongo --resolver lts-10.9
Downloading template "yesod-mongo" to create project "my-project" in my-project/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- my-project/
Selected resolver: lts-10.9
Resolver 'lts-10.9' does not have all the packages to match your requirements.
classy-prelude version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-conduit version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-yesod version 1.3.1 found
- my-project requires ==1.4.*
http-conduit version 2.2.4 found
- my-project requires ==2.3.*
persistent version 2.7.1 found
- my-project requires ==2.8.*
persistent-mongoDB version 2.6.0 found
- my-project requires ==2.8.*
yesod version 1.4.5 found
- my-project requires ==1.6.*
yesod-auth version 1.4.21 found
- my-project requires ==1.6.*
yesod-core version 1.4.37.3 found
- my-project requires ==1.6.*
yesod-form version 1.4.16 found
- my-project requires ==1.6.*
yesod-static version 1.5.3.1 found
- my-project requires ==1.6.*
Using package flags:
- my-project: dev = False, library-only = False
Now I am at a loss and more than a little frustrated. It seems like perhaps the template is ignoring the snapshot specification. So, my question:
Is there a way to build the scaffolded site from a template that uses a specific snapshot to fill in the cabal and stack.yaml files? Is there anything else I can do to get this to work?
Happy to provide more information if it's helpful.
Edit: I also tried bumping down the versions of the packages in the above snippet, and while this solves the issue of building dependencies, now the scaffolded site doesn't compile (presumably because things have changed in a meaningful way from yesod-1.4.5 to yesod-1.6.0).
Unfortunately you can't use Commercial Haskell's stack templates with yesod and amazonka as of now. The reasons being:
There was a recent conduit rewrite in version 1.3
Some breaking changes were introduced in recent Yesod 1.6 which depends on conduit >= 1.3
Amazonka doesn't work with recent version of conduit
The only way for you to get it working is switching back to old version of stack templates (those templates which actually worked with stackage resolver 10.9) and then using that to create a new project. Fortunately, Stack supports custom stack templates:
$ stack new my-project https://raw.githubusercontent.com/github-user-id/stack-templates/master/my-template.hsfiles

.NET Standard 2.0 Xamarin.iOS project VSTS build issue

Currently I'm trying to upgrade a Xamarin.Forms project to use .NET Standard 2.0. This went fine for Android but I'm getting stuck with the iOS version. To build iOS we use a On-Primise MacMini as build agent int VSTS. Now I'm getting the error below when building the solution.
=================================
.... way more erros like below ...
2017-11-21T11:39:43.8920830Z ViewModels/DashboardViewModel.cs(66,35): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [/Users/Admin/BuildAgent/_work/3/s/xxx.App/xxx.Core.csproj]
2017-11-21T11:39:43.9014700Z ViewModels/DashboardViewModel.cs(66,73): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [/Users/Admin/BuildAgent/_work/3/s/xxx.App/xxx.Core.csproj]
2017-11-21T11:39:43.9036150Z ViewModels/DashboardViewModel.cs(66,93): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [/Users/Admin/BuildAgent/_work/3/s/xxx.App/xxx.Core.csproj]
2017-11-21T11:39:43.9053280Z
2017-11-21T11:39:43.9083060Z 6 Warning(s)
2017-11-21T11:39:43.9107960Z 47 Error(s)
2017-11-21T11:39:43.9116100Z
2017-11-21T11:39:43.9131830Z Time Elapsed 00:00:59.23
2017-11-21T11:39:43.9327960Z ##[error]Xamarin.iOS task failed with error Error: /Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild failed with return code: 1. For guidance on setting up the build definition, see https://go.microsoft.com/fwlink/?LinkId=760847.
2017-11-21T11:39:43.9575950Z [command]/usr/bin/security delete-keychain /Users/Admin/BuildAgent/_work/3/s/_xamariniostasktmp.keychain
2017-11-21T11:39:44.2658340Z ##[section]Finishing: Build Xamarin.iOS solution xxx.sln
=================================
This output comes from the following build definition:
Now I've searched the internet and found a view possible solutions:
Update Visual Studio on the MacMini
Update XCode on the MacMini
Install .NET Core 2.x SDK on the MacMini
Add .NET Standard 2.x NuGet package to Xamarin.IOS project
Add .NET Standard Library NuGet pre-release package to Xamarin.iOS project (not possible)
Manually reference netstandard.dll to the Xamarin.iOS project
Remove install argument (not using it)
But all of this was not enough to fix the issue. Now I'm not a expert in using a Mac. Actually I never touched one before this issue... So I might have done something wrong here...
But I've been able to get some version information about all products on the MacMini:
========= Visual Studio =========
Visual Studio Community 2017 for Mac
Version 7.2.2 (build 11)
Installation UUID: b43353ef-651c-468b-8b7d-3f1714586419
Runtime:
Mono 5.4.1.6 (2017-06/1f4613aa1ac) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 504010006
NuGet
Version: 4.3.1.4445
.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.3
SDK: /usr/local/share/dotnet/sdk/2.0.3/Sdks
SDK Version: 2.0.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks
Xamarin.Profiler
Version: 1.5.6
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Xamarin.Android
Not Installed
Xamarin Inspector
Not Installed
Apple Developer Tools
Xcode 9.1 (13532)
Build 9B55
Xamarin.iOS
Version: 11.3.0.47 (Visual Studio Community)
Hash: 51128b8c
Branch: xcode9.1
Build date: 2017-10-31 22:42:13-0400
Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.
Build Information
Release ID: 702020011
Git revision: b604c37c5a4a2f0919b45ffbe2aaad9fe040af31
Build date: 2017-11-01 08:31:43-04
Xamarin addins: d57dc14cbd4eb166ee62bab585965ab78d3650bc
Build lane: monodevelop-lion-d15-4
Operating System
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Wed Oct 4 00:17:00 PDT 2017
root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
============= XCode =============
XCode for Mac
Version 9.1 (9B55)
============= Mono ==============
Mono JIT compiler version 5.4.1.6 (2017-06/1f4613aa1ac Wed Oct 18 09:31:57 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-master/8b1520c8aae)
GC: sgen (concurrent by default)
========= .NET Core SDK =========
.NET Core SDK
Version 2.0.3
=================================
The project can be build on the MacMini itself. Only the VSTS task keeps failing...
Does someone have any idea's left which can help me solve my issue?
Kind regards,
Jop
Everything started to work fine after we manually edited the .NET Standard 2.0 project file (*.csproj) and add a PackageReference by hand.
<ItemGroup>
...
<PackageReference Include="NETStandard.Library" version="2.0.0" />
...
</ItemGroup>

Unresolved assembly reference with sandcastle

I am trying to generate documentation with sandcastle help file builder. While building the project in the sandcastle i am getting the following error.
MRefBuilder : error : Unresolved assembly reference: Microsoft.Owin (Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) required by Microsoft.AspNet.Identity.Owin [C:\Users\inkosah\Documents\Help\Working\GenerateRefInfo.proj]
Last step completed in 00:01:19.4610
Can anybody help me to resolve this issue? I also tried adding it separately to project references in the sandcastle but no help.
Solution 1 : Add missing references to a dummy project.
Create 'dummyProject' (ie class library)
In Visual Studio - Package Manager Console
Install-Package Microsoft.Owin -Version 2.1.0.0 -ProjectName dummyProject
Install-Package Microsoft.Owin.Security.OAuth -version 2.1.0.0 -ProjectName dummyProject
In Sandcastle Help Fil Builder - Project Explore, add two references
Microsoft.aspNet.identity.Owin (dll found in ..\packages\Microsoft.AspNet.Identity.Owin.2.2.0\lib\net45)
Microsoft.Owin (dll found in ..\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll)
It looks like MRefBuilder found that Microsoft.AspNet.Identity.Owin relies on Microsoft.Owin (== v 2.1.0) and not Microsoft.Owin (>= 2.1.0).
The main project is still using Microsoft.Owin 3.0.1.0
Solution 2 : Ignore unresolved references
In Documentation (or SHFB) Project Properties / Plug-Ins :
Add "Assembly Binding Redirection" in "Plugs-Ins in This Project"
configure it to "ignore if Unresolved" "Microsoft.Owin" and "Microsoft.Owin.Security.OAuth"

How to get C# 4.0 in Mono (in xbuild)?

I have a .NET project which uses msbuild that I want to try building in Mono. I can build some of its trivial targets just fine, but if I try the full compilation it fails.
I'm not sure how much of the output is relevant, but these are the first lines that look like trouble:
Target GetFrameworkPaths:
/usr/lib/mono/3.5/Microsoft.Common.targets: warning : TargetFrameworkVersion 'v4.0' not supported by this toolset (ToolsVersion: 4.0).
and
Target ResolveAssemblyReferences:
/usr/lib/mono/3.5/Microsoft.Common.targets: warning : Reference 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
and
/usr/lib/mono/3.5/Microsoft.CSharp.targets: error : Error executing tool '/usr/bin/dmcs': ApplicationName='/usr/bin/dmcs', CommandLine='/noconfig #/tmp/tmp4749932e.tmp', CurrentDirectory='/home/ken/foo/bar'
Task "Csc" execution -- FAILED
I'm running latest Debian unstable. According to this, "dmcs" is the 4.0 compiler. I've not used Mono/xbuild much at all -- is there something special it needs in order to compile a C# 4.0 project? Thanks!
Sid still has Mono 2.6, you probably need Mono 2.10 (available in experimental).

Resources