How to get around the limitations of the Visual Studio F # project folder on Xamarin.Android?

I created a new Xamarin.Android application and added several assets to it. These assets are available in several permissions, so I placed them in the corresponding drawable-XXX folders inside the Resources folder. This led to an error:

The project "XXXX.fsproj" could not be opened because opening it will cause the folder to appear several times in the researcher’s solution. One of these problematic elements is "Resource \ drawable-hdpi \ pencil.png"

This is due to the incorrect F # folder structure. Usually I don’t need to use folders at all in F # projects, but in this particular case this is necessary because of how Android deals with resources. The project loads fine in Xamarin Studio, but in Visual Studio it isn’t.

The project is quite large, which means that I (and other people) will need to add a lot of files, so manual approaches like this should not be used, because they are too time-consuming.

I read the official docs , but there is nothing there that says a special way to handle file uploads on VS or another way to deal with this limitation. My question is: does such a thing exist? Can I add these files differently so that I don’t need a complex structure on VS? Will I be forced to use C # or Xamarin Studio against my will?

+5
source share
2 answers

Links to folder files must be listed together; they cannot be interleaved with files elsewhere. Sort links and everything 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> 
+5
source

Unfortunately, the standard integration of Visual Studio does not support folders in F # projects.

Best to use Visual F # PowerTools . This adds some folder support to F # projects and therefore can work well enough to do what you need. If this is not the case, then Visual F # PowerTools is an open source project and always welcome contributions!

I don't know much about the types of Xamarin projects for Android, but I assume that adding a C # project, which is just an empty DLL for storing resources, is also a reasonable alternative. (Then you should be able to reference this from F # and load all resources from there.)

+1
source

All Articles