简体   繁体   中英

Reference netcoreapp1.0 from normal .net 4.6.2 unit test project

I have 2 projects. One is a .Net Core Console App and one is a normal Unit Test Project.

I want to add a Reference to the .Net Core App from the Unit Test Project.

When I try to add a reference to the Project, I get the following error:

A reference to '{0}' could not be added. An assembly must have a 'dll' or 'exe' extension in order to be referenced.

When I then add a reference to the produced dll inside the bin folder, I can write my tests without any compile time errors, but the Tests won't show up in the Test Explorer.

As soon as I remove the reference to the dll, And comment out any code relying on that dll, all Tests show up in the Test Explorer.

What do I have to do to make my Tests show up in the Test Explorer?

This is my project.json in the Console App:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true,
    "allowUnsafe": true
  },

  "dependencies": {
    "adremes.Data": "1.0.0",
    "MailKit": "1.10.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.Relational": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.Extensions.Configuration": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.NETCore.App": "1.1.0",
    "Newtonsoft.Json": "9.0.1"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  },

  "runtimes": {
    "win7-x64": {}
  }
}

I had the same issue. I solved it by manually adding a reference the .Net Core dll to the Unit test project. Hopefully this will be solved in VS2017.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM