473,503 Members | 12,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional build events

I've got a C# project that automatically kicks off NUnit whenever I do
a build. I want to change this so that it only does so when I've got
the Configuration set to NUnit.
Is there any way to either set up the post-build event to be
conditional, or have it be dynamic?
Cheers,
Andy D

Nov 17 '05 #1
4 3786
"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I've got a C# project that automatically kicks off NUnit whenever I do
a build. I want to change this so that it only does so when I've got
the Configuration set to NUnit.
Is there any way to either set up the post-build event to be
conditional, or have it be dynamic?


The way I do it, is in the project settings for your DLL, and with your
NUnit configuration selected, set the Debug Mode to 'Program', then set the
Start Application to 'NUnit-GUI'. You can specifiy command line arguments
separately to load the correct assembly and run it automagically.

If you really want to do it from a post build step, there is a
ConfigurationName macro, can you not use that with the standard bat file IF
conditional?

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
Nov 17 '05 #2
Aaaa, that would be great, if my project wasn't an EXE that I actually
wanted to run a fair bit of the time.

I shall go dig around and find out how IF works in .bat files...

Cheers,

Andy D

Nov 17 '05 #3
The other option is to using compiler directives to exclude the unit
test code unless you have selected the Unit Test configuration.
e.g.
#if UNITTESTS

<<test code>>

#endif

This way the Nunit console will run everytime but it will not have any
work to do unless UNITTESTS is set so will not impact build performance
too much when you don't want to be running the unit tests.

The problem with using a batch file as I see it is that its pretty hard
to tell visual studio when the Unit Tests failed. As the batch file
will always run successfully.

The other advantage of using a compiler directive is that you can then
not include your Unit Test code in your release binaries.

Cheers
Ian

Nov 17 '05 #4
<ia*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
The problem with using a batch file as I see it is that its pretty hard
to tell visual studio when the Unit Tests failed. As the batch file
will always run successfully.


You can run nunit-gui from the batch file, making failures more visible. If
you really want to run the console version, you could write a dinky little
tool that parse the output xml file and pops a message box if there are any
failures - or maybe it could launch NUnit-GUI if there are any problems.

I guess just running NUnit-GUI to start with is probably the best bet..

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1371
by: in | last post by:
In Visual Studio, is there a way of marking a statement as a "conditional run". Sort of like a breakpoint, but there, in the debugger, the statement will not execute. I'm thinking of code...
3
5354
by: Andante.in.Blue | last post by:
Hello everyone! I'm building a form in Access 97 and I want to to show a special icon if the record has been marked as deleted. Obviously, I don't want the icon to show if the record was not...
13
6056
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
1
1592
by: lavu | last post by:
Is there any way to specify a different executable name for my project based on value that I have set in my conditional compilation constant. For eg: If I have FIRST specified in my conditional...
1
2712
by: AlexZh | last post by:
Hi, I'd like to stop command line build by one project build failed. To do that I've created simple AddIn (see code below), that works fine for IDE and does not work for command line. In the AddIn...
8
8461
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
3
4177
by: Goose14 | last post by:
Is there a way to use conditional compilation symbols to change the output path for the build, change the exe name and also change the the exe icon? I have an application that has "skins". I use...
3
3093
by: =?Utf-8?B?Rmxhc2hwcm8=?= | last post by:
i have googled this question but cannot find an answer. i'm running windows vista and i'm using Visual Basic Express 2008. i know the build event button SHOULD be in under the compile tag but i...
7
4301
by: tiptap | last post by:
Hey Guys, I have a huge statement loads of if statements in... and its getting bigger. On closer inspection there is only 3 difference in the select statement. so I thought I could cut the...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.