Documentation

Documentation
V5 Documentation

Implicit File Dependencies

Description

When preparing to build a project, NCrunch will copy all known files within the project to a workspace to create a cloned version of the project for background processing.

NCrunch automatically tracks all files that have been included in a .proj file, considering these files to be a part of the project and needing to exist in any isolated workspace built for the project.

Possible Problems

Because NCrunch can only copy files into the workspace that it is aware of, there is a risk that implicitly or ambiguously referenced files may not be copied into the NCrunch workspace. This can create issues when NCrunch builds projects and runs tests, including FileNotFound exceptions or other more obscure problems.

Files missing from NCrunch workspaces account for the vast majority of reported problems when using NCrunch. There are many ways in which projects and tests can reference files on the file system, and not all of these ways can be reliably monitored by NCrunch.

An easy way to confirm whether you have important files missing from a project's workspace is to inspect the contents of the workspace using Windows Explorer, and compare it with the project the workspace was derived from. You can easily open an explorer window over a workspace by right-clicking a project or test in the NCrunch Tests Window, then choosing Advanced->Browse to workspace.

Solutions

Include Referenced Files In The Project

As a matter of convention, it is good practice to ensure all files that are relevant to a project are included in the project's .proj file.

This can also be done for files that exist in an upwards relative path from the .proj file itself - although the only way to specify this is to edit the .proj file directly. For example:

<ItemGroup>
    <None Include="..\Images\ImageFileOutsideProject.png" />
</ItemGroup>

The type of included file (i.e. 'None', 'Content', 'Compile') is of little functional relevance to NCrunch, so when including files in the project, a good approach is often to use the 'None' tag.

Use The Additional Files To Include Configuration Setting

The Additional files to include configuration setting can be used to include a specific file, directory, or range of files into the NCrunch workspace.

This option is a useful alternative to including references to the files directly in the .proj file, and is a far more effective way to specify whole directories of files that need to be included in the workspace.

A situation where this would work particularly well would be where a project is dependent upon a series of build tools or resources that exist upwards from its own directory (i.e. '..\BuildTools\*.*').

The Additional files to include configuration setting can be applied both at project level and solution level.

Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download