您如何解决 AspNet Core 缺少依赖项的问题?
How do you troubleshoot AspNet Core missing dependencies?
所以我对我的 project.json 进行了更改,这导致了重新恢复,这带来了一堆无法解决的依赖关系。你怎么知道这里发生了什么?这绝对有效,因为我针对这个 project.json 文件编写了很多代码。
"dependencies": {
"EntityFramework.Commands": "7.0.0-*",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc2-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"AspNet.Security.OAuth.Validation": "1.0.0-*",
"OpenIddict": "1.0.0-*",
"System.IdentityModel.Tokens.Jwt": "5.0.0-rc2-301150021",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15958",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-15958",
"EntityFramework.Sqlite": "7.0.0-rc2-*",
"EntityFramework.Sqlite.Design": "7.0.0-rc1-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*"
}
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.staticfiles/index.json 514ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity.entityframeworkcore/index.json 498ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting.abstractions/index.json 1743ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.authentication/index.json 1745ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.extensions.fileproviders.embedded/index.json 1791ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.extensions.fileproviders.composite/index.json 1859ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity/index.json 1892ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.cors/index.json 1901ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc/index.json 1875ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting/index.json 1887ms
NotFound https://api.nuget.org/v3-flatcontainer/openiddict/index.json 1720ms
OpenIddict 和所有 aspnet-contrib
项目 have been updated to use .NET CLI and the new ASP.NET Core 1.0 packages,所以如果您最近恢复了项目,您可能使用的是最新的夜间构建,需要新的 ASP.NET 和 aspnet -贡献包。
要迁移,install the .NET Core tooling。
您还需要更新您的参考资料以使用 ASP.NET 核心 RC2 包。这是 an updated project.json
的示例:
"dependencies": {
"AspNet.Security.OAuth.GitHub": "1.0.0-alpha4-final",
"AspNet.Security.OAuth.Introspection": "1.0.0-alpha1-final",
"AspNet.Security.OAuth.Validation": "1.0.0-alpha1-final",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"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.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"OpenIddict": "1.0.0-*"
},
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-rc2-24027"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" }
},
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
}
别忘了替换 usings 和 to use the new WebHostBuilder
:
public static class Program {
public static void Main(string[] args) {
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.ConfigureLogging(options => options.AddConsole())
.ConfigureLogging(options => options.AddDebug())
.UseConfiguration(configuration)
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
祝你好运。
首先也是最重要的 - 不要混用包版本。使用所有 rc1 或所有 rc2 等。也不要将 "old"(.AspNet。 - rc1 或更旧)包与新(.AspNetCore。 - rc2 - 尚未发布)包混合。如果您决定使用 rc2 从 dnx 切换到 dotnet。正如@Pinpoint 的回答所指出的,您现在需要使用 aspnetcidev 提要。您可以在 this repo
中的 dotnet 上找到 ASP.Net 核心应用程序 运行 的一些示例
所以我对我的 project.json 进行了更改,这导致了重新恢复,这带来了一堆无法解决的依赖关系。你怎么知道这里发生了什么?这绝对有效,因为我针对这个 project.json 文件编写了很多代码。
"dependencies": {
"EntityFramework.Commands": "7.0.0-*",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc2-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"AspNet.Security.OAuth.Validation": "1.0.0-*",
"OpenIddict": "1.0.0-*",
"System.IdentityModel.Tokens.Jwt": "5.0.0-rc2-301150021",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15958",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-15958",
"EntityFramework.Sqlite": "7.0.0-rc2-*",
"EntityFramework.Sqlite.Design": "7.0.0-rc1-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*"
}
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.staticfiles/index.json 514ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity.entityframeworkcore/index.json 498ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting.abstractions/index.json 1743ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.authentication/index.json 1745ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.extensions.fileproviders.embedded/index.json 1791ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.extensions.fileproviders.composite/index.json 1859ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity/index.json 1892ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.cors/index.json 1901ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc/index.json 1875ms
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting/index.json 1887ms
NotFound https://api.nuget.org/v3-flatcontainer/openiddict/index.json 1720ms
OpenIddict 和所有 aspnet-contrib
项目 have been updated to use .NET CLI and the new ASP.NET Core 1.0 packages,所以如果您最近恢复了项目,您可能使用的是最新的夜间构建,需要新的 ASP.NET 和 aspnet -贡献包。
要迁移,install the .NET Core tooling。
您还需要更新您的参考资料以使用 ASP.NET 核心 RC2 包。这是 an updated project.json
的示例:
"dependencies": {
"AspNet.Security.OAuth.GitHub": "1.0.0-alpha4-final",
"AspNet.Security.OAuth.Introspection": "1.0.0-alpha1-final",
"AspNet.Security.OAuth.Validation": "1.0.0-alpha1-final",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"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.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"OpenIddict": "1.0.0-*"
},
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-rc2-24027"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" }
},
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
}
别忘了替换 usings 和 to use the new WebHostBuilder
:
public static class Program {
public static void Main(string[] args) {
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.ConfigureLogging(options => options.AddConsole())
.ConfigureLogging(options => options.AddDebug())
.UseConfiguration(configuration)
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
祝你好运。
首先也是最重要的 - 不要混用包版本。使用所有 rc1 或所有 rc2 等。也不要将 "old"(.AspNet。 - rc1 或更旧)包与新(.AspNetCore。 - rc2 - 尚未发布)包混合。如果您决定使用 rc2 从 dnx 切换到 dotnet。正如@Pinpoint 的回答所指出的,您现在需要使用 aspnetcidev 提要。您可以在 this repo
中的 dotnet 上找到 ASP.Net 核心应用程序 运行 的一些示例