Hi Evan,

This is a fine way to solve my problem, and it works smoothly, as i
expected. :)

I tried Owen's suggestion of using the asminfo task too, and it worked
as well, but it's a little more verbose than i'd prefer.

Is there any way to put your <target name="StringFunctions"> into the
Nant library of std. tasks, as I can imagine many situations where this
task may be very usefull to me ?

Best regards
/ allan


-----Oprindelig meddelelse-----
Fra: Evan Levy [mailto:[EMAIL PROTECTED] 
Sendt: 20. oktober 2005 18:17
Til: Nielsen.Allan Rene Dystrup AND; nant-users@lists.sourceforge.net
Emne: RE: [Nant-users] Patch version number in AssemblyInfo.cs

I ran into this and wrote a simple generic regex-replace task:

   <target name="StringFunctions">
      <script language="CSHARP" prefix="string" >
         <code>
            <![CDATA[
               [Function("regex-replace")]
               public static string RegexReplace(string strInput, string
strRegex, string strReplace)
               {
                    System.Text.RegularExpressions.RegexOptions options
= ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace
| System.Text.RegularExpressions.RegexOptions.Singleline) |
System.Text.RegularExpressions.RegexOptions.IgnoreCase);        
                  string result = Regex.Replace(strInput, strRegex,
Regex.Unescape(strReplace), options);
                  return result;
               }
            ]]>
         </code>
      </script>
   </target>

For your purpose, you can call it like this:

   <target name="UpdateAssemblyInfo">
      <call target="StringFunctions" />
      <loadfile file="AssemblyInfo.cs" property="contents" />
      <echo file="AssemblyInfo.cs"
message="${string::regex-replace(contents,
'AssemblyVersion\(&quot;\d+\.\d+\..+?&quot;\)', 'AssemblyVersion(&quot;'
+ ver.config + '&quot;)')}" />
   </target>


e



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Nielsen.Allan Rene Dystrup AND
Sent: October 20, 2005 11:27 AM
To: nant-users@lists.sourceforge.net
Subject: [Nant-users] Patch version number in AssemblyInfo.cs

Hi guys,

I'd like to parse my AssemblyInfo.cs file for :

   [assembly: AssemblyVersion("0.2.0.0")] 

and substitute the version (in casu: 0.2.0.0) with a current version# in
property ${ver.config).

I've looked at the nant task 
   <copy> with <filterchain> and <replacestring but it doesn't quite cut
the cheese.

What would be really nice was a regular expression filtering/
substitution, but I haven't found one.

Any suggestions?

Thanks & best regards/
allan







________________________________________________________________________
_______________
www.kmd.dk   www.kundenet.kmd.dk   www.eboks.dk   www.civitas.dk
www.netborger.dk www.organisator.dk

Hvis du har modtaget denne mail ved en fejl vil jeg gerne, at du
informerer mig og sletter den.
KMD skaber it-services, der fremmer effektivitet hos det offentlige,
erhvervslivet og borgerne.

If you received this e-mail by mistake, please notify me and delete it.
Thank you.
Our mission is to enhance the efficiency of the public sector and
improve its service of the general public. 



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads,
discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users




_______________________________________________________________________________________
www.kmd.dk   www.kundenet.kmd.dk   www.eboks.dk   www.civitas.dk   
www.netborger.dk www.organisator.dk

Hvis du har modtaget denne mail ved en fejl vil jeg gerne, at du informerer mig 
og sletter den.
KMD skaber it-services, der fremmer effektivitet hos det offentlige, 
erhvervslivet og borgerne.

If you received this e-mail by mistake, please notify me and delete it. Thank 
you.
Our mission is to enhance the efficiency of the public sector and improve its 
service of the general public. 



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to