I’m working on a multiplatforms game for Windows and Android so I created a shared project to use the same source code for both tagerts.
The problem is that in my project, I need to load raw assets and these assets are the same on Android and Windows. So I put them into my shared project but in this kind of project, we can’t add copy rules like AndroidAsset.
I tried to manually update the Android project file to manually specify that I wanted to copy an external folder as raw assets like that:
And it kind of works, but when I add new files in the ..\Core\Assets\ folder, they are not copied. I need to relaunch the solution to take into account new files.
I also tried to use prebuild commands to do what I wanted:
But it doesn’t work as expected neither because the rule to embed the raw files into the produced APK is missing, and copy files to the Assets folder is not enough.
You have to manually include the .targets file that defines the MonoGameContentReference build action and set your .mgcb file to use it in the .shproj. It’s best if you look at a MG project from one of the templates to see how it’s done. Once you have that setup you automatically build for the right platform when you build one of the platform-specific projects. Built content will go into Content/bin/{Platform}/.
Thanks a lot, it seems to do the job Even if the new files doesn’t appear in the solution explorer without opening the solution again, they are embedded in the APK
I’m already using a shared content pipeline for other files, but I needed to have raw assets too.
Thank you for your answer @MrValentine, but I couldn’t do that because the shared project is not related to any platform, so I can’t specify AndroidAsset as build action (and I don’t want to do that, because on Windows the build action must be Content).