locked
Adding files to a package that without adding them to the VS project

    Question

  • I'd like to be able to add files to the unpackaged app created by VS before Run (that is, the AppX folder) without adding them directly to the project. I'm working on a project that has a lot of content, and it would be preferable to not have to add the content to the project directly. One answer is, of course, just copying the files directly to the AppX folder, but I'd like it to work with Remote Debugging and, ideally, the Create Package Wizard. Right now, I'm overwriting .build.appxrecipe in a post-build step. This sort of works. The files I add to .appxrecipe get copied to the layout folder, but it looks like VS caches the .build.appxrecipe file--I have to manually restart VS for it to use my updated .appxrecipe. Is there a better way to do this, or a way to prevent .appxrecipe from being cached?
    Friday, August 17, 2012 8:19 PM

All replies

  • Are you looking to add it to the AppX folder or the deployed folder?


    Jeff Sanders (MSFT)

    Wednesday, August 22, 2012 3:22 PM
    Moderator
  • You can make the resources as "Content" by changing the "Content" property to "true" for the intended files in the property grid windows (The property grid window is under "solution explorer" in a default layout).

    Li Shao, MSFT


    Li Shao

    Thursday, August 23, 2012 2:56 AM
  • Isn't AppX the deployed folder? It's what gets registered as an app, and what's launched. I would like the extra content to be included in AppX for development and the final package for shipping.
    Wednesday, August 29, 2012 4:04 PM
  • I'm facing the same issue with very little clear documentation.  The pre-build, pre-link, and post-build steps don't seem to affect the files that get put into the AppX folder.  The appxrecipe only lists files that have been added to the project.  In this case we have a copy script (bat file) that copies resources next to the exe.  

    We do add folders (not files) to our xCode projects.   This is so much easier with "reference" folders there that reflect custom folder content, but I haven't found an equivalent Visual Studio.  

    AppX is the pre-deployed app isn't it?  The deployed version of the app is found in %ProgramFiles%/WindowsApps, but that's a non-visible folder.

    Sunday, September 16, 2012 6:40 PM
  • I've asked this, (and answered) this question on this thread:

    http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/ef01937e-53b6-4a40-abd2-3c103d4a6956

    Here's the short answer I'm using:

    In the project's "post build" step, I add the line:

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

    Replace "My project" with yours, or whatever is appropriate for you, and replace "Release" with "Debug" for the debug version of your project.

    You can have the first directory be anything... I still use my Assets directory as the "source store", but you can make it anywhere you want.

    Now, my art assets can be delivered to any team-agreed-to directory, and I don't have to manually maintain them in the project.

    I would discourage any attempt to do this by the typical "add to project" if you have a high volume of resources. The post I pointed to goes into detail why I say this.


    Jim Tomasko

    • Proposed as answer by James Tomasko Sunday, September 16, 2012 10:16 PM
    Sunday, September 16, 2012 10:16 PM
  • Thanks for the tip, but I've tried all manner of pre-build/pre-link/post-build steps.   The data is copied into the AppX folder, and then when I run the application from the debugger, it blows away the AppX folder, and the Resources folder with it.  The second time I launch the app, the AppX folder stays around, and the Resources are copied in a second time.   How do I get this to work without having to build twice?  Then when I build from the command line, there's an AppPackages folder that's created in a directory not of my choosing, and that doesn't have the Resources folder in it.  Augh!

    I also don't see any files add to the appxrecipe file, but I'm assuming I can reference deployed files in the same folder as the exe even if they're not in that.  I still want fopen to work with a standard path.

    Monday, September 17, 2012 5:50 PM
  • Another dead end.... it looks like Links are honored in VS 2012 in the .vcxproj, provided that they point to valid files.  But alas, in VS 2010/2012, the development team split out filters from the vcxproj file.  Bad idea.  VS 2012 doesn't even offer the Link option, because it's whole behavior is broken.   There's no way to encapsulate this in a folder, and it appears that the .filters file is continually modified and appended to.   You'll end up with thousands of copies of the same files in the .filters file.   When you look at the project, you'll only see each file once, but at the root of the project intermingled with all other loose files. 

    You can also use **\*, add this to .vcxproj

     <None Include="..\resources\test_images\*.*"> 

          <Link>Resources\test_images\%(RecursiveDir)%(FileName)%(Extension)</Link>
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
          <DeploymentContent>true</DeploymentContent>
      </None>

    • Proposed as answer by Alecazam Thursday, September 20, 2012 9:55 PM
    Tuesday, September 18, 2012 5:38 AM
  • The link is actually the best way to add content.  It preserves the folder hierarchy, deploys, copies to AppX.  The vcxproj.filters file gets wonky, but it feels like the only approach to have content bundled into the app, added to the appxrecipe, etc.   
    Thursday, September 20, 2012 9:57 PM