[nunit-discuss] Syntax for /framework flag

8 views
Skip to first unread message

Bryan Call

unread,
Apr 27, 2010, 3:01:29 PM4/27/10
to NUnit-Discuss
I've got a stupid question for you. I'm trying to get the /framework
flag to work to force nunit 2.5.5 to run under .net 4 and I'm having
trouble. Here is what I've tried:

nunit.exe /framework=net-4.0 unittests.dll
nunit.exe /framework:net-4.0 unittests.dll
nunit.exe /framework:4.0.30319 unittests.dll
nunit.exe /framework=4.0.30319 unittests.dll

All of them give me an invalid argument error (it pops up the command
line argument help dialog which doesn't list /framework as an
option).

Here is what I'm trying to do. I want the NUnit gui to run a unit
test assembly in the .NET 4 framework without running it in a separate
process. I like to launch nunit from the debug settings in visual
studio. This causes the process (nunit.exe) to be executed and then
attaches the debugger to it automatically. As it is now nunit is
running my assembly in a seperate process which is not the one visual
studio automatically attaches to.

I know I can manually attach to the correct process but I'm trying to
get this to work automatically like I have done in the past and my
understanding is the /framework flag should do that but I just can't
get it to work right.

Thanks for the help,

Bryan

--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.

Charlie Poole

unread,
Apr 27, 2010, 4:23:26 PM4/27/10
to nunit-...@googlegroups.com
HI Bryan,

On Tue, Apr 27, 2010 at 12:01 PM, Bryan Call <bryan...@gmail.com> wrote:
> I've got a stupid question for you.  I'm trying to get the /framework
> flag to work to force nunit 2.5.5 to run under .net 4 and I'm having
> trouble.  Here is what I've tried:
>
> nunit.exe /framework=net-4.0 unittests.dll
> nunit.exe /framework:net-4.0 unittests.dll
> nunit.exe /framework:4.0.30319 unittests.dll
> nunit.exe /framework=4.0.30319 unittests.dll
>
> All of them give me an invalid argument error (it pops up the command
> line argument help dialog which doesn't list /framework as an
> option).

Not surprisingly, the help display is right. :-) There is no
/framework option to
the nunit.exe command - although there is one for nunit-console. The gui
runner does not need one because it has other ways - such as the File
menu - to load the test using a given framework. By default, as you
have seen, it uses the framework version used in creating the test assembly.

> Here is what I'm trying to do.  I want the NUnit gui to run a unit
> test assembly in the .NET 4 framework without running it in a separate
> process.  I like to launch nunit from the debug settings in visual
> studio.  This causes the process (nunit.exe) to be executed and then
> attaches the debugger to it automatically.  As it is now nunit is
> running my assembly in a seperate process which is not the one visual
> studio automatically attaches to.
>
> I know I can manually attach to the correct process but I'm trying to
> get this to work automatically like I have done in the past and my
> understanding is the /framework flag should do that but I just can't
> get it to work right.

Try setting COMPLUS_Bersion to 'v4.0.30319' in the command that
you run in the debug settings. I think (but I haven't tried it) that it should
work if you use

set COMPLUS_Version=v4.0.30319&<your existing command>

If that does not work, you may need to run a .bat file instead.

[Note for others reading this: Do NOT do this unless you have the
exact issue that Bryan is talking about. It's only needed because
of the specific goal Bryan is trying to achieve.]

Bryan, this would make a reasonable feature request - some way
for NUnit to detect it is under the debugger and to (somehow)
force the alternate process to run under the debugger as well.

Charlie
nunit under the debugger.]

Bryan Call

unread,
Apr 27, 2010, 4:33:55 PM4/27/10
to NUnit-Discuss
Charlie,

I'd be happy to just have the /framework flag work on the gui. Is
there a different place to submit this as a feature request or is this
list the best place? I suspect there isn't an easy way to detect the
debugger is attached though I could be wrong.

Another workaround (I haven't tried yours yet) is to add the startup
required runtime config section to the config file like many of us did
with NUnit 2.5.4. The problem with that is it isn't a good idea if
you plan to run NUnit 2.5.5 with non .NET 4 libraries. For me I am
going to just stick with the previous version of NUnit I was using on
my older projects and only use 2.5.5 with .NET 4 libraries so it will
work for me.

Thanks for the clarification,

Bryan

On Apr 27, 2:23 pm, Charlie Poole <nunit...@gmail.com> wrote:
> HI Bryan,
>
> > For more options, visit this group athttp://groups.google.com/group/nunit-discuss?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
> To post to this group, send email to nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/nunit-discuss?hl=en.

Charlie Poole

unread,
Apr 27, 2010, 4:44:19 PM4/27/10
to nunit-...@googlegroups.com
Hi Bryan,

> I'd be happy to just have the /framework flag work on the gui.

No you wouldn't. ;-)

The framework flag simply tells nunit what runtime to use in a separate
process. It doesn't change the runtime under which NUnit is running.
I suspect you are remembering an older version of the flag which did
have that effect. It was in NUnit for a while and then removed. I revived
it under 2.5 with the slightly different meaning of "framework under
which the tests should run."

> Is
> there a different place to submit this as a feature request or is this
> list the best place?  I suspect there isn't an easy way to detect the
> debugger is attached though I could be wrong.

Use http://bugs.launchpad.net/nunitv2 and flag it as a feature. When
we have a 3.0 gui project, I'll change it to apply to that project. (I
really like that Launchpad lets me do that.)

Actually, System.Diagnostics.Debugger.IsAttached detects the
debugger trivially. I don't know how to run the secondary process
under the debugger, but I'm betting there's a way.


> Another workaround (I haven't tried yours yet) is to add the startup
> required runtime config section to the config file like many of us did
> with NUnit 2.5.4.  The problem with that is it isn't a good idea if
> you plan to run NUnit 2.5.5 with non .NET 4 libraries.  For me I am
> going to just stick with the previous version of NUnit I was using on
> my older projects and only use 2.5.5 with .NET 4 libraries so it will
> work for me.

Yes... that's a valid workaround if you only want to run under 4.0.
Reply all
Reply to author
Forward
0 new messages