Mandar's blog about .Net & PHP Web Development

  • Archive
  • RSS

How to use C# inside nant build scripts


I use c# to take input from user (via command line) to take certain actions in build script. Here’s code that ask name of web app and will copy necessery files to target directories.

  <target name=”AskAndDeploy”>
        <script language=”C#” prefix=”DNSNamePrefix” >
            <code><![CDATA[
                [Function(“ask”)]
                public string AskDNSNamePrefix(string prompt) {
                    Project.Log(Level.Info, prompt);
                    try
                    {
                        return Console.ReadLine();
                    }
                    finally
                    {
                    }
                }
            ]]></code>
        </script>

        <echo message=”If Your website is called foo.dev.co.uk then enter foo as DNS Prefix. Config files will be updated to point AT http://foo.dev.co.uk ” />
        <property name=”DNSNamePrefix” value=”${DNSNamePrefix::ask(‘What is the web DNS name prefix ?’)}” />
        <property name=”Build.Env.Name” value=”qa” />
        <property name=”Solution.Dir.Path” value=”C:\Projects\phoenix” />

               <copy todir=”\appqawin\projects\${DNSNamePrefix}WS.qa">
          <fileset basedir=”${Solution.Dir.Path}\src\JB.WebService">
            <include name=”**\*”/>
            <exclude name=”**/bin/JB.Common.config” />
           </fileset>
        </copy>

    </target>

  • 6 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

Get 2GB Free Cloud storage

>> Download dropbox


About

I am programmer from London specializing in web based technologies, startups and web 2.0 related stuff.

My Startup

WealthBird

Available for Freelancing work

I am available for .NET contracting work in & around London. Drop me a mail : mandarp1979 at gmail.com

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr