469,631 Members | 986 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Removing a reference from Release build?

Hi,

I'm writing a largish (>60 projects) solution with VS.NET 2003 using VB.NET
as my implementation language. I'm using NUnit and NUnit VS.NET-addin to
implement unit tests for my code.

Currently I have a single UnitTests-project that contains unit tests for all
other projects. This way I can embed all unit testing into a single assembly
which I can use during the development but exclude from a setup that I
create from other projects, thus excluding the unit testing code from the
release-version. This works fine otherwise except it is not very logically
nice to have all the unit testing code inside one project.

BUT: What I would like to do is to embed the unit testing code for each
project inside projects themselves. I would have in each project two folders
"Source", and "UnitTests" that would conveniently separate the unit testing
code from the application code and still retain them in the same project as
they are related.

I think that I can exclude all the unit testing code with a compiler
directive so that none of the unit testing code will be included into the
release-build. That is fine.

But how about the nunit.framework-assembly that I must reference from the
projects? Now it is not a problem as the assembly is referenced only from
the specific UnitTests-project. But if I distribute the unit testing code
into separate projects, each project needs to reference nunit.framework.dll
and I would want leave that reference out from the release build because I
know from the compiler directive that there is no code that actually uses
the nunit-classes in the release build.

So, basically my need would be satisfied if I could say to VS.NET that a
particular reference is to be included only in Debug-build. Or if I could
make the reference conditional, say, depending on a DEBUG-definition
constant.

So, do I have any chance of doing this?

- Petri

PS. I'm not sure if .NET CLR causes problems if a reference DLL is not
present even if I don't refer to it, but I suspect it might.
Nov 22 '05 #1
3 2398
"Petri J. Riipinen" <petri.riipinen@koti.(NOSPAM).soon.fi> wrote

But how about the nunit.framework-assembly that I must reference from the
projects? Now it is not a problem as the assembly is referenced only from
the specific UnitTests-project. But if I distribute the unit testing code
into separate projects, each project needs to reference nunit.framework.dll and I would want leave that reference out from the release build because I
know from the compiler directive that there is no code that actually uses
the nunit-classes in the release build.


Hi Petri, I am doing the same as you do, and AFAIK assemblies are only
referenced when they are _used_ by your project build. VS still copies them
to the target directory, but check your project output's manifest to see the
assemblies actually referenced!

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!

Nov 22 '05 #2
Jens Thiel wrote:
"Petri J. Riipinen" <petri.riipinen@koti.(NOSPAM).soon.fi> wrote

But how about the nunit.framework-assembly that I must reference
from the projects? Now it is not a problem as the assembly is
referenced only from the specific UnitTests-project. But if I
distribute the unit testing code into separate projects, each
project needs to reference nunit.framework.dll and I would want
leave that reference out from the release build because I know from
the compiler directive that there is no code that actually uses the
nunit-classes in the release build.


Hi Petri, I am doing the same as you do, and AFAIK assemblies are only
referenced when they are _used_ by your project build. VS still
copies them to the target directory, but check your project output's
manifest to see the assemblies actually referenced!


The copying is not the problem in the release deployment as I have one
Setup-project which is used to distribute the assemblies to several other
programmers the use the assemblies. Of course the Setup-project suggests
adding the nunit.framework.dll to the project as there is an obvious
dependency inside the VS.NET-project references but I can always exclude the
nunit.framework.dll from the setup project.

Have you verified that although you reference the (nunit.framework?)
assembly in VS.NET and leave out the unit testing code from the
Release-build, there is no need to include the nunit.framework.dll with the
other assemblies?

Ok, will check the manifest as you suggest.

- Petri
Nov 22 '05 #3
> Have you verified that although you reference the (nunit.framework?)
assembly in VS.NET and leave out the unit testing code from the
Release-build, there is no need to include the nunit.framework.dll with the other assemblies?


I have verified it with another assembly, that is only used for a special
edition build, not using any types from that assembly (using #if...). No
problems with that (using VS.NET 2003 and v1.1 if that matters somehow).

Try to remove your reference and see if your project still compiles. Maybe
you have missed to "#if" something?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Petri J. Riipinen | last post: by
3 posts views Thread by Steve Franks | last post: by
11 posts views Thread by Just Me | last post: by
7 posts views Thread by Oldman | last post: by
1 post views Thread by kurt sune | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.