Question

I'm using Xamarin Studio. Is it possible to set the default build action for custom files or image files?

I'm developing an app that uses A LOT of PNG images. BundleResource is set by default for every image I import into the project. I noticed that my memory usage decreases by about ~25mb (from 220 to about 193mb) when I build my images using Content as opposed to the default BundleResource.

"MonoDevelop should automatically choose the BundleResource build action, but you can check or set this manually using in each file’s properties."

-http://docs.xamarin.com/guides/ios/platform_features/monodevelop_features

Was it helpful?

Solution 2

It does not appear that a default build action can be set. However, when adding the files to the project the Add files dialog provides the option to override the build action that the files will be imported to use.

In this way you can select a bunch of the PNG images and import them with Content from the get go.

http://mjhutchinson.com/journal/2011/03/monodevelop_tips_build_actions

OTHER TIPS

I would recommend against using the Content build action. The BundleResource build action was added later and is more powerful, however the only difference between them is the mapping from the file's location in your project to the file's location in the app bundle. The Content build action has only been kept for backwards compatibility.

If you're seeing different memory use there must be some other reason for it. Have you tried comparing the two versions of your app bundle?

Content files are copied into the app bundle with a relative path matching their relative path within your project. BundleResource files are treated the same, except that if their are in the project's Resource directory, this prefix is stripped off. The idea is that you can copy things into the root of the app bundle, as required by Apple APIs, without cluttering up the root of your project.

So, for example, with BundleResource build action, the file Resources\Foo\Bar.png in yur project would be copied to Foo\Bar.png in the app bundle. Whereas with the Content build action it would be copied to Resources\Foo\Bar.png (though you're not allowed to have a directory called "Resources" inside your app bundle since it's an Apple reserved name, so you'd get an error).

BundleResource also supports a IPhoneResourcePrefix project property you can only set by manually editing the csproj file that allow you to define more directories to be treated this way, for example you could have an Images directory. This gives you more control over organizing your resources. You can also use the LogicalName item metadata on any BundleResource item to completely override its bundle-relative location.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top