DotNetNuke including or excluding files in a theme, skin, or module build in Visual Studio

Developing modules and themes/skins for DotNetNuke is made easy with the module/theme templates from Christoc.  I'm assuming if you're reading this article you are familiar with these templates and use them to build your modules.   If you aren't using these templates you probably aren't experiencing this issue, and this isn't the article for you.  However, you should be using these templates as it automates the packaging of your DNN modules and themes.  You can automate it on existing projects as well by following this tutorial:

In my recent journey creating DotNetNuke modueles, I ran into something very interesting.  Sometimes I would build a module and it would work fine on my local environment, but in any other environment it was missing certain files and even entire folders.  For example, I added a new folder with a bunch of images to my module.  I then referenced these images in my page and it worked fine.  However, after building the solution, I used the install file on a different environmen only to discover the folder was and it's images were missing.  


To solve this problem, we need to look in the BuildScripts folder of your solution.   If you're creating a module, the file we need is called "ModulePackage.targets."  If you're creating a skin/theme, the file we need is called "SkinPackage.targets."

Look for a section similar to the following: 

      <InstallInclude Include="**\*.jpg" Exclude="**\containers\*.jpg" />


      <SourceInclude Include="**\*.jpg" />

Within these sections you set the file extensions you want to include, as well as the file extensions and folders you want to exclude.  You might have to play around with the settings a bit to get your desired results, but you simply make a change and build your module in release mode.  Verify it by looking through the installer zip to ensure the files exist, and it helps to install it on a test DNN site as well.