Search code examples
msbuildfilepathnunit-console

Nunit has a path length limitation?


Running Nunit console inside a MSBuild project a command is built in order to execute the tests, that command includes about 90 paths, each one is the full path of a compiled test project (.test.dll) and contains at least 100 characters but no more than 150.

When the script run I got the following error:

NUnit version 2.5.10.11092
 Copyright (C) 2002-2009 Charlie Poole.
 Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
 Copyright (C) 2000-2002 Philip Craig.
 All Rights Reserved.

 Runtime Environment -
    OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
   CLR Version: 2.0.50727.5485 ( Net 2.0 )

 ProcessModel: Default    DomainUsage: Multiple
 Execution Runtime: Default
 Unhandled Exception:


System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Builds\123\XXXX\XXX.Build.Sonar\srcDroplocation\Build\x86\Release\xxxxx.xxxx.CustomTypes.Test.dll'.
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights
 , FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolea
 n bFromProxy)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
    at NUnit.Core.AssemblyReader.CalcHeaderOffsets()
    at NUnit.Core.AssemblyReader..ctor(String assemblyPath)
    at NUnit.Util.RuntimeFrameworkSelector.SelectRuntimeFramework(TestPackage package)
    at NUnit.Util.DefaultTestRunnerFactory.GetTargetProcessModel(TestPackage package)
    at NUnit.Util.DefaultTestRunnerFactory.MakeTestRunner(TestPackage package)
    at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
    at NUnit.ConsoleRunner.Runner.Main(String[] args)

the original path of this file is 'C:\Builds\123\XXXX\XXX.Build.Sonar\src\Droplocation\Build\x86\Release\xxxxx.xxxx.CustomTypes.Test.dll'. The file exists, and I notice that in the exception there is a missing backslash in the path between src and Droplocation.

This issue happens in my build server, in my local machine works, the difference is that in my local machine the folder is not so deep : 'C:\T\XXX\Droplocation\Build\x86\Release\xxxxx.xxxx.CustomTypes.Test.dll'

Is there any restriction regarding the paths for the use of NUnit?

I also try to create a .nunit file in order to put all the references on it but it lead to another issue


Solution

  • Indeed it is bug in NUnit version 2.5.10.11092.

    1. Create a drive unit pointing to C:\Builds\123\XXXX\XXX.Build.Sonar\src\Droplocation

    subst t: C:\Builds\123\XXXX\XXX.Build.Sonar\src\Droplocation

    1. change the $(OutDir) from C:\Builds\123\XXXX\XXX.Build.Sonar\src\Droplocation to t: