FSharp.Android.Resource 1.1.1

dotnet add package FSharp.Android.Resource --version 1.1.1
NuGet\Install-Package FSharp.Android.Resource -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSharp.Android.Resource" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FSharp.Android.Resource --version 1.1.1
#r "nuget: FSharp.Android.Resource, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FSharp.Android.Resource as a Cake Addin
#addin nuget:?package=FSharp.Android.Resource&version=1.1.1

// Install FSharp.Android.Resource as a Cake Tool
#tool nuget:?package=FSharp.Android.Resource&version=1.1.1

This library is no longer needed for .NET 8 and higher.
Please remove it from your projects when you migrate.

MSBuild task to expose resources to F# Xamarin.Android / .NET Android projects up until .NET 7.

Why is it no longer needed for .NET 8 and higher?

Starting .NET 8, F# Android projects work out of the box without the need for this library.

Microsoft improved access to assets in your Android apps. They generate an assembly named _Microsoft.Android.Resource.Designer which contains all your Android assets, instead of silently injecting C# code into your F# projects.

How to use

  1. Replace the old type provider with the new package for your Android project
- <PackageReference Include="Xamarin.Android.FSharp.ResourceProvider" />
+ <PackageReference Include="FSharp.Android.Resource" />
  1. Remove the following properties from your Android project fsproj file. They are managed by FSharp.Android.Resource
<PropertyGroup>
-   <AndroidResgenFile>Resources/Resource.designer.cs</AndroidResgenFile>
-   <AndroidUseIntermediateDesignerFile>false</AndroidUseIntermediateDesignerFile>
</PropertyGroup>
  1. Run the build one time; it will fail but it's ok. This generates the resource assembly.
  2. Reload your project to be able to see the new resource assembly
  3. Add do Resource.UpdateIdValues() to your MainActivity (or whichever activity is the first one to display)
type MainActivity() =
    inherit Activity()
    
    // This is required for the app to pick up the right resources
    do Resource.UpdateIdValues()
    
    member _.OnCreate(bundle) =
      base.OnCreate(bundle)
      
      // Now you can use Resource like usual
      this.SetContentView(Resource.Layout.Main)
  1. Build one more time. This time it should complete successfully.
  2. Everything should be working, enjoy!

How to use in a Continuous Integration environment

Given the first build will always fail, you can use the following steps to workaround it:

  1. Execute a build using the target CompileResourceDesignerForFSharp
  2. Execute a normal build
msbuild -t:CompileResourceDesignerForFSharp
msbuild -t:Build
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on FSharp.Android.Resource:

Repository Stars
egvijayanand/dotnet-maui-samples
.NET MAUI Samples
Version Downloads Last updated
1.1.1 411 10/23/2023
1.0.4 4,818 5/27/2022
1.0.3 464 5/19/2022