I removed dnxcore50 from project.json and added an empty class library to solution. When I add reference to class library, project build correctly but when I want to publish project, I will get this error:
The expected lock file doesn't exist. Please run "dnu restore" to generate a new lock file
dnu restore command also not helps.
If i remove reference to class library, publish works fine.
project.json:
{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-AdsProject-e7d42575-2bc4-4316-881a-236435c407a1",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta7",
"EntityFramework.SqlServer": "7.0.0-beta7",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
"Microsoft.Framework.Logging": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.Framework.Logging.Debug" : "1.0.0-beta7",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary": "1.0.0-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
Be sure you resolved all reference warnings and don't mix different beta versions.
Are both versions still in beta7 incl your visual studio??
Try upgrade to beta 8 all projects, dnvm,dnx and visual studio
See the home repro
I know this is a bit late. I had the exact same issue on beta 7 today. And only with custom libs added.
I got it fixed by going into the folder called "wrap" that gets created when you add your library. In there you'll find a project.json. Run a dnu restore on that folder in cmd.
Worked like a charm for me.
Related
New ->Project -> Asp.net Web Application
Asp.net Preview Template -> Web Application
When I try to add reference "Signalr" in "MVC6" application I am getting this error
MVC6 D:\abc\abc\MVC6\MVC6\src\MVC6\project.json 29"
Project.json File
[![{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-MVC6-1f7e65af-9175-4945-8e68-ee0805d494e9",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
"Microsoft.AspNet.SignalR": "2.2.0"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { }
},
"exclude": \[
"wwwroot",
"node_modules",
"bower_components"
\],
"publishExclude": \[
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
\],
"scripts": {
"prepublish": \[ "npm install", "bower install", "gulp clean", "gulp min" \]
}
}][1]][1]
[1]: http://i.stack.imgur.com/wMvK6.png
Severity Code Description Project File Line
Error Dependency Microsoft.AspNet.SignalR >= 2.2.0 could not be resolved MVC6 D:\abc\abc\MVC6\MVC6\src\MVC6\project.json 29"
Version 2.2.0 of SignalR is only for classic .Net framework, ASPNET Core will use version 3.0.0, still in beta.
I want to use the Entity Framework 7 in my ASP.NET Core 1 application to connect to a PostgreSQL database.
If I add EntityFramework.Commands (7.0.0-beta5) and EntityFramework7.Npgsql (3.1.0-rc1-3) to my project.json file:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
"EntityFramework7.Npgsql": "3.1.0-rc1-3"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
I get errors in my Startup.cs
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
namespace Suplim.Web.Platform
{
public class Startup
{
public IConfiguration Configuration { get; set; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage(ErrorPageOptions.ShowAll);
}
else
{
app.UseErrorHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
Then Visual Studio says that in my Startup.Configure() method it can not find the methods:
app.UseBrowserLink
app.UseErrorPage
app.UseErrorHandler
app.UseStaticFiles
app.UseMvc
It says
Core DNX 4.5.1 not available
Core DNX Core 5 available
But both packages are loaded and available in the Visual Studio references structure (DNX 4.5.1 and DNX Core 5).
If I remove the EntityFramework.Commands and EntityFramework7.Npgsql packages everything works fine.
Why does the Entity Framework affect my Startup class? Are the versions incompatible (beta5 and rc1-final)? If yes what can I do?
I do not understand the problem.
You are using an rc1 package for EF and beta5 for anything else. You can't mix package versions. Move everything to rc1 (beta5 is a thing of the past) and use the rc1 runtime (dnx) otherwise things will break.
I have already tried to set the same version to all packages but some packages are still beta-* and others are rc1-final. These are the newest packages (I removed the EntityFramework7.Npgsql and other not needed packages for testing):
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final"
},
And my global.json is now:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-final",
"runtime": "clr",
"architecture": "x86"
}
}
Now it can not find the EntityFramework.Commands and Microsoft.AspNet.Mvc packages (both with different version number than 1.0.0) in the DNX 4.5.1 reference. In the DNX Core 5 reference it finds nothing, all packages are unresolved.
It is like the old DLL hell ...
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"
needs to be changed to
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"
As the other responder says you are mixing and matching. You should have everything on the same version or don't use it.
I have the following project.json file...
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta5",
"EntityFramework.SqlServer": "7.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands",
"gen": "Microsoft.Framework.CodeGeneration"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
},
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
I am trying now to do some MVC 6 Controller Scaffolding in command line but after executing the command:
dnx gen controller -name ClassController --dataContext
RegistrationDbContext --model Class
However, I am getting the following error message...
EDIT: This is the message that I am getting after installing Microsoft.Framework.CodeGeneration package (Install-Package Microsoft.Framework.CodeGeneration -Pre)
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Framework.Runtime.ILibraryManager' while attempting to activate 'Microsoft.Framework.CodeGeneration.DefaultCodeGeneratorAssemblyProvider'.
at Microsoft.Framework.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Framework.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProviderprovider, Object[] parameters)
at Microsoft.Framework.CodeGeneration.ServiceProvider.AddServiceWithDependencies[TService,TImplementation]()
at Microsoft.Framework.CodeGeneration.Program.AddCodeGenerationServices(ServiceProvider serviceProvider)
at Microsoft.Framework.CodeGeneration.Program..ctor(IServiceProvider serviceProvider)
Any pointers? How can I fix that?
In any case, this is my global.json too..
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta5",
"runtime": "clr",
"architecture": "x64"
}
}
Thanks!
In rc1-final, the namespaces have changed :
FROM: Microsoft.Framework.CodeGeneration
TO: Microsoft.Extensions.CodeGeneration
project.json
"dependencies": {
...
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
}
"commands": {
...
"gen": "Microsoft.Extensions.CodeGeneration"
}
To customize the MVC6 scaffolding templates, you will find them in the folder: C:\Users\{user}\.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\1.0.0-rc1-final\Templates
Use dnx gen controller --help to get some help on the parameters
When I use the command
dnx ef
the following error occurs:
C:\Users\Livio\OneDrive\Informatik\Websites\HomeNetwork\src\HomeNetwork.API>dnx ef
System.ArgumentNullException: Value cannot be null.
Parameter name: appEnv
at Microsoft.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.Data.Entity.Commands.Program..ctor(IServiceProvider > serviceProvider, IApplicationEnvironment appEnv, ILibraryManager libraryManager, > IRuntimeEnvironment runtimeEnv)
I'm using dnvm 1.0.0-beta8 coreclr x86.
My project.json looks like this (in HomeNetwork.API)
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"EntityFramework.SqlServer": "7.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
I created this project without editing the code, expect adding the EF7 Dependency.
I'm using dnvm 1.0.0-beta8 coreclr x86.
Then, you should use the beta8 versions of the dependencies:
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta8",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
"EntityFramework.SqlServer": "7.0.0-beta8",
"EntityFramework.Commands": "7.0.0-beta8"
}
This question already has an answer here:
Specify the application base path in ConfigurationBuilder in beta8
(1 answer)
Closed 7 years ago.
Using VS 2015 with beta 8 of MVC, I receive the following error
"Severity Code Description Project File Line
Error CS1503 Argument 1: cannot convert from 'string' to 'Microsoft.Framework.Configuration.IConfigurationProvider' NewInventory.DNX Core 5.0 F:\Projects\NewInventory\src\NewInventory\Startup.cs 35
from this portion of my startup.cs:
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
// This reads the configuration keys from the secret store.
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
When I hover over ConfigurationBuilder I can see its looking for'ConfigurationBuilder.ConfigurationBuilder(params IConfigurationProvider[] providers)'
How do I change the appEnv.ApplicationBasePath to an IConfigurationProvider array?
my project.json is:
{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-NewInventory-f5a8bab7-e95b-485b-97e9-9a072438b107",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.SqlServer":"7.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
"Microsoft.AspNet.Identity.EntityFramework":"3.0.0-beta8",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Binder": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
},
"configurations": {
}
}
There is no more constructor of ConfigurationBuilder having appEnv.ApplicationBasePath as argument, but instead there is SetBasePath method.
So change your code to:
var builder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);