Bonio Lopez wrote:
> Dear all,
> Following build file fails with " 
>       Expression: SOFTWARE\Microsoft\VisualStudio\${vs_version}\InstallDir
>                                               ^^^^^^^^^^
>     Property 'vs_version' has not been set.
> "
>
> But if remove 'xmlns="http://nant.sf.net/schemas/nant.xsd";' then it works
> without problems.
> Why does xmlns changes scope of properties?
>   
It doesn't.  Here's what's happening:

The xmlns at the top level sets the default namespace for your 
default.build file.  This gets used implicitly for all of the NAnt 
tasks, i.e. when you write <readregistry>, it gets interpreted as if 
readregistry is in the 'http://nant.sf.net/schemas/nant.xsd' namespace.  
But when you include the settings.inc file, it gets processed according 
to XML rules, meaning that the <property> task in settings.inc gets 
interpreted as if that occurrence of property is in the '' namespace.  
In other words, it uses the default namespace for the settings.inc file, 
not the default namespace fo rthe default.build file.  NAnt will ignore 
elements that aren't in the default namespace for the top level file, so 
the <property> in settings.inc is being silently ignored.

The fix is obvious:  Add the xmlns="..." string to the <project> element 
in settings.inc (and all NAnt files you right, whether top level or 
included).  This has the additional benefit that if you're using an XML 
editor that exploits the namespace for completion (e.g. Visual Studio), 
then it will work smoothly in all of the files.

Gary
>
> -----default.build-----
> <project name="SomeName" default="build"
> xmlns="http://nant.sf.net/schemas/nant.xsd";>
>     <include buildfile="..\\buid_scripts\\settings.inc" />
>
>    <target name="build">
>    <readregistry property="__ide.dir" 
>       
> key="SOFTWARE\Microsoft\VisualStudio\${vs_version}\InstallDir" 
>               hive="LocalMachine" />
>               
>    </target>
> </project>
> -----settings.inc-----
> <project>
> <property name="vs_version" value="7.1" overwrite="false"/>
> </project>
>   




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to