locked
How in Visual Studio to tag/copy a folder so it's contents copy to App Data during build? RRS feed

  • Question

  • My Metro C++ app project as an ART directory, which as you would guess holds my finalized art assets.  To be clear, these are art assets I use for rendering... not a user picture directory.  Currently, I place a new piece of art in the directory, then use "Add Existing Item" to add it to the project (Content=True).  While this works, it's not nearly an ideal workflow.

    With either some setting, or a post build step; I would like to have my project automatically add anything in my art directory as if I had manually added it and tagged it as content.

    I'm guessing that manually doing a copy during post build would upset the manifest.

    Thanks,


    Jim Tomasko

    Wednesday, September 12, 2012 12:52 AM

Answers

  • Hi Mike,

    Well… “Does it cause other issues”?  Yes… too many to be desirable, but you did provide me with a path to get me moving again. (The bottom has what I think should work.)

    Here are two examples to illustrate the problem:

    <Image Include="Assets\Scenes\Robots\*.png" />

    Does copy all files in “Robots”, has a secondary problem explained in the next example.

    <Image Include="Assets\Scenes\*.*" />

    Only copies files directly in “Scenes”, does not copy subdirectories and files. 

    I did try to explicitly list the subdirectories of “Scenes” as includes in the project file.  This highlighted a much larger (at least for me) problem.  All the content from all the scenes showed up in the solution explorer as unfiltered content in the project…. Yikes!

    Next attempt=====================

    As per my original post, the next step is to try to do this with a post build step.  This appears to be successful, but I have to reserve judgment for a bit.  I added a post build step of:

    xcopy /y /s "$(SolutionDir)..\MyProject\ MyProject \Assets\Scenes\*.*" "$(SolutionDir)..\ MyProject \Release\ MyProject \AppX\Assets\Scenes\"

    Everything works until I run the app certification tool… I fail the “Crashes and hangs test”, but then, after I remove these changes I still fail, so something else has gone wrong in the last few days since I ran the test.

    After I find the crash (only happens during the cert test… grrr), I’ll try the xcopy again.  If it works, I’ll check this post as “the answer”.  If it doesn’t, I’ll be back.

    Thanks for getting me going again.  I’m not sure why I didn’t think of trying the xcopy first… I think I’m a bit overwhelmed with the tsunami of new material building a metro app.


    Jim Tomasko

    • Marked as answer by James Tomasko Saturday, September 15, 2012 6:47 PM
    Saturday, September 15, 2012 2:55 AM

All replies

  • Hi Jim,

    if you open up the vcxproj file what do the xml tags look like for your items in the ART directory?  Also this is a physical file directory instead of a VC filter?

    much appreciated,

    mike

    Wednesday, September 12, 2012 9:32 PM
    Moderator
  • Hi Mike,

    Here's a line of one PNG file from the vcxproj file:

    <Image Include="Assets\Scenes\Robots\Robot1Parts.png" />

    The directory path shown is physically in the main project directory.  (I do have filters for Assets/Scenes, where everything is currently added to the project in "Scenes".

    To recap, the end result I'm looking for is to be able to have all files in the physical "Assets\Scenes" directory (and it's sub-directories) added as content just as they are now, but without having to explicitly include them.

    Thanks


    Jim Tomasko

    Friday, September 14, 2012 3:51 AM
  • Hi Jim,

    we might want to try something like the following:

    right click on the project node in solution explorer, select unload project.

    right click again on the project node and select edit yourproject.csproj

    where you see the line

    <Image Include="Assets\Scenes\Robots\Robot1Parts.png" />

    replace it with something like

    <Image Include="Assets\Scenes\Robots\*.png" />

    Does that work or does it cause other issues?

    thanks!

    mike

    Friday, September 14, 2012 8:50 PM
    Moderator
  • Hi Mike,

    Well… “Does it cause other issues”?  Yes… too many to be desirable, but you did provide me with a path to get me moving again. (The bottom has what I think should work.)

    Here are two examples to illustrate the problem:

    <Image Include="Assets\Scenes\Robots\*.png" />

    Does copy all files in “Robots”, has a secondary problem explained in the next example.

    <Image Include="Assets\Scenes\*.*" />

    Only copies files directly in “Scenes”, does not copy subdirectories and files. 

    I did try to explicitly list the subdirectories of “Scenes” as includes in the project file.  This highlighted a much larger (at least for me) problem.  All the content from all the scenes showed up in the solution explorer as unfiltered content in the project…. Yikes!

    Next attempt=====================

    As per my original post, the next step is to try to do this with a post build step.  This appears to be successful, but I have to reserve judgment for a bit.  I added a post build step of:

    xcopy /y /s "$(SolutionDir)..\MyProject\ MyProject \Assets\Scenes\*.*" "$(SolutionDir)..\ MyProject \Release\ MyProject \AppX\Assets\Scenes\"

    Everything works until I run the app certification tool… I fail the “Crashes and hangs test”, but then, after I remove these changes I still fail, so something else has gone wrong in the last few days since I ran the test.

    After I find the crash (only happens during the cert test… grrr), I’ll try the xcopy again.  If it works, I’ll check this post as “the answer”.  If it doesn’t, I’ll be back.

    Thanks for getting me going again.  I’m not sure why I didn’t think of trying the xcopy first… I think I’m a bit overwhelmed with the tsunami of new material building a metro app.


    Jim Tomasko

    • Marked as answer by James Tomasko Saturday, September 15, 2012 6:47 PM
    Saturday, September 15, 2012 2:55 AM