Is there any support in MGCB / Pipeline Tool for automatically adding copy-action files via wildcard? I have a folder of script files (.lua) which I’d like added to my Content.mgcb file so I can utilize the copying action from our raw asset directory to our build directory. Looking at the mgcb file, these files are added in a pretty simple manner:
However adding these files manually would be very tedious. Is there a way to automatically include all files of type lua in the scripts/ui directory, and simply have their asset name stay the same as whatever the actual file name is?
Not the end of the world if not, I will probably just write a python script to do the copying instead of routing it through the content builder. I would just prefer to keep all assets in one location and one build pipeline if at all possible.
But if you don’t need your raw files to be processed, you could simply use the System.IO namespace for this.
Another approach would be to completly build you mgcb file dynamically (it’s just a text file) and then call the MGCB.exe with some arguments by yourself.
It’s also possible to do it by customizing your build process, when building with msbuild. The MonoGame.Content.Builder.targets runs a target called BuildContent just before your project builds. If you want to do any processing before or after this process you can use the BeforeTargets and AfterTargets mechanism provided by msbuild to run your own targest.
If you can have them organized such that everything in the folder is always a copy action, you can simply remove the folder and readd it, within the pipeline tool (ie, right click parent, and choose ‘add folder’, choose it)
Oh cool thanks for sharing! I’ll take a look as soon as I get a chance. We’re coming up on a milestone and I’m not scheduled to do more asset work until after, so it might take a couple of weeks. But as soon as I’m back on asset pipeline I’ll mess around with it and get back to you in the linked thread with any feedback.
hi i also came up with a solution for this and thought i’d share.
it’s a simple node.js script that gets run automatically by using the “BeforeBuildContent” target in the “.csproj” file. all it does is it crawls my content folder and it writes to the “content.mgcb” file.
the code i have in that gist is custom tailored to my needs but it’s not super complicated to alter it. i figured out what to put as templates by using the built in monogame wizard and seeing what it would write out in the “content.mgcb” file. so whatever you want to happen automatically you’d just see what the wizard does and you’d add that to the “BuildContent.js” file.
a somewhat weird thing i added was a “leaveOutAudio” flag, adding all my songs and sfx slows down the build process of my game sometimes and leaving out the audio speeds things up considerably. i’m usually listening to music and have the game muted anyways.
so if you like this solution all you really need to do is to:
have node.js installed (so you can run javascript files on your computer)
have a javascript file (BuildContent.js) that adds all the stuff you care about to the “content.mgcb” file
add a build target command to your game.csproj file so you never have to run this javascript file manually
you could probably also do this with not node.js of course, so you don’t have to install anything, but i dunno i actually find javascript to be a good solution for simple little utility scripts like this.
Since this theme has been resurrected an in case anyone finds it, just use this. https://github.com/Martenfur/Nopipeline
No need for js dependencies, csproj editing, completely automatic operation, more features, support for whatever resource type you have.