From e4725e37a4fffa1f17cdcdc69c2ca2329d49b055 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 20 Aug 2020 10:30:58 -0500 Subject: [PATCH] [build] support for .NET 5.0+ Trying to build an F# project under .NET 5 fails with: error FS3053 : The type provider 'Xamarin.Android.FSharp.ResourceProvider' reported an error : The type provider constructor has thrown an exception: Could not load file or assembly 'System.CodeDom, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. We need this library to target `netstandard2.0`, so it will work on .NET framework, Mono, and .NET Core (.NET 5+). I reworked `Xamarin.Android.FSharp.ResourceProvider.fsproj` to be `netstandard2.0`. This created a new issue when I tried to *use* the package in a .NET 5 project: Foo.Android.fsproj : error NU1202: Package Xamarin.Android.FSharp.ResourceProvider 1.0.0.29 is not compatible with net5.0 (net5.0). Package Xamarin.Android.FSharp.ResourceProvider 1.0.0.29 supports: Foo.Android.fsproj : error NU1202: - monoandroid81 (MonoAndroid,Version=v8.1) Foo.Android.fsproj : error NU1202: - netstandard2.0 (.NETStandard,Version=v2.0) .NET 5.0 seems to prefer `netstandard2.0` over `monoandroid81`, and so it doesn't know what to do here: hence the error. I literally, could run this command on the package and it works afterward: zip -d Xamarin.Android.FSharp.ResourceProvider.1.0.0.29.nupkg lib/netstandard2.0/Xamarin.Android.Fsharp.ResourceProvider.dll The fix is to use the `.nuspec` instead of the `.fsproj`: -nuget pack Xamarin.Android.FSharp.ResourceProvider.fsproj +nuget pack Xamarin.Android.FSharp.ResourceProvider.nuspec I also made some changes to the Xamarin.Android project (just general cleanup): * Migrate from `packages.config` to `@(PackageReference)` * We can rely on `/restore` now in the build definition. `restoreNugetPackages` is deprecated, so we shouldn't use it. * Removed an `` that was unused. --- ...oid.FSharp.ResourceProvider.Runtime.fsproj | 6 +-- Runtime/packages.config | 4 -- ...rin.Android.FSharp.ResourceProvider.fsproj | 44 ++----------------- azure-pipelines.yml | 11 +---- 4 files changed, 7 insertions(+), 58 deletions(-) delete mode 100644 Runtime/packages.config diff --git a/Runtime/Xamarin.Android.FSharp.ResourceProvider.Runtime.fsproj b/Runtime/Xamarin.Android.FSharp.ResourceProvider.Runtime.fsproj index 0d42b34..3d8bdf7 100644 --- a/Runtime/Xamarin.Android.FSharp.ResourceProvider.Runtime.fsproj +++ b/Runtime/Xamarin.Android.FSharp.ResourceProvider.Runtime.fsproj @@ -37,15 +37,11 @@ - - ..\packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll - + - - diff --git a/Runtime/packages.config b/Runtime/packages.config deleted file mode 100644 index b4e3326..0000000 --- a/Runtime/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Xamarin.Android.FSharp.ResourceProvider.fsproj b/Xamarin.Android.FSharp.ResourceProvider.fsproj index 6ab3877..bb29d25 100644 --- a/Xamarin.Android.FSharp.ResourceProvider.fsproj +++ b/Xamarin.Android.FSharp.ResourceProvider.fsproj @@ -1,48 +1,12 @@ - + - Debug - AnyCPU - {F0B64BEE-BBAA-4A11-94F8-DBE1A9C04D11} - Library + netstandard2.0 Xamarin.Android.FSharp - Xamarin.Android.FSharp.ResourceProvider - v4.5.1 - - - true - full - false - bin - DEBUG - prompt - anycpu - - - true + false + false bin - - prompt - true - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - packages\FSharp.Core.4.0.0.1\lib\net40\FSharp.Core.dll - - - - - - - \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 666f98c..62f975d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,25 +22,18 @@ jobs: - checkout: self clean: true - - task: NuGetCommand@2 - displayName: nuget restore Xamarin.Android.FSharp.ResourceProvider.sln - inputs: - command: restore - restoreSolution: $(System.DefaultWorkingDirectory)/Xamarin.Android.FSharp.ResourceProvider.sln - - task: MSBuild@1 displayName: msbuild Xamarin.Android.FSharp.ResourceProvider.sln inputs: solution: $(System.DefaultWorkingDirectory)/Xamarin.Android.FSharp.ResourceProvider.sln - msbuildArguments: /bl:$(System.DefaultWorkingDirectory)/bin/build.binlog + msbuildArguments: /restore /bl:$(System.DefaultWorkingDirectory)/bin/build.binlog configuration: Release - restoreNugetPackages: true - task: NuGetCommand@2 displayName: pack nupkg inputs: command: pack - packagesToPack: $(System.DefaultWorkingDirectory)/Xamarin.Android.FSharp.ResourceProvider.fsproj + packagesToPack: $(System.DefaultWorkingDirectory)/Xamarin.Android.FSharp.ResourceProvider.nuspec packDestination: $(System.DefaultWorkingDirectory)/bin/ - task: NuGetCommand@2