Visual Studio Cordova – Exclude files
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:
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 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.