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
<PackageReference Include="FSharp.Android.Resource" Version="1.1.1" />
paket add FSharp.Android.Resource --version 1.1.1
#r "nuget: FSharp.Android.Resource, 1.1.1"
// 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
- Replace the old type provider with the new package for your Android project
- <PackageReference Include="Xamarin.Android.FSharp.ResourceProvider" />
+ <PackageReference Include="FSharp.Android.Resource" />
- 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>
- Run the build one time; it will fail but it's ok. This generates the resource assembly.
- Reload your project to be able to see the new resource assembly
- 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)
- Build one more time. This time it should complete successfully.
- 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:
- Execute a build using the target
CompileResourceDesignerForFSharp
- Execute a normal build
msbuild -t:CompileResourceDesignerForFSharp
msbuild -t:Build
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
|