How to add resources to Assets?


#1

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?

Thanks


#2

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:


#3

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.


#4

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???!


#5

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

    <_CustomResource Include="..\Resources\**\*">
      Assets\Resources\%(RecursiveDir)%(FileName)%(Extension)
      true

#6

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


#7

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