I have a Visual Studio 2005 solution/vcproj which has a post-build task that runs unit tests. I want to build it using msbuild.exe.
However, when the tests fail, I do not see any output logged to the console (I've verified that output is logged when executed at the command line.) I can see the output if I use the /v:detailed parameter. Is there a better way to do this? Ideally, I only want to see the output if a test fails.
Thanks.
To answer my own question, the best way I've found is to call msbuild and pass parameters down to vcbuild:
msbuild ... /p:VCBuildAdditionalOptions="/M /logfile:logfile.log" || type logfile.log
So if the build fails, the errors that were logged will be output at the end of the build which is sufficient for me.
Related
Can someone please help. I am trying to trigger a post-build action using the post-build action plugin. The log text that I inputted is returning false, hence not performing a post-build action. When I don't enter any text, it returns true.
This is a simple freestyle project that should print test if it matches the text
Post build setting
This is the console output returning false
Console output returning false
This is the output with no text
Output with no text
Any help will be appreciated. All I want to do is perform a post-build action depending on if my build fails or passes. Alternate solution is welcomed
Thanks
The root cause is your job has no any log out in Job Build Stage, please see Post build task plugin's help, this plugin will search job build log to find the text you specified in plugin.
A quick way to re-try is add a Build Step to print out something:
1. Execture shell (if job executed on Linux machine)
2. Execute windows batch (if job execute on Window machine)
A Job configure example:
I have msbuild script that perfectly working. But when it runs when build task executed I'm seeing all output of building progress.
Is there a way to just write :
Building project ... OK.
instead of 1000 rows of text?
Use verbosity parameter to set log to the level you'd like, e.g.:
msbuild myScript.proj /verbosity:quiet
UPD:
Sorry, that was not clear from the original question, but (from the comments) it looks like you want to have different verbosity levels for different Tasks. I don't think this is supported out-of-the box. You could try 2 solutions:
Run your task using Exec task (see this question for details)
Implement a custom logger and filter messages by task name.
I am using NAnt to run some scrips for a deployment. It has simplified the process a lot. The issue now is that when there is an error I want the NAnt task to run my roll back scripts. However I only know of the option to fail on error for my tasks. Is there any sort of baked in way to set properties on error or to use the the chose statement to redirect the flow of the tasks if a previous task fails?
I found the answer looking for another question about NAnt (error handling in nant build scripts). This will fill the need I have to automatically kick off roll back scripts. Only thing catch is that is not a part of base NAnt but NAntContrib, but that a minor detail.
i want to execute SubWCRev.exe in msbuild to check for local modifications .if local modifications found then i want to display message on command prompt.
please tell me how can i use this.
thanks
Using MSBuild Exec task you can't get the output, so you'll have to write an MSBuild custom task to do that (Or an inline task if you are using MSBuild v4).
In that task you'll execute SubWCRev.exe, parse the result and set it to an output property.
I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on TFS.
In an attempt to make it self contained I would like to start the seleniumRC server only when it's needed from fitness.
I've seen that there is a "Command Line Fixture" but it's written in java can I use that?
I think you might be able to. You can call any process easily in MSBuild using the task. However, the problem with doing this is that the exec task will wait for the Selinium process to finish before continuing, which is not the bahaviour you want. You want to run the process, keep it running during your build and then tear it down as your build finishes.
Therefore, I think you are probably going to need to create a custom MSBuild task to do this. See the following post for an example of a tasks that someone has created that will run asynchronously returning control back to the build script:
http://blog.eleutian.com/2007/03/01/AsyncExecMsBuildTask.aspx
And for an example of calling a Java program from MSBuild (but in this case synchronously) take a look at my task that calls Ant from MSBuild here
http://teamprise.com/products/build/
As part of your MSBuild task, you will want to output the process id that you created to an output property so that at the end of your build script you can call another custom MSBuild task that kills the process. It can do this by looking for the process id passed in as a variable in MSBuild and then call Process.Kill method i.e.
Process process = Process.GetProcessById(ProcessId);
process.Kill();
That said, you would need to be careful to ensure that your kill task was always executed in MSBuild by making sure it was included during error paths etc in the build. You could probably make things a bit more resilient by making the selenium RC starter task look for other seleniumRC processes and killing them before starting a new one - that way if a process didn't get closed properly for some reason, it would only run until the next build.
Anyway - my answer sounds like a lot of work so hopefully someone else will come up with an easier way. You might be able to create the seleniumRC process in the test suite start up of the FitNesse tests and kill it in the suite tear down, or you might be able to write a custom task that extends your FitNesse runner tasks and fires up seleiniumRC asynronously before running the test process and then kills it afterwards.
Good luck,
Martin.
Thanks for your replies!
This is how I've done so far.
I made a fit fixture (very simple) that starts a process with the supplied command line, in my case startSelenium.bat. The fixture returns the ProcessID so I can store that in my fitnesse context and close that session later.
I can now make a SuiteSetUp page in my fitnesse test that looks like this.
|RunCommandFixture|
|Commandline|RunCommand?|
|C:\Projects...\startSeleniumRC.bat|>>seleniumprocess|
and a SuiteTearDown like this
|RunCommandFixture|
|ProcessID|StopCommand?|
|<
That works for me. No selenium RC starts by request from my fitnesse test.
What about writing a simple .NET app that does a Process.Start("selenumRC commandline") which gets run by your build script?
If you aren't too far down the Selenium route; might I suggest that you look at similar .NET browser automation tools; specifically WatiN or ArtOfTest. The "stacks" in these are completely .NET, so getting them running on different machines is much easier.