How to add resources to Assets?


Hi, I find the TestCpp project can add the whole Resources directory to the Assets directory in the generated xap,How does it do this?



There is a pre-build event that does an xcopy of the Resource folder into the WP8 assets folder. This copied folder is then referenced from the Assets solution filter folder in the project. If files in here have the property - Content : Yes then they will get copied into the xap. Beware, when adding your own resources! make sure the property Content: Yes is set for all platforms and configurations, it only sets this automatically for image types etc.
This can be the source of much head-scratching if it catches you out… :frowning:


hi, Craig, thanks for your reply. I right click the HelloCpp project select “Properties”, I can’t find any thing in pre-build event, there is nothing in the “Command Line” text box.


Hi Sophie. You are correct of course. I must have added the pre-build stuff to my own project at some point. Looking at HelloCpp again I find myself as confused as your are… I remember this puzzled me when I started building WP8 and WinRT projects. I thought I had this Resources/Assets folder stuff worked out, but if I did, I’ve forgotten :frowning:
Can anyone else please enlighten us???!


May be you can edit your xxx.vcprojec by notepad or other.
add this depends on your environment:

    <_CustomResource Include="..\Resources\**\*">


hi,jackin the TestCpp project does copy resources to xap, I just can’t find where it does this.


hi sophie, just like I described above, you can open the TestCpp.vcxproj in notepad, you can file the xml code. To the end of xml, you can find a ItemGroup contain _CustomResource, and the Include path is what you want: “…”, vs2012 copy all resource into the destination path of ‘link’: ‘Assets\Resources(RecursiveDir)(Extension)’.