How to add a folder and its contents with build action content in to uwp project?

MG Bhadurudeen 631 Reputation points
2021-07-31T14:42:39.68+00:00

Hi, I have nearly 2000 files in my Assets\MyImages\ folder, which should be added as 'Build Action = Content'.
Now I am adding it manually in the properties window. I want to know is there any method to add all files and subfolders of a parent folder (MyImages) in to my project with Build action as content.

![119566-image.png]1

<Project...>  
     ....  
    <Content Include="Assets\MyImages\Animals\elephant1.png" />  
    <Content Include="Assets\MyImages\Characters\Characters.txt" />  
    <Content Include="Assets\MyImages\Flowers\Flowers.doc" />  
    <Content Include="Assets\MyImages\Fruits\Fruits.some" />  

I wish there must be a way to add it like, <Content Include="Assets\MyImages\*.*" /> through Notepad++
I tried this way. But no luck.

In short, I want to know how to add a folder with all its subfolders and all files in all subfolders with Build action as content by a single line in .csproj file?

Developer technologies | Universal Windows Platform (UWP)
Developer technologies | Visual Studio | Other
Community Center | Not monitored
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 34,441 Reputation points Microsoft External Staff
    2021-08-02T07:54:25.787+00:00

    Hi @MG Bhadurudeen ,

    Welcome to Microsoft Q&A forum.

    Since Animals, Characters, Flowers, Fruits… are folders/subdirectories, you can try to use <Content Include="Assets\MyImages\**\*.*" />

    Document about wildcards: Specify inputs with wildcards.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.