I've created a new Xamarin.Android app and added a few assets to it. Those assets are available in multiple resolutions, so I placed them in their respective drawable-XXX
folders inside the Resources
folder. Doing so resulted in the following error:
The project 'XXXX.fsproj' could not be opened because opening it would cause a folder to be rendered multiple times in the solution explorer. One such problematic item is 'Resource\drawable-hdpi\pencil.png'
This is being caused by F#'s poor folder structure handling. I usually don't need to use folders at all in F# projects, but in this specific case it's necessary because of the way Android deals with resources. The project loads fine in Xamarin Studio, but in Visual Studio it doesn't.
The project is quite big, what means I (and other people as well) will need to add a lot of files, so manual approaches like this one are of no use, for they're too time consuming.
I read the official docs but there's nothing there that states there's a special way to handle adding files on VS or another way to deal with this limitation. My question is: such thing exists? Can I add those files in another way so that I don't need the complex structure on VS? Will I be forced to use C# or Xamarin Studio against my will?
The references to folder files have to be listed together, they can not be interspersed with files in different location. Sort the refs and it will be fine.
EDIT, for clarity:
<ItemGroup>
<Compile Include="folder\file1.fs" />
<Compile Include="file.fs" /> <-- this can't be between the folder files, all folder files have to be listed together
<Compile Include="folder\file2.fs" />
</ItemGroup>
Sadly, the standard Visual Studio integration does not support folders in F# projects.
Your best option is to use the Visual F# PowerTools. This adds some support for folders to F# projects and so it may work good enough to do what you need. If it does not, then Visual F# PowerTools is an open-source project and it always welcomes contributions!
I don't know much about the Xamarin Android project types - but I guess that adding C# project which is just an empty DLL to store the resources would be a reasonable alternative too. (Then you should be able to reference this from F# and load all resources from there.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With