Copying assets into UWP application package
Asked Answered
I

1

7

I have a large folder structure with a ton of subfolders that I am using for application data in my UWP app. When testing, I can just have it sitting on disk and it's fine, but when I make a store package, I need to be able to copy that data in. The only way I've found to include assets is to manually add individual files into Visual Studio and set them to be "Content". Is there a way to copy in an entire folder as "Content" and preserve its folder structure?

Innutrition answered 21/8, 2015 at 15:36 Comment(0)
S
14

You don't have to manually add all the files. Add the entire folder inside the UWP app folder. Once you do that you should be able to use the Show All Files option in the solution explorer and add the entire folder. If the property of the added files is not already set to "Content", multi select the files and set the Build Action property in the Properties window to Content

[enter image description here]

[enter image description here]

Scagliola answered 21/8, 2015 at 17:3 Comment(7)
Hmm, "Include In Project" doesn't seem to work on folders. Is the only solution to manually go through all folders and include the files? Also, will they be included in their respective subfolders?Innutrition
It does work on folders. It will include sub-folders as well.Scagliola
Strange, it doesn't seem to do anything for me on Visual Studio 2015 Community.Innutrition
I'm trying to use this tip, but my file doesn't appear in the deploy folder. There's no Asset subfolder. I have Build Action=Content & Copy To Output Directory as "Copy Always". Then I clicked the solution->Deploy. Is there something else needed?Autocade
In case people have the same problem like @DeannaD, try cleaning up the Debug and Debug/AppX folder outside of VS, like using Windows Explorer or cmd.exe. I have the feeling VS keeps especially Debug/AppX after a former deployment as it is and doesn't really like things like changing build operations for assets with a deployment afterwards. Other users have similar issues and removed files from the project to get VS syn again: social.msdn.microsoft.com/Forums/en-US/…Annaleeannaliese
Instead of using "Include in project", at least in VS 2019 Community Edition it's enough already to simply Drag&Drop the folder of interest into the "Assets"-folder in the project manager. Marking all files of interest and change their build settings doesn't seem to be a good solution in case of hundreds of files, though.Annaleeannaliese
@LukkhaCoder awesome. May I know how can I target architecture based inclusion e.g I included a folder which have some exe for x64 but also want to support x86. Also don't want to include all folders since it will increase the overall size of the application.Tapetum

© 2022 - 2024 — McMap. All rights reserved.