Copy raw assets from a shared project

Hello everyone :slight_smile:

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:

    <AndroidAsset Include="..\Core\Assets\**\*.*">

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:

xcopy "$(SolutionDir)Core\Assets" "Assets\" /Y /I /S /R

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.

Do you know another solution to do what I want?

Thanks in advance :slight_smile:

Try setting to Always. Also consider using the Content Pipeline if you can, that works really well for Shared Projects.

1 Like

Solution Explorer > Show All Files > Right Click > Include In Project > In-Show Show All Files
[You can multi file select and perform this action]

Click Object > Properties Panel > Build Action > Content
Click Object > Properties Panel > Copy To Output Directory > Copy If Newer

Or you did this already?


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}/.

1 Like

Thanks a lot, it seems to do the job :wink: Even if the new files doesn’t appear in the solution explorer without opening the solution again, they are embedded in the APK :slight_smile:

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).

1 Like