Build/Test Issues

Build errors when referencing Shared Projects

Started by distilled on 5,117 views

I'm currently working on a solution that contains a Shared Project (*.shproj). The shared project is referenced by two class library projects. NCrunch (v3.6.0.2) raises the following error if I don't tell it to ignore the shared project:


NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\CodeSharing\Microsoft.SharedProject.Common.targets (15, 5): Shared projects cannot be built on their own.  Please either build a project that references this project, or build the entire solution.


If I set "Ignore this project completely" to "true" in my NCrunch configuration then changes to the files in the shared project aren't detected properly. For example, if I add a new class named "Foo" to the shared project, NCrunch raises the following error in both class library projects that depend on it:


CSC (0, 0): Source file '%LOCALAPPDATA%\NCrunch\9804\10\src\SharedProject\Foo.cs' could not be found.


I've tried adding the shared project's directory to the list of "Additional files to include" for the solution, but I still receive the above error when adding new files to the shared project. Is there anything else I can do to support this scenario?

Hi,

Shared projects are still a work in progress, so there are some rough edges here. Standard practice at the moment is to always ignore the shared project. The projects that then reference it should have all 'shared' files explicitly included and things should work. Because NCrunch doesn't track the in-memory changes to shared projects, you'll need to save these to disk and reload the referencing projects before they pick up the changes. There shouldn't be any need to make use of the 'Additional files to include' setting here.

Post a reply

Log in to reply.