Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1048
  • Last Modified:

Problem with NAnt build (can't get filterchain to work)

I'm trying setting up a build-script in Nant (and I'm somewhat of a "NAnt-noob").
In this script I want to copy my entire codebase to a temporary directory, in which I later compile the code. When doing this copy, I want to replace certain keywords in the sourcecode, and for that I'm using "filterchain"s.
The copy works fine, but the filterchain doesn't seem to be executed at all.

Does anyone have any pointers?

I have included the content of my attempts so far in this post. This is of course not my real build, just a mock-up I made to try and isolate the problem (also downloadable from http://openspace.subsero.dk/temp/nant_problem.zip).

The setup is:
---------------
NAnt 0.84 (Build 0.84.1455.0; net-1.0.win32; release; 26-12-2003)

The buildfile:
---------------
<?xml version="1.0"?>
<project name="Deploysource" default="deploysource" basedir=".">
            <property name="ApplicationName" value="MyApplication" />


            <target name="deploysource">
                        <copy file="source/testfile.cs" tofile="target/testfile.cs" inputencoding="utf-8" outputencoding="utf-8">
                                    <filterchain>
                                          <replacestring from="String" to="System.String" ignorecase="true" />
                                          <replacestring from="appName" to="${ApplicationName}" ignorecase="true" />
                                    </filterchain>
                        </copy>
            </target>
</project>


The source file:
---------------
//you are looking at appName

protected String testString = "hello";
0
Rohde
Asked:
Rohde
  • 2
  • 2
1 Solution
 
RohdeAuthor Commented:
Does anyone have an existing NAnt buildscript (which uses filterchain in some form) that they could post or mail me?
That way I would have a working example which I could manipulate to fit my setup. (I can't find any in the samples that come with NAnt)
0
 
MudieCommented:
http://nant.sourceforge.net/release/0.85-rc1/sdk/NAnt.Core.Filters.FilterChain.html
(taken from above link)
" Replace all occurrences of @NOW@ with the current date/time and replace tabs with spaces in all copied files."
<property name="NOW" value="${datetime::now()}" />
<copy todir="out">
    <fileset basedir="in">
        <include name="**/*" />
    </fileset>
    <filterchain>
        <replacetokens>
            <token key="NOW" value="${TODAY}" />
        </replacetokens>
        <tabstospaces />
    </filterchain>
</copy>

http://weblogs.asp.net/soever/archive/2005/03/17/394985.aspx
(taken from above link)
<project default="go">
<target name="go">
<property name="word" value="nice" />
<loadfile file="input.txt" property="message">
<filterchain>
<replacetokens = "WORD" value="${word}" />
</filterchain>
</loadfile>
<echo message="${message}" />
</target>
</project>

Hope that helps!
0
 
RohdeAuthor Commented:
Thanks Mudie,
Not your fault of course - but none of the examples worked :o)

crash:
<replacetokens = "WORD" value="${word}" />

property name should be TODAY:
<property name="NOW" value="${datetime::now()}" />
.....
<token key="NOW" value="${TODAY}" />

But never mind - when fixed, they both work.... the weird thing is that now my original sample (http://openspace.subsero.dk/temp/nant_problem.zip) also works !
I think it was propably a version issue. Filterchain is a 0.85 addition and I was using 0.84, but even after upgrading, it still didn't work. Quite weird, but I'm happy it works now :-)

I'm willing to give you partial credit for your effort Mudie, if someone can tell me how. In the faq it says "click the 'Split Points' link", but I can't see any such link.


0
 
MudieCommented:
Split Points would split points between two experts. I'm the only person who responded so that could explain why it's not showing up.
I'm glad it's working now. ;)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now