i've got a question about ant and String split.
In a IniFile i've a section "[app_version]" with 1 element: "VERSION = 3.48".
My goal is to split "3.48" in 3 and 48.
I've try to read the ini file sucessfully with this code and it's work.
<target name="get_new_version_number">
<property file="${basedir}/Ini File/Config.ini" prefix="config.">
</property>
<property name="version_actuelle" value="${config.VERSION}" />
<echo message="version de l'application: ${version_actuelle}"/>
but, how can i split "3.48" witch is my value, in 3 and 48. I need to do this to increment 48 each time i execute the script.
Thanks by advance for your considerations.
Regards.
Simon
thanks for your answer.
I've try your solution but it not work for me because, i've got for result, 3.48.1, 3.48.1.2, 3.48.1.2.3....... etc
I really need to increment "48" so i have to split my value 3.48 with split fonction or something else.
But, again, thanks very much for your time.
regards
Simplest solution would be to read the major number from the ini file and then use the buildnumber task to manage the incrementing number
<buildnumber/>
<echo message="${majorNum}.${build.number}"/>
The Ant addon Flaka provides a split function, f.e. =
<project name="demo" xmlns:fl="antlib:it.haefelinger.flaka">
<property name="yourvalue" value="3.48"/>
<fl:echo>#{split('${yourvalue}', '\.')[0]}${line.separator}#{split('${yourvalue}', '\.')[1]}</fl:echo>
</project>
if you have further requirements -- you mentioned a "need to increment" -- you have to give more details.It's no problem to wrap it in a for loop with Flaka.
Related
Other questions (MSBUILD Splitting text file into lines) mention implementation-specific alternatives, but none seem to directly address how to split a simple string property into an item group based on endlines.
How can you do this? Attempts that didn't work:
<ItemGroup>
<SplitLines Include="$(SourceString.Split('\r\n'))" />
</ItemGroup>: (splits on 'r' or 'n')
<ItemGroup>
<SplitLines Include="$(SourceString.Split('%0A%0D'))" />
</ItemGroup>: (doesn't split at all)
In case you're curious: SourceString is the output of an Exec command that needs splitting, so ReadLinesFromFile isn't an option. It can't output to an intermediary file because file systems are slow and this needs to be used by build processes that care about file operations.
Using property functions is the way to go and you can search for sulutions using e.g. 'C# split string lines' in your search engine of choice, then translate the answer. This comes up with this SO question and the Regex.Split method is the easiest to implement:
<ItemGroup>
<SplitLines Include="$([System.Text.RegularExpressions.Regex]::Split(`$(SourceString)`, `\r\n|\r|\n`))" />
</ItemGroup>
Is it possible to use the ${shortdate} in the internalLogFile?
<nlog internalLogFile="C:\Logs\${shortdate}_nlog.log"
<targets>
<target name="logfile"
fileName="C:/logs/${shortdate}_dev.log"
</target>
I'm getting the expected dated logfile, but the internal log file is named ...
${shortdate}_nlog.log
Short answer: No.
Longer answer: The internal logger file name is just a string. It's read in during initialization and the XmlLoggingConfiguration class ensures that the directory exists whereas (for example) the FileTarget uses a Layout for fileName that converts the value provided using LayoutRenderers.
https://github.com/NLog/NLog/issues/581#issuecomment-74923718
My understanding from reading their comments is that the internal logging should be simple, stable, and used sparingly. Typically you are only supposed to turn it on when trying to figure out whats going wrong with your setup.
You can still dynamically name your internal log file based on the date time if you want. However it won't have the same rollover effect a target file would. It would essentially have a different datetime whenever you initialized your logger I think.
DateTime dt = DateTime.Now;
NLog.Common.InternalLogger.LogFile = #"C:\CustomLogs\NLog_Internal\internal_NLogs" + dt.ToString("yyyy-MM-dd") + ".txt";
I have a xml like shown below
<?xml version="1.0" encoding="UTF-8"?>
<schools>
<city>Marshall</city>
<state>Maryland</state>
<highschool>
<schoolname>Marshalls</schoolname>
<department id="1">
<deptCode seq="1">D1</deptCode>
<deptName seq="2">Chemistry</deptName>
<deptHead seq="3">Henry Carl</deptHead>
<deptRank seq="4">L</deptRank>
</department>
<department id="2">
..
..
..
</highschool>
</schools>
In XSL i am copying the contents from department based on deptCode using
<xsl:copy-of select="*">
This produces result with all the attributes in the element tags.
Is it possible to ignore the attributes while using xsl:copy-of?
The desired result is like shown below
<deptCode>D1</deptCode>
<deptName>Chemistry</deptName>
<deptHead>Henry Carl</deptHead>
<deptRank>L</deptRank>
xsl:valueOf is working as required but i am trying to know if it
can be done with in xsl:copy-of? As a note, in my requirement, there are nearly 5 or 6 attributes for each element. Can someone please help? Thanks in Advance..
regards
Udayakiran
xsl:valueOf is working as required but i am trying to know if it can
be done with in xsl:copy-of?
No. xsl:copy-of is a package deal, you cannot pick and choose. To avoid repetitive coding, use a template matching department/*.
<project name="My Project" queue="1" queuePriority="1">
<labeller type="MyLabeller">
<MyNumber>myProject_${MyNumber}</MyNumber>
</labeller>
<parameters>
<selectParameter name="MyNumber">
<description>Select RC number</description>
<display>RC build</display>
<allowedValues>
<value name="None">0</value>
<value name="data1">1</value>
<value name="data2">2</value>
</allowedValues>
<default>0</default>
<required>true</required>
</selectParameter>
</parameters>
</project>
I wrote a Labeller plugin named MyLabeller. I want when user choose MyNumber in UI when they force a new build. The value of MyNumber will be passed into MyLabeller plugin. I try to use the following syntax but no luck.
myProject_${MyNumber}
If user choose 1, My Number has to be myProject_1.
if user choose 2, My Number has to be myProject_2.
So are there any ways to do this ? Thanks.
p/s: currently, I use cruisecontrol.net version 1.8.4.0
parameter references use square brackets $[parameter name]
Be ware that parameters are not updated for pre-build.
You can also set environemnt variable ... value = $[parameter name] within an executable task but remember the variable value will only exist for the duration of the executable command.
I am looking for a pointer as to how to get statistics out of a merge xml file. The file structure looks like this ..
<CyclometricComplexity>
<module name="Srvr" type="unit" total="14" low="14" medium="0" high="0" ultra="0"/>
</CyclometricComplexity>
I have created a merge publisher to pick up this file, but cannot configure the statistics publisher to pick up values for total, low, medium, high and ultra.
Does anyone have an example they can point me at to help me out?
Thanks
I think I found how to do this. First I needed to understand how XPath works! Then I changed my output tool to create a summary of the entire project, rather than trying to get CCNET to aggregate them together, so the out put now has total, low, medium, etc. for the entire project. Then I changed my statistics section to be as follows ...
<firstMatch name='Total Methods' generateGraph='true' xpath='//CyclometricComplexity/#total'/>
<firstMatch name='Low Complexity' generateGraph='true' xpath='//CyclometricComplexity/#low'/>
<firstMatch name='Medium Complexity' generateGraph='true' xpath='//CyclometricComplexity/#medium'/>
<firstMatch name='High Complexity' generateGraph='true' xpath='//CyclometricComplexity/#high'/>
<firstMatch name='Ultra Complexity' generateGraph='true' xpath='//CyclometricComplexity/#ultra'/>
The stats are now showing in the detailed statistics, and I need to now start asking questions about how to do bespoke graphs!