Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Step 1</strong>: Define a property in your NAnt script to track the environment you're building for (local, test, production, etc.).</p> <pre><code>&lt;property name="environment" value="local" /&gt; </code></pre> <p><strong>Step 2</strong>: If you don't already have a configuration or initialization target that all targets depends on, then create a configuration target, and make sure your other targets depend on it.</p> <pre><code>&lt;target name="config"&gt; &lt;!-- configuration logic goes here --&gt; &lt;/target&gt; &lt;target name="buildmyproject" depends="config"&gt; &lt;!-- this target builds your project, but runs the config target first --&gt; &lt;/target&gt; </code></pre> <p><strong>Step 3</strong>: Update your configuration target to pull in an appropriate properties file based on the environment property.</p> <pre><code>&lt;target name="config"&gt; &lt;property name="configFile" value="${environment}.config.xml" /&gt; &lt;if test="${file::exists(configFile)}"&gt; &lt;echo message="Loading ${configFile}..." /&gt; &lt;include buildfile="${configFile}" /&gt; &lt;/if&gt; &lt;if test="${not file::exists(configFile) and environment != 'local'}"&gt; &lt;fail message="Configuration file '${configFile}' could not be found." /&gt; &lt;/if&gt; &lt;/target&gt; </code></pre> <p>Note, I like to allow team members to define their own local.config.xml files that don't get committed to source control. This provides a nice place to store local connection strings or other local environment settings.</p> <p><strong>Step 4</strong>: Set the environment property when you invoke NAnt, e.g.:</p> <ul> <li>nant -D:environment=dev</li> <li>nant -D:environment=test</li> <li>nant -D:environment=production</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload