locked
How can I easily add multiple resources to my project

    Question

  • I am porting a number of apps to Windows 'Metro' and each of these apps have a large number of resource files in multiple directories (dozens of directories, and hundreds of files).  I would like to be able to add all of these files to my project without having to import them one folder at a time (and setting them as 'content').  I have tried dragging the root of the resources folder to the 'Assets' folder in the 'Solution Explorer', but that, of course, does not work.  Right now, it seems that I have to physically copy all the files into my 'Assets' folder for my project, and then create the corresponding 'folder' in the project by using the 'Add/New Filer' option in the 'Solution Explorer' and then adding the files for that folder to the project (and then rinse and repeat).  Surely there is a better way to do this?

    Thanks.

    Thursday, July 12, 2012 7:50 PM

All replies

  • I don't think you can avoid the manual creation of the folders and putting the appropriate files in the language-specific folders. One thing I can suggest is if you do all the creating folders and copying files in the file system via windows explorer, then in Solution Explorer in VS, you can click the "Show All Files" button located at the top of the Solution Explorer window, then right-click on those folders and select "Include In Project". This will mark all the files in the folder to be included in the project and files like .txt or image files are marked as Content by default so you don't need to manually change them.

    Friday, July 13, 2012 11:19 PM
  • That does indeed help, however after 'Showing all files' I would REALLY like to be able to click on the root folder of my assets and specify that it and all of it's sub-folders be included in the project, but alas that does not seem to be possible.

    Thanks for the tip, it will make things a bit easier.

    Sunday, July 15, 2012 1:06 AM
  • You should be able to right-click on the root folder and select "Include In Project" which will mark it and its subfolders to be included in the project. Is that not working for you?
    Monday, July 16, 2012 6:28 PM
  • Well, yes, I can right click on the folder and choose 'Include In Project', but nothing happens.  The files in the folder and sub-folders are not included.  I must select the files individually (I can multiple select) in order to include them.
    Monday, July 16, 2012 10:26 PM
  • This works fine for me in a C# project. What project type are you working with?
    Monday, July 16, 2012 11:06 PM
  • It is a C++ project, perhaps it is a bug?
    Tuesday, July 17, 2012 1:06 AM
  • Could be. I encourage you log a bug about this on Connect: http://connect.microsoft.com/VisualStudio
    Tuesday, July 17, 2012 10:46 PM
  • I created a mocked project with 50 files with a range of extensions.  Some tool extensions like .cpp, .idl, and .rc were added to the project via Candy's method.  Other extensions like .hlsl, .dat, .foo were not added to project. 

    What extensions are you using?

    Wednesday, July 18, 2012 2:13 AM
  • I am using a variety of extensions, but I still want to add all of them.  Note that I CAN do that if I select the files, add them to my project, and then set their 'content' as True. However we have a number of projects (which we are porting to Metro) each of which have many files in many folders.  I was hoping for a quick way to import a folder and all of it's sub-folders and files.  The 'Show All Files' idea works to a degree, but I still cannot add all the files to the project by simply selecting the root folder.  I am forced to select the individual files and add them to the project.  I suppose that is is not a HUGE deal, but I was looking for an easier way.

    Thanks.

    Wednesday, July 18, 2012 10:25 PM
  • I still haven't found an easier way.  However, I notice that you can use the search/filter in the new solution navigator to filter for extensions.  This and conjuction with multi-select should get pretty close.

    This blog post might give you some extra ideas.

    http://blogs.msdn.com/b/zainnab/archive/2012/06/21/visual-studio-2012-new-features-solution-explorer.aspx

    Thanks

    Felix

    Monday, July 23, 2012 11:07 PM
  • The extensions to include are controlled by Tools - Options - Projects and Solutions - VC++ Project settings - Extensions to include. I guess we are missing a bunch of useful extensions there by default, but if you add them there, it should work.

    Olga

    Tuesday, August 28, 2012 7:46 PM