"It's a simple and fast download that can clear out those stuck documents in less than 30 seconds." - Kim Komando
Home » Visual Studio Cordova – Exclude files

Visual Studio Cordova – Exclude files

This plugin was initially published by Magic Box Software, but I want to give a more detailed description, so I am posting it here. In Visual Studio 2013 Cordova Tools CTP 3.1 and VS 2015 there is a bit of a problem – a gotcha. Every file in the root of the VS project and most any folder in it (css, scripts, Content, etc.) is packed into the application package. This leaks code and results in unbelievable bloat. On top of that unless you are curious enough to look in the app package you might not even notice that the template readme, packages.config, typescript files and all the unminified javascript in your project is packed inside. This plugin, available on Github, offers a solution to this problem until MSFT fixes this.

To clarify, this plugin does not alter your Visual Studio project in any way. It simply removes the selected files and folders from the build.

Let me give you a little better idea what this looks like. Using a default Cordova template might leave the root of your project looking like this in part:


When you build this app (APK used for this example) you get this in the Cordova project root /assets/www:


The project readme, the intellisense js file, the .nupkg and the packages.config have no business here obviously. It gets better. Look at the size of that Content(css) directory and the scripts directory. The only content in this project so far are AngularJS, Ionic and some Typescript .d.ts declaration files.

The problem here is twofold. Let’s have a look at the scripts directory in our APK:


While we are probably only using the unminified javascript (css is the same way) for intellisense and linking to the .min.js in the app code we are packing both in the app package defeating the whole point of the min and then some. If you are using Typescript in your project the problem is compounded by, you guessed it, the inclusion of not only your application .ts files, but also the declaration files in the typings directory:


At the same time you may have some other files that you don’t want to include in the application package. In other VS projects you can easily exclude these files from being copied to the bin. In the Cordova CTP this is not yet possible. That is why I wrote this plugin. When asked Chuck Lantz at Microsoft not only promised this would be addressed as the tools get ready for RTM, but also suggested the manner of an interim fix that became the basis for this plugin.

In its default state the plugin cleans out the packages.config, the template readme and any errant .nupkg and _references.js that may be in the project root. At the same time it removes any Typescript files from the project and removes any unminified javascript and css files if, and only if, a minified version exists in the same directory.

In addition to those default actions some granular exclusions can be specified using 3 types of text files in the project. The actions in these files are applied to every non “Debug” build configuration. Non-Debug configurations are defined as any build configuration name that does not begin with “Debug”.

The first of these files is releaseignoreglobal.txt that you would place in the root of your VS project. No directory syntax is allowed in this file, only glob file patterns which will be applied to the entire project. For example version.json would remove every version.json file in the project while *.map would remove all source maps from the project. An example is:


To exclude specific files from a single directory we add a releaseignore.txt in the directory where the file(s) to be excluded reside:


Finally you can exclude directories by placing a releaseignoredir.txt in the directory you wish to exclude. By default this is an empty file and the exclusion is recursive. However you can add this line to the file recursive=false to alter the behavior to only exclude all the files in the directory, but not the subdirectories. This will allow the further use of releaseignore.txt in the subdirectories.


After applying these files your release builds will be smaller and not be leaking all those files that don’t belong in the app package to begin with.

Name of author

Name: Mike