locked
Cannot add a reference within unit test project to class library under test. RRS feed

  • Question

  • Well I'd assumed (always dangerous these days) that adding a simple unit test project to a solution and then adding my class library project as a reference would be trivial - sadly I was wrong.

    The class library is is - well a class library, targeting .Net 4.5.2, gets built for AnyCPU and builds and runs when consumed by another (simple MVC) project in the solution - that is there are two projects in this solution.

    So I then added a new project of type "Unit Test App (Universal Windows)" to this solution - there are now three projects in the solution, the class library, the simple web app and now the test project.

    Everything builds fine, but then when I try to add a reference in the test project to the class library project it fails, with:

    Unable to add a reference to project 'MyClassLibrary' - a rather dumb and unhelpful dialog if I may say so.

    FYI the test project has no setting for target framework (I looked) but only the following:

    Target:                Universal Windows

    Target version:    Windows 10 (10.0; Build 10586)

    Min Version:        Windows 10 (10.0; Build 10240)

    additionally (and confusingly) the test project's Platform target (a dropdown) is set to x86 and AnyCPU is not listed as a choice.

    Prior to this I initially added the test project as a Unit Test Library (Windows) but this failed also when attempting to add references, in fact various web searches indicated that the project type was the problem and advised adding it instead as a Unit Test App but as you can see this fails in the very same way.

    I'd kind of understand if I was doing something esoteric but this is pretty simple, a simple app, a simple class library and a trivial new unit test project.

    I'm running Visual Studio Enterprise 2015, Update 1 on Windows 10 with developer mode enabled.

    Thank you,

    Korp.

    UPDATE:

    I tried to add the reference not as a project reference but as a direct DLL file reference, this fails but gives more info. It fails with the message:

    A reference to <the DLL> could not be added. The project targets .NETCore while the file reference targets .NETFramework. This is not a supported scenario.

    But as I already explained the the test project's properties seem to offer no choice for the framework target...

    Sunday, May 1, 2016 2:57 PM

Answers