I am trying to update my net core project to 1.1-preview as well as EF core to the same version. Restoring the project.json works fine, but once I try to use commands like Add-Migration it fails with this error:
Commands could not invoke on target framework 'netcoreapp1.1'.
Commands on ASP.NET Core and .NET Core projects currently only support .NET Core ('netcoreapp1.0') or .NET Framework (e.g. 'net451') target frameworks.
project.json of small console App to test
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0-preview1-*"
},
"Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Design": "1.1.0-preview1-final"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final"
},
"frameworks": {
"netcoreapp1.1": {
"imports": "dnxcore50"
}
}
}
I am using Visual Studio 2015. Am I missing something or is EF/.net Core 1.1 not supported by the Visual Studio tools right now?
On EF/.net 1.0 it already does not recognize the Add-Migration or dotnet-ef commands, so to get them to work I have to initialize the EF tools manually as decribed here: https://stackoverflow.com/a/37876143/3506081
I also tried using the Microsoft.EntityFrameworkCore.Tools.DotNet as suggested in the release post but that has same issue that it does not recognize dotnet-ef.
Anyone got similar issues?
I found out that you can do that using the command line, so not within Visual Studio Package Manager Console (strange not sure why).
Keep in mind that the commands are not exactly the same, so for creating a migration for instance this is how you would do it:
dotnet ef migrations add InitialMigration
I'm also using:
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
and removed the old tools.
I believe that the tooling has not been updated yet to work with Entity Framework Core 1.1 Preview 1. So, what I did as a work around is to change framework version to netcoreapp1.0, do whatever commands I want to run on database, then revert to latest targeted framework.
This thread shreads some light over this situation.
The tooling is dependent on a certain MSBuild version so make sure that the tools version have the same version. I've got it running on Mac OSX Sierra
.csproj
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-msbuild1-final</Version>
</DotNetCliToolReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-msbuild1-final</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<Version>1.0.0-msbuild1-final</Version>
</PackageReference>
After changing the .csproj make sure to run dotnet clean && dotnet restore. In case it fails try rm -rf obj/
Also
Related
I am getting this error when I use the -LockMode switch with the nuget restore command.
NU1004: The packages lock file is inconsistent with the project
dependencies so restore can't be run in locked mode. Disable the
RestoreLockedMode MSBuild property or pass an explicit
--force-evaluate option to run restore to update the lock file.
What I am trying to achieve is to automatically upgrade my nuget references by using wildcards but use specific versions when I want to re-build my project from known sources. this blog posts describes how this can be achieved Enable repeatable package restores using a lock file.
When I use -UseLockFile & -LockMode on a simple solution with just one project it works as expected, the issue arises when I start adding another project to the solution.
Here're the steps:
I have published my package to an Azure DevOps feed and I have the following versions listed:
1.0.1-ci.1
1.0.1-ci.2
I have created a .Net 3.1 console app that references my package using wild cards, i.e. <PackageReference Include="My.Package" Version="1.0.*-ci.*" />
Running the command nuget restore -UseLockFile -ForceEvaluate creates the packages.lock.json with the right reference (I am using -ForceEvaluate in order to ensure it always resolves to the latest version available on the feed), the contents of the lock file of my console project are:
{
"version": 1,
"dependencies": {
".NETCoreApp,Version=v3.1": {
"My.Package": {
"type": "Direct",
"requested": "[1.0.*-ci.*, )",
"resolved": "1.0.0-ci.2",
"contentHash": "4HQuN7LNoZT9Z+MOL/Yig79FehhXBZmi26j3VtWR9Cgz8k5irWspSQ8aasVbNkYp7AgA2XaDQdr/cnwJnPilpQ=="
}
}
}
}
I then publish a new version of My.Package (1.0.1-ci.3) and run the command nuget restore -LockedMode, and the version resolved is still 1.0.1-ci.2, and if I then run nuget restore -ForceEvaluate it will resolve as expected to 1.0.1-ci.3, so far so good!
The issue arises when I add a class library to my solution which uses the same package reference, i.e. <PackageReference Include="My.Package" Version="1.0.*-ci.*" />, when I run restore -UseLockFile -ForceEvaluate my packages.lock.json file is updated to include the project dependency:
{
"version": 1,
"dependencies": {
".NETCoreApp,Version=v3.1": {
"My.Package": {
"type": "Direct",
"requested": "[1.0.*-ci.*, )",
"resolved": "1.0.0-ci.3",
"contentHash": "4HQuN7LNoZT9Z+MOL/Yig79FehhXBZmi26j3VtWR9Cgz8k5irWspSQ8aasVbNkYp7AgA2XaDQdr/cnwJnPilpQ=="
},
"classlibrary1": {
"type": "Project",
"dependencies": {
"My.Package": "1.0.0-ci.0"
}
}
}
}
}
While the contents of the lock file of the Class Library project are:
{
"version": 1,
"dependencies": {
".NETCoreApp,Version=v3.1": {
"My.Package": {
"type": "Direct",
"requested": "[1.0.*-ci.*, )",
"resolved": "1.0.0-ci.3",
"contentHash": "4HQuN7LNoZT9Z+MOL/Yig79FehhXBZmi26j3VtWR9Cgz8k5irWspSQ8aasVbNkYp7AgA2XaDQdr/cnwJnPilpQ=="
}
}
}
}
After this when I try running restore -LockMode I get the NU1004 error mentioned earlier.
Doing what the error message suggests and use -ForceEvaluate would clearly break what I wanted to achieve, yet I can't imagine that this relatively simple scenario is not covered by NuGet, so I would guess I am doing something wrong, does anyone have any ideas of what I could try to make this work?
It sounds like you're adding a new dependency then running nuget restore -LockedMode without first running nuget restore -ForceEvaluate.
It's not obvious what NuGet should do in that case - you're telling it you only want to use the dependencies in your lock file but you've also added new dependencies too.
It sounds like this would typically fail the restore:
If locked mode is set, restore will either get the exact packages as listed in the lock file or fail if it cannot. For example, if you updated the defined package dependencies for the project after lock file was created
https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/#why-use-a-lock-file
You might have hit a corner case if the only transitive dependency of your new dependency is one that's already in the lock file but at a different version.
In general though, whenever you add new dependencies you're going to need to update your lock file, then after that you should be set to carry on running nuget restore -LockedMode.
I am trying to learn the basics of ASP.NET Core using this tutorial:
I have created a ASP.NET Core web application
I have upgraded it using instruction from here
Now, I am trying to setup the database migration using dotnet ef migrations add Initial from command prompt within project's folder (where project.json is located):
No executable found matching command "dotnet-ef"
I have changed project.json, so that dotnet-ef works:
"tools": {
...
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
Now, the generation fails with the following error:
The specified framework 'Microsoft.NETCore.App', version
'1.0.0-rc2-3002702' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\shared\Microsoft.NETCore.App
- The following versions are installed:
1.0.0
1.0.1
1.1.0
- Alternatively, install the framework version '1.0.0-rc2-3002702'
Ok, it makes sense, because Microsoft.EntityFrameworkCore.Tools 1.0.0-preview1-final relies on the old version mentioned in the error, as found in the project.lock.json file.
I don't want to downgrade, so I put the latest version of Microsoft.EntityFrameworkCore.Tools I could find:
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
Doing this will lead to the same error:
No executable found matching command "dotnet-ef"
How can I make it work in version 1.1?
Other context information that might be useful:
OS: Windows 7 x64
VS: 2015 Community Edition
Other parts from project.json:
"frameworks": {
"netcoreapp1.1": {
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"runtimes": {
"win7-x64": {}
},
UPDATE [30/3/2017]
The new package is
Install-Package Microsoft.EntityFrameworkCore.Tools
ORIGINAL
Try adding
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4"
}
Additionally here is a tutorial on setting up .Net Core 1.1.0 with EF Core 1.1.0
https://learn.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite
Grierson's answer is ok, but for future reference I will include the whole process until I made it work:
1) Tools.DotNet already suggested in the accepted answer
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4"
}
Ran the same command and received:
Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.
2) Added
//EF Core
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
}
3) Now, the error is:
No parameterless constructor was found on 'ApplicationDbContext'.
Either add a parameterless constructor to 'Application DbContext' or
add an implementation of 'IDbContextFactory' in
the same assembly as 'ApplicationDbC ontext'.
I have chosen to implement the interface. One possible way:
public ApplicationDbContext Create(DbContextFactoryOptions options)
{
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
builder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=Movies;Trusted_Connection=True;MultipleActiveResultSets=true");
return new ApplicationDbContext(builder.Options);
}
The same error occurs when running dotnet ef migrations add Initial
4) I have added a default constructor for ApplicationDbContext class
Now I can add the migration.
EntityFrameworkCore 1.1.0-preview4-final will work only asp.net core 1.1,if you want to move from core 1.0 to core 1.1,look into https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-net-core-1-1/.
I had the same issue.
that's resolved it for me
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
},
You might miss CliToolReference
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
check this
I'm doing a project sample by using ASP.Net Core RC2 with Microsoft.EntityFramework.Core and SQLite.
I've followed this tutorial:
https://damienbod.com/2015/08/30/asp-net-5-with-sqlite-and-entity-framework-7/
But, when I run this command :
dotnet ef migrations add FirstMigration
I got this error :
No executable found matching command "dotnet-ef"
Here is my project.json configuration:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Entity Framework Core 1.0
You should just need to update the tools section of your project.json file to include this:
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
This should make the dotnet ef commands available.
Important
I should also note here that the dotnet ef commands will only be available when running them from the same directory which contains the project.json file.
Entity Framework Core 1.1
If you are having this problem again after upgrading to Entity Framework Core 1.1, be sure to replace the Microsoft.EntityFrameworkCore.Tools dependency with Microsoft.EntityFrameworkCore.Tools.DotNet version 1.1.0-preview4. There is no need to keep the imports section, either. For more information on this, see the "Upgrading to 1.1" heading under the Entity Framework Core 1.1 release announcement blog post.
Entity Framework Core 1.1
Adding in on this if you're using VS2017 with the new .csproj projects without a project.json file
you need to edit the .csproj file (right click it in solution explorer and click edit whatever.csproj) and then paste this in
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-*</Version>
</DotNetCliToolReference>
</ItemGroup>
courtesy of : https://github.com/aspnet/EntityFramework/issues/7358#issuecomment-278379967
Specific to VS2017 15.3 or greater and ASP.NET CORE 2.0 or later...
Install nuget for db provider via command line or nuget package manager.
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
Add following section to .csproj
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
Version="2.0.0" />
</ItemGroup>
Install design time tools via commandline or nuget manager in VS2017.
dotnet add package Microsoft.EntityFrameworkCore.Design
This enables dotnet ef * at the command line in the project directory.
Enables dotnet ef * commands at the command line in the project directory,
dotnet ef migrations add Initial
dotnet ef database update Initial
dotnet ef dbcontext scaffold
This is a common issue when switching from .NET Core 1.0 to .NET Core 1.1+ or 2.x.
To fix that, you need to:
Get the Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.Tools.DotNet package libraries using NuGet.
Manually add a reference to this package within your project.json (for .NET Core 1.0) or <projectName>.csproj (for .NET Core 1.1+ & 2.x) project configuration file.
More specifically, for .NET Core 1.0 projects, add this:
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0"
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0"
}
For .NET Core 1.1+ and .NET Core 2.x projects, add this:
<ItemGroup>
<DotNetCliToolReference
Include="Microsoft.EntityFrameworkCore.Tools"
Version="2.0.0" />
<DotNetCliToolReference
Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
Version="2.0.0" />
</ItemGroup>
If you already have a tools json key or an <ItemGroup> element with one or more existing DotNetCliToolReference elements, just add the new ones to the existing group.
IMPORTANT: other than performing the above steps, you have to launch the dotnet ef command within the project root folder (the one containing the project file), otherwise it won't work.
For additional info and an extensive explanation of the issue you can read more on my blog post.
I think I have found the Accurate solution for the problem - dotnet : No executable found matching command "dotnet-ef"..
I am using dot net core 2.0 in VS 2017 versio 15.5.3
Cause of this error
This error is caused because the Nuget is not able to find the solution file on the location.
Solution:- Move to the directory where you have the 'Startup.cs' class
I Moved to the root by adding the below command on your Package Manager Console.
cd .\School1
Here 'School1' was my root directory of the project, and it contains my 'Startup.cs' class, it will be different in your case.
Then run the command dotnet ef on Package Manager Console which will now run successfully.
Example With Pictures for Clear Understanding
I got error Error when running dotnet ef.
I corrected the error by moving to the root folder with the command cd .\School1
Hope it helps my fellow Dot Net Developers.
I had to add Microsoft.EntityFrameworkCore.Tools.DotNet to work. The tools section of your project.json file will look like this:
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools":"1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
},
If you met this problem and run the asp.net core with CLI tool, you may solve it by adding
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
into xx.csproj file, and
dotnet restore
.
Then you can use dotnet ef command.
In my case dotnet ef wasn't available and not showing in the list when dotnet -h is run.
I've installed globally dotnet-ef with following command and I'm now able to use it. But still not in the list.
dotnet tool install -g dotnet-ef
Instead of opening a separate console window in VS Package Manager Console type and run the following commands:
Add migration
Add-Migration <migration name>
Remove last migration
Remove-Migration
Before a migration has been applied (or, to apply migration):
Update-Database
When migration has been applied:
Update-Database -Migration <previous migration> -Context <db context name>
HTH
EDIT: You may also need the following class in your MVC core project:
public class DbContextFactory : IDesignTimeDbContextFactory<NotesContext>
{
public YourDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<YourDbContext>();
builder.UseSqlServer("DefaultConnection", optionsBuilder => optionsBuilder.MigrationsAssembly(typeof(YourDbContext).GetTypeInfo().Assembly.GetName().Name));
return new YourDbContext(builder.Options);
}
}
I was using a separate class library project. After trying and failing all of above in package manager console. I used command prompt, and it worked! Weird.
However, credit goes to this article.
And if you are using separate class library project, This is your solution.
Under visual studio 2017 i needed to run these commands from package manager console
install-package Microsoft.EntityFrameworkCore.SqlServer.Design
Scaffold-DbContext "Server=.\sqlexpress;Database=MyDb;Trusted_Connection=True;MultipleActiveResultSets=true" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Context "MyApp"
In tools section add below code,
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview2-final",
"imports": "portable-net45+win8+dnxcore50"
}
}
This format of code solved my error.
By default when adding a NuGet Pkg it will be added as a PackageReference, this is wrong, so edit it manually
1- Edit .csproj file
2- change from "PackageReference":
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3"/>
</ItemGroup>
to:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1"/>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3"/>
</ItemGroup>
I have framework version set to: dnx46 in project.json.
Also have the following packages:
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
}
However when I got into running enable-migrations command I get the following:
The term 'enable-migrations' is not recognized as the name of a cmdlet
Does anyone know how I get EF migrations running in latest .NET?
This is what worked for me to solve this issue:
Run:
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
In project.json add this (if not there already) to the "tools" section:
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final",
Useful reference: https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html
As ErikEJ mentioned, there is no "enable-migrations". You will need to use "Add-Migrations" instead. See official docs for EF Core's Powershell commands here: http://docs.efproject.net/en/latest/cli/powershell.html
There appears to be a bug in NuGet and Package Manager Console in some versions of Visual Studio. If cmdlets are not recognized after adding the Commands package, try restarting VS.
Also, dnx commands will not be supported after RC1. New (forthcoming) dotnet tooling will be available for RC2. See https://github.com/aspnet/EntityFramework/issues/3925
The only way I managed to get EntityFrameworkCore.Tools (which includes Add-Migration) working with the latest EF Core & VS 2015 was to manually call the init script from the Package Manager Console like so:
PM> %UserProfile%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview1-final\tools\init.ps1
To add a new migration in EF7 use this command :
dnx ef migrations add YourMigrationUniqueName
There is no "enable-migrations" command in EF Core (EF7).
Just use "add-Migration"
Currently EF migrations are not supported out of the box:
https://github.com/aspnet/EntityFramework/issues/4497
I Haved the same probleam, i was using the PowerShell for the comand, but he work in Package Manager Console.
Try to run in ->
Tools -> NuGet Package Manager -> Package Manager Console
I am developing an asp.net 5 application targeting dnx451.
The asp.net 5 project relies some libraries with unit-tests written for nunit 2.x. So the reasonable choice for me is to use nunit for testing the asp.net 5 project.
When I running the unit test in ReSharper, the ReSharper says "Test not run" with additional message "System.IO.FileNotFoundException: Could not load file or assembly xxx ".
Both nunit 2.6.4 and 3.0.0-beta-2 results the same error.
Any one has successfully running nunit tests against an dnx project?
DNX tests aren't currently supported by ReSharper. It's a whole new execution model, and hasn't yet been implemented for ReSharper. I'd expect to see support as DNX and asp.net stabilise and near release. Also, I don't believe nunit itself supports running as a DNX test runner - the xunit team have a separate project to plug into DNX: https://github.com/xunit/dnx.xunit
NUnit does not support the DNX core.
Follow this issue to see when nunit adds dnx support. https://github.com/nunit/nunit/issues/575
Looks like NUnit has (partial) support as of v3.0.0-RC
http://www.alteridem.net/2015/11/04/testing-net-core-using-nunit-3/
Hopefully, by saying "Especially with ReSharper", you mean that you want to know how to run NUnit tests, and if possible, with ReSharper. That being said, here's how to run NUnit tests against ASP.NET Core (Formerly known as ASP.NET 5) in Visual Studio without needing ReSharper:
Add a new project and choose Console Application (.NET Core). Trying to use class libraries will currently report an error.
Add the latest version of the dotnet-test-nunit NuGet package (Make sure that Include prerelease is checked, or you won't find it in the NuGet feed)
Add the latest version of the NUnit NuGet package.
Edit project.json and add this line: "testRunner": "nunit",
Now you can run your tests by choosing Test - Run - All Tests from the Visual Studio menu.
Your project.json file should look like this:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"dotnet-test-nunit": "3.4.0-beta-1",
"ProjectUnderTest": "1.0.0-*",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"NUnit": "3.4.1"
},
"testRunner": "nunit",
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}