Eric,

Good observation which I should have mentioned.  The <if> statement in my example is not really necessary--it just suppresses the error message generated by Nant.  The code behaves correctly without the <if> statement as was in my original example.  That is what was so confusing from the beginning--the code worked, but the message made no sense.

Thanks to all for their help and comments.

Ken Parrish
Gomez, Inc.



Eric Fetzer wrote:
That explains a lot.  I always thought, "that message is lying" because, indeed, the property in the file DID get overwritten with my command line entry.  Now that I realize the error is talking about the property statement in the file, I won't call NAnt a lier anymore.  The only reason I put in the property in the file is for a default.  The message doesn't bug me, so I'm ok with this.


 
----- Original Message ----
From: Ken Parrish <[EMAIL PROTECTED]>
To: "Roebuck, Alex" <[EMAIL PROTECTED]>
Cc: nant-users@lists.sourceforge.net
Sent: Monday, March 3, 2008 10:04:58 AM
Subject: Re: [NAnt-users] Command line properties - Can you explainthismessage?

Alex,

Yes, now I see what is going on.  Modified the script as follows to set a 'default' value in the event it is not specified on the command line as such:

<?xml version="1.0"?>

<project name="TestBuild" default="default" basedir=".">

    <if test="${not property::exists('TestProperty')}" >
        <property name="TestProperty" value="foo" />
    </if>

    <target name="*">

        <echo message="TestProperty = ${TestProperty}" />

    </target>

</project>

This elicits the behavior that I want without the error message.

Thanks,

Ken Parrish


Roebuck, Alex wrote:
This also fooled me for a long time.
 
The message saying "cannot overwrite read-only property" refers to the line in the NAnt build file trying to assign to a property that has been assigned on the command-line, not vice versa.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Bob Archer
Sent: Monday, March 03, 2008 4:38 PM
To: Martin Gainty; [EMAIL PROTECTED]; nant-users@lists.sourceforge.net
Subject: Re: [NAnt-users] Command line properties - Can you explainthismessage?

That won’t work because a property set on the command line is read-only by design.

 

(Overwrite by default is already set to true anyhow.)

 

BOb

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Martin Gainty
Sent: Monday, March 03, 2008 11:31 AM
To: [EMAIL PROTECTED] ; nant-users@lists.sourceforge.net
Subject: Re: [NAnt-users] Command line properties - Can you explain thismessage?

 

Hi Ken-

1) you'll need to set overwrite attribute to true e.g.

<property name="TestProperty" value="foo" overwrite="true"/>

2)The user MUST HAVE write privileges to the folder in which he is writing
so user fu can overwrite bar.txt

chown fu bar.txt

HTH

Martin-

----- Original Message -----

From: Ken Parrish

Sent: Monday, March 03, 2008 11:06 AM

Subject: [NAnt-users] Command line properties - Can you explain this message?

 

I am setting a property from the command line.  It seems to work, but I get a message indicating that I cannot overwrite the property, yet the property does in fact get set.  Can anyone help explain this?
______________

Nant Script:

<?xml version="1.0"?>

<project name="TestBuild" default="default" basedir=".">

    <property name="TestProperty" value="foo" readonly="false" />

    <target name="*">

        <echo message="TestProperty = ${TestProperty}" />

    </target>
</project>
______________

Command Line:

nant -D:TestProperty=bar
______________

Output:

NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/Gomez/svn/Source/GPNCore/trunk/Applications/test/test.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: default

 [property] Read-only property "TestProperty" cannot be overwritten.

default:

     [echo] TestProperty = bar

BUILD SUCCEEDED - 0 non-fatal error(s), 1 warning(s)

Total time: 0 seconds.
______________

Thanks,

Ken Parrish
Gomez, Inc.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft (R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users


------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________ NAnt-users mailing list NAnt-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-users



-----Inline Attachment Follows-----

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


-----Inline Attachment Follows-----

_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users



Never miss a thing. Make Yahoo your homepage.




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to