Project page
Substitution of any config, text or code file before compilation. Support of different substitutions based on build flavor (i.e. Debug, Release etc.)
Perfect for generation of complete sites including all neccesary files.
Enables you to put environment specific values under source control.
Available on the official NuGet feed
SubstituteApp and all add ons are available on the official NuGet feed
Use the NuGet to get a quick start. Basic setup are included in the package installer.
NOTE: For the moment I dont have a working uninstall-script, so you have to remove some files and delete the pre-buildevent manually if you want to uninstall the NuGet package.
Usage
- Create a file with the same name as the file you want to make substitutions in.
But add an additional extension, same file extension as the file you want to generate.
I.e. web.config.config
, robots.txt.txt
or crossdomain.xml.xml
- Create a file with your substitutions. Name it whatever you want, but it will contain XML-data so a XML-file would be just fine. I.e. "web.config.substitute.xml"
- Format the XML-file as the ""XML-Format - Substitution" section below)
- Add the
SubstituteApp.exe
to you project. The "Libraries"-folder (or "External" etc.) could be a suitable place.
- Add a
SubstituteApp.config.xml
to your project and populate it with the XML according to the "XML-Format - Config"-section below
- Add a line to your pre-build event, in your project.
I.e.
$(SolutionDir)Libraries\SubstituteApp\SubstituteApp.exe $(ConfigurationName) SubstituteApp.config.xml $(ProjectDir)
The example shows when the SubstituteApp.exe
is located in folder \Libraries\SubstituteApp\
- Exclude the result file from Source Control (NOT exclude from project).
In VS2010 using TFS:
- Mark the file by clicking on it
- Go to: File->Source Control->Exclude 'YourFile' from Source Control
Parameters
- Build flavor name (use
$(ConfigurationName)
)
- Path to
SubstituteApp.config.xml
, relative to project root folder.
- Path to your project (use
$(ProjectDir)
)
- If path (3.) contains whitespaces the app will believe additional parameters are sent in. These will be concaternated in the app with a whitespace between.
What happens
The app search the template file for keys and substitutes them with the value defined in the substitution-xml-file. The app also remove the readonly attribute of the target file. In order to be able to write to it.
XML-Format - Config
- Root node:
<substitutes>
- Child nodes:
<substitute>
containing three nodes.
Optional attribute 'name' is added for nuget transformation support.
<templatefile>
<substitutefile>
<resultfile>
each containing the relative path (from projectroot) to given file.
Example:
<?xml version="1.0" encoding="utf-8" ?>
<substitutes>
<substitute name="web.config">
<templatefile>web.config.config</templatefile>
<substitutefile>web.config.substitute.xml</substitutefile>
<resultfile>web.config</resultfile>
</substitute>
</substitutes>
XML-Format - Substitution
- Root node:
<substitution>
- One
<configuration>
node for each build flavor you want to use. Attribute name
.
- X number of
<item>
nodes under each <configuration>
node.
- Attribute:
key
, the key to find and substitute.
- InnerXml: the value of found key after substitution
- Each
<configuration>
node needs the same amount of <item>
nodes. Else the substitution will fail.
- It is possible to have subtrees instead of values in the inner xml. The subtree may however lose the xml-formatting.
Example:
<?xml version="1.0" encoding="utf-8" ?>
<substitution>
<configuration name="Debug">
<item key="Key1">Value1</item>
<item key="Key2">Value2</item>
</configuration>
<configuration name="Release">
<item key="Key1">Value3</item>
<item key="Key2">Value4</item>
</configuration>
</substitution>
Errors
The app will fail if...
- ...it isn't invoked with 3 (or more) parameters.
An error will be found in the build log.
-
...the substitution file doesn't have a configuration node for the given configuration.
An error will be found in the build log and the the same error will be written to the result file.
-
...the substitution file doesn't have the same amount of item nodes within each configuration node.
An error will be found in the build log and the the same error will be written to the result file.
Welcome to GitHub Pages.
This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:
$ cd your_repo_root/repo_name
$ git fetch origin
$ git checkout gh-pages
If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.
Designer Templates
We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.
Rather Drive Stick?
If you prefer to not use the automatic generator, push a branch named gh-pages
to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.
Authors and Contributors
You can @mention a GitHub username to generate a link to their profile. The resulting <a>
element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.
Support or Contact
Having trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.