Thaoden Thaoden - 10 months ago 112
C# Question

Testing Asp.Net Core on full .NET framework

I want to unit test an core project that targets the full .net framework. I tried using the "normal" unit test project template and a .net core project as outlined in this blog post, but both attempts fail because the assembly of my web-project cannot be referenced in either of the test projects.

Is there a way to unit test core apps on the full framework?


Found the solution in the comments section of the same blog post. As I cannot link directly, it is quoted below:


In case anyone needs to do something similar, I have managed to set this up so I can test my controllers in an ASP.NET Core project that targets the .NET Framework 4.6.1 and also references class libraries that are standard .NET, not .NET core (we will have this hybrid situation for some time!). I am using VS2015 update 3 and .NET Core 1.0. My project.json is:

    "version": "1.0.0-*",
    "testRunner": "mstest",
    "dependencies": {
        "dotnet-test-mstest": "1.0.1-preview",
        "MSTest.TestFramework": "1.0.0-preview",
        "MyASP.NetCoreProject": "1.0.0-*"
    "frameworks": {
        "net461": {
            "dependencies": {
                "MyClassLibrary": {
                    "target": "project"