Setup Problems

Running NCrunch under Local System account

Started by memark on 7,281 views

I'm trying to set up NCrunch with my TeamCity server. My build agent is running under the Local System account, which seems to cause problems for NCrunch.

Running the NCrunch Console Tool from a command line as a normal user works fine. My solution compiles and all tests are run successfully.

Running the NCrunch Console Tool from a command line as Local System gives an error

[10:38:58.2328-LocalBuildTask-5] ERROR (Build): NCrunchTest: (0): NCrunch was unable to parse this project file because of an unexpected error: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\system32\config\systemprofile\AppData\Local\NCrunch\2588\1\NCrunchTest'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.SetCurrentDirectory(String path)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)


Examining the detailed log, we can see that files are in fact being copied to this directory, so it seems to exist. Some examples of successful events
[10:38:57.9431-LocalBuildTask-5] Building new workspace C:\Windows\system32\config\systemprofile\AppData\Local\NCrunch\2588\1 for component NCrunchTest in context of grid client (local)
[10:38:57.963-LocalBuildTask-5] Writing new workspace member C:\Windows\system32\config\systemprofile\AppData\Local\NCrunch\2588\1\NCrunchTest\Properties\AssemblyInfo.cs (version 1)
[10:38:57.983-LocalBuildTask-5] Copying assembly reference C:\Users\coll-loans-bld\Desktop\NCrunchTest\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll into workspace at C:\Windows\system32\config\systemprofile\AppData\Local\NCrunch\2588\1\_ncrunchreferences\xunit.abstractions.dll (BCL=False)


Please see provided log file.
https://www.dropbox.com/s/dw5vmdj5xu7fhfm/ncrunch-detailed-log.txt?dl=0

Windows Server 2012 R2 Datacenter
NCrunch Console Tool 2.17.0.16

Any idea what the problem might be? Is it related to permissions? Is the folder path simply too long? Is it possible to reconfigure NCrunch to store its workspace somewhere else?

(Not sure how to open a command prompt under Local System? Just download Sysinternals and run "psexec -s cmd" in an elevated prompt.)

Edited

Hi,

I think this is a permissions related issue. It looks as though the NCrunch engine has no trouble creating or accessing this directory (the workspace), but as soon as it tries to access the directory in a build runner process, it can't open it.

The cleanest way to solve this would probably be to set a custom path for your workspace base path. You can do this in your NCrunch configuration file ('WorkspaceBasePath' in the XML). Set the value to a known path, ideally close to the root of your disk (i.e. C:\NCrunchWorkspaces). You can then create the directory yourself and assign a broader set of permissions to it. NCrunch won't ever delete the workspace base path, so this should be a permanent fix (assuming it solves the problem).
Thank you, that worked! I didn't even have to create the directory (since Local System already has high permissions).

However, I would still encourage you to look into this issue. Running TeamCity as Local System is pretty common, and solving this would make integrating NCrunch into TeamCity much easier for a lot of users.

Edited

Post a reply

Log in to reply.