Ah! Thanks kindly for the info! Sounds like I'm doing weird/odd stuff.
What can I say, I'm just a cog. :p
I'd looked at the <asminfo> task, but my boss wants me to update the
file in place, as opposed to recreating it each time. I don't suppose
there's a way to load an existing assemblyinfo file into the <asminfo>
task? Otherwise, the <script> tag looks like the way to go.
Regards,
John W. Ellenberger
Senior Programmer/Analyst
Geac Commercial Systems Division
-----Original Message-----
From: Ian MacLean [mailto:[EMAIL PROTECTED]
Sent: Monday, December 06, 2004 21:43
To: John Ellenberger
Cc: [EMAIL PROTECTED]
Subject: Re: [Nant-users] LoadFile in .85 RC1
John Ellenberger wrote:
> I'm hoping someone can help answer a question in regards to the
> LoadFile task. It's actually not the task itself, but associated
> functionality. Here's the dilemma:
>
> I'm checking an AssemblyInfo.vb file out, and want to update the
> 'AssemblyVersion' key with the value from version (from NantContrib)
> that I keep track of. I've done some fairly ugly string manipulation
> to get it right, but now I have a fairly big issue. How to I write
> the contents of a property out to a file?? :p Am I missing something?
>
> If anyone is interested, here's the code to do the parse:
>
> <loadfile file="${solutionBaseDirectory}AssemblyInfo.vb"
> property="assembly_file" />
> <property name="searchString" value="AssemblyVersion(" />
> <if test='${string::contains(assembly_file, searchString)}'>
> <property name="totalLength"
> value="${string::get-length(assembly_file)}" />
> <property name="lengthOfLineStart"
> value="${string::index-of(assembly_file, searchString) + 17}" />
> <property name="endOfLine"
> value="${string::substring(assembly_file, lengthOfLineStart,
> int::parse(totalLength) - int::parse(lengthOfLineStart))}" />
> <property name="endOfLineStart"
> value="${string::index-of(endOfLine,')')}" />
> <property name="endOfLineLength" value="${int::parse(totalLength) -
> int::parse(endOfLineStart)}" />
> <property name="assembly_file_beginning"
> value='${string::substring(assembly_file, 0, lengthOfLineStart)}' />
> <property name="assembly_file"
>
value='${assembly_file_beginning}${sys.version}${string::substring(assem
bly_file,
> int::parse(totalLength) - int::parse(endOfLineStart),
> int::parse(endOfLineStart))}' />
> <!-- determine how to save file out -->
> </if>
wow ! - I've never seen the nant expression language used in quite that
way.
I'd seriously consider using either:
- the AssemInfo task
(http://nant.sourceforge.net/release/latest/help/tasks/asminfo.html) or
- an inline script using the script task
(http://nant.sourceforge.net/release/latest/help/tasks/script.html)
<asseminfo> allows you to do what you are after using a built in task
and with <script> you can use any .Net code which will be much easier (
and clearer ) than trying to use NAnt as a procedural programming
language.
Ian
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users