Hi Adam, Thanks a lot for your help! It works!
By the way, do you have any experience in working with MSTest (with CCNet of course) ? :) On Jul 14, 5:01 pm, Adam Burton <[email protected]> wrote: > This is the code for reading the log file inside my nant task. > > /////////// > > vbTask.ErrorFile.Refresh(); > if (vbTask.ErrorFile.Exists) > { > string errorOutput = ""; > > StreamReader reader = vbTask.ErrorFile.OpenText(); > > string fileLine; > while ((fileLine = reader.ReadLine()) != null) > { > fileLine = fileLine.Trim(); > > if (fileLine.StartsWith("Compile Error") || > fileLine.StartsWith("Syntax Error")) > errorOutput += fileLine + "\n"; > } > > reader.Close(); > File.Delete(vbTask.ErrorFile.FullName); > > // Only output error messages. If there are some, fail the build. > if (!errorOutput.Equals(String.Empty)) > { > this.Log(Level.Error, errorOutput); > throw new Exception("Error compiling COM. Please see log more > information"); > } > > } > > ////////// > > The if that checks the line is essentially the errors I have come > across so far :-). As we come across others I will just add to the if > (this isn't meant to be super sexy code, just something that gets the > job done). > > I think to convert it to nant it would something like below > > ////////////// > > <property name="vb6.result" value="false"/> > <foreach item="Line" in="mylogfile.log" property="fileLine"> > <property name="fileLine" value="${string::trim(fileLine)}"/> > <if test="${string::starts-with(fileLine, 'Compile Error') || > string::starts-with(fileLine, 'Compile Error')}"> > <property name="vb6.result" value="true"/> > <echo message="${fileLine}" level="Error"/> > </if> > </foreach> > > <fail message="VB6 Build failed" if="${vb6.result == 'true'}"/> > <echo message="VB6 Build succeeded" unless="${vb6.result == 'true'}"/> > > ////////////// > > 2009/7/14 Chapa <[email protected]>: > > > > > > > I'll wait for your code. Thanks. > > > On Jul 13, 11:58 pm, Adam Burton <[email protected]> wrote: > >> On Monday 13 Jul 2009 10:43:46 Chapa wrote: > > >> > Hi Adam, > > >> > Can you explain more detail the way of your decision. I have the log > >> > file after building. How can I get the error and name of the module? > >> > Thanks. > > >> > On Jul 12, 2:51 am, Adam Burton <[email protected]> wrote: > >> > > On Thursday 09 Jul 2009 12:45:04 Chapa wrote:> Hi all. > > >> > > > We still have many VB6 modules compiling with the NAnt tool. When > >> > > > some > >> > > > of them is broken in the e-mail (in errors section) we just have the > >> > > > next message: > >> > > > "External Program Failed: C:\Programme\Microsoft Visual Studio > >> > > > \VB98\VB6.EXE (return code was 1)". > >> > > > But it will be great to know which module is broken exactcly. Is it > >> > > > possible? > >> > > > Can anybody help? I will be glad to any advices. > > >> > > > P.S. My english is not very well but I hope my problem is clear :) > > >> > > Output the VB6 build to a log file, then at the end of your VB6 builds > >> > > or > >> > > on failures (I am thinking trycatch) look through the file for errors > >> > > and > >> > > you can output those details with an error echo then fail the build > >> > > once > >> > > you've completed looking through the fail (or not if you found none). > >> > > That is essentially how I do it. That way I get class name, line > >> > > numbers > >> > > and failure reason in the ccnet log. > > >> The module should be included in the error message (well it will give the > >> filename) along with a line number. I don't have the code in front of me > >> now > >> (but it is not written in NAnt, it is actually a custom nant task that > >> basically produces some temporary project files for us with the > >> dependencies > >> fixed) but I shall look when I get into work tomorrow. I think I just loop > >> through the log files contents and if the line has Error or Warning in it I > >> just echo the line with error or warning set, then for error I also set a > >> flag > >> so that after looping through the log file I know to throw an exception > >> (or for > >> a nant scripts case I would call <fail/>).- Hide quoted text - > > >> - Show quoted text -- Hide quoted text - > > - Show quoted text -
