Since BlueChilli uses Nuget packages to store and share framework libraries, in some cases we need to modify files during the installation of Nuget packages for new projects. After investigation and research, it turns out quite simple. Nuget supports two types of transformations during installation of a package: Configuration fie transformations and source code transformations
Configuration transformations provide a simple way for a package to modify a web.config or app.config. When Nuget sees this transformation file, it attempts to merge in the various sections into your existing configuration file, it includes only the sections that need to be merged into the project’s configuration file, it does not change existing elements or attributes in any other way.
Nuget also supports source code transformations in a similar manner to Visual Studio project templates. These are useful in cases where your Nuget package includes source code to be added to the developer’s project. To enable source transformations, simply append the .pp file extension to your source file within your package, and add the token in the file (e.g. “$rootnamespace$”). During package installation, the token will be replaced by Visual Studio project property, and the .pp extension will be removed.