Unexpected Config File Name Used When Opening csproj File

Bug #517187 reported by cyboc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit V2
Fix Released
High
Charlie Poole

Bug Description

I'm running NUnit 2.5.2.9222 and Visual Studio 2008. I launch the NUnit GUI from with VS 2008 via an External Tool menu item by following the instructions on this documentation page: http://nunit.com/index.php?p=vsSupport&r=2.5.2

For the External Tool's Arguments setting, I use: $(ProjectDir)$(ProjectFileName)

Note that the aforementioned documentation states "...the following command would load the tests using the configuration file nunit.tests.config located in the same directory as the csproj file.: nunit.exe nunit.tests.csproj"

However, contrary to what the documentation says, if my project is named "nunit.tests.csproj", the configuration file "nunit.tests.config" is NOT loaded. Instead, I have found that I must rename my configuration file to "nunit.tests.csproj.config". That is, I have to add ".csproj" in front of ".config".

This requirement to add ".csproj" to the file name is confirmed by outputting the value of "AppDomain.CurrentDomain.SetupInformation.ConfigurationFile" at runtime, which is indeed "nunit.tests.csproj.config".

What is really confusing is that if you click "Project..Edit" in the NUnit GUI, the "Project Editor" dialog shows the Configuration File Name as "nunit.tests.config" (i.e. without the ".csproj").

To summarize, in the case of opening a csproj file, I think either the NUnit GUI should be changed to use the name "nunit.tests.config" or the documentation should be changed to add ".csproj" to the name.

Related branches

Revision history for this message
cyboc (joe-kelly) wrote :

If it helps, I believe the config file name gets set in DomainManager.cs in the method "public AppDomain CreateDomain( TestPackage package)". The relevant code snippet is as follows (starts at line 75 in the DomainManager.cs source code for NUnit-2.5.2.9222):

-----snippet start------
configFile = NUnitProject.IsProjectFile(testFile.Name)
    ? Path.GetFileNameWithoutExtension( testFile.Name ) + ".config"
    : testFile.Name + ".config";
-----snippet end------

In the debugger, I see that the ternary operator test returns false so configFile gets set to testFile.Name + ".config".

Since the value of testFile.Name is "nunit.tests.csproj", the value of configFile becomes "nunit.tests.csproj.config".

Revision history for this message
cyboc (joe-kelly) wrote :

> To summarize, in the case of opening a csproj file,
> I think either the NUnit GUI should be changed to
> use the name "nunit.tests.config" or the documentation
> should be changed to add ".csproj" to the name.

FYI, I don't really have a preference for whether the code or the documentation should be fixed. I just think they should be consistent.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

To clarify the situation, NUnit is working internally with a project nunit.tests.nunit - or at least that's what it would be called if you were to save it. However, the docs say nothing about this, and the need to add csproj to the name was not an intended affect. We should check to see when this error was introduced and reverse it.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Also, this needs to be confirmed against 2.5.3 as well as the latest code.

Changed in nunitv2:
importance: Undecided → High
Changed in nunitv2:
milestone: none → 2.5.5
Changed in nunitv2:
status: New → Triaged
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunitv2:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.