Automatically Include All Files in Folder in Visual Studio

I’ve written before about how you have to make sure to include asset files into the project file if you want Azure to deploy them during a git deployment.

Thats pretty annoying, especially if you’re using external build tools to copy assets into the css, images or assets folders – You have to remember to right click and Include in Project.

Wouldn’t it be nice if Visual Studio and (therefore) msbuild just recursively included and deployed a folder of files?

You have to hand edit the .csproj file, but all you need to do is use a wildcard in the Include statement:

MyProject.Web.csproj
1
2
3
4
5
6
<!-- double wildcards include all files and folders -->
<Content Include="assets\**" />
<Content Include="images\**" />

<!-- You can also filter like you would at the command line -->
<Content Include="css\*.min.css" />

Go forth and deploy in confidence.

Comments