gpt4 book ai didi

visual-studio - Nuget 无法更新 .NET Core 项目

转载 作者:行者123 更新时间:2023-12-04 02:08:35 26 4
gpt4 key购买 nike

我安装了 .NET Core 并使用 ASP.NET Core Web 应用程序 (.NET Core) 模板创建了一个新的 VS2015 项目。

这个基本项目编译和运行都很好,在 References 部分下没有任何奇怪的错误。

但是,NuGet 包管理器 UI 标识了十三个更新。我大胆/天真地在 PM 控制台上执行了这个命令:

Update-Package

它输出这个很好的长列表,显示在这个问题的底部(为简洁起见)并更新 project.json 中的版本号。

这是 project.json 的依赖部分:

  "dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
}
},

虽然在解决方案资源管理器中,包版本更新。

enter image description here

当我重建时,我收到大量警告,全部采用以下格式:

warning NU1007: Dependency specified was Microsoft.AspNetCore.Mvc >= 1.1.0 but ended up with Microsoft.AspNetCore.Mvc 1.0.1.

我不明白为什么 NuGet 会更新 package.json,而不是项目引用。而且,我不知道如何手动修复它。虽然 project.json 已更新,但 project.lock.json 未更新,但手动更改版本号会导致警告变为以下形式的错误:

NU1001  The dependency Microsoft.Extensions.Logging.Console >= 1.1.0 could not be resolved.

我正在使用 VS2015 更新 3 和 NuGet 3.5。

我的问题是:

  1. 有没有办法强制 NuGet 更新项目引用,这样我就不会收到这些警告?
  2. 知道为什么会这样吗?
  3. 是否有可靠的解决方法(例如手动编辑某些文件)?

这是 Update-Package 的输出:

Retrieving package 'Microsoft.ApplicationInsights.AspNetCore 1.0.2' from 'nuget.org'.
Retrieving package 'Microsoft.AspNetCore.Mvc 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.AspNetCore.Routing 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.AspNetCore.Server.IISIntegration 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.AspNetCore.Server.Kestrel 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Configuration.EnvironmentVariables 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Configuration.FileExtensions 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Configuration.Json 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Logging 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Logging.Console 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Logging.Debug 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.Extensions.Options.ConfigurationExtensions 1.1.0' from 'nuget.org'.
Retrieving package 'Microsoft.NETCore.App 1.1.0' from 'nuget.org'.
Uninstalling NuGet package Microsoft.ApplicationInsights.AspNetCore.1.0.0.
Successfully uninstalled 'Microsoft.ApplicationInsights.AspNetCore.1.0.0' from WebApplication3
Installing NuGet package Microsoft.ApplicationInsights.AspNetCore.1.0.2.
Successfully installed 'Microsoft.ApplicationInsights.AspNetCore 1.0.2' to WebApplication3
Uninstalling NuGet package Microsoft.AspNetCore.Mvc.1.0.1.
Successfully uninstalled 'Microsoft.AspNetCore.Mvc.1.0.1' from WebApplication3
Installing NuGet package Microsoft.AspNetCore.Mvc.1.1.0.
Successfully installed 'Microsoft.AspNetCore.Mvc 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.AspNetCore.Routing.1.0.1.
Successfully uninstalled 'Microsoft.AspNetCore.Routing.1.0.1' from WebApplication3
Installing NuGet package Microsoft.AspNetCore.Routing.1.1.0.
Successfully installed 'Microsoft.AspNetCore.Routing 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.AspNetCore.Server.IISIntegration.1.0.0.
Successfully uninstalled 'Microsoft.AspNetCore.Server.IISIntegration.1.0.0' from WebApplication3
Installing NuGet package Microsoft.AspNetCore.Server.IISIntegration.1.1.0.
Successfully installed 'Microsoft.AspNetCore.Server.IISIntegration 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.AspNetCore.Server.Kestrel.1.0.1.
Successfully uninstalled 'Microsoft.AspNetCore.Server.Kestrel.1.0.1' from WebApplication3
Installing NuGet package Microsoft.AspNetCore.Server.Kestrel.1.1.0.
Successfully installed 'Microsoft.AspNetCore.Server.Kestrel 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Configuration.EnvironmentVariables.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Configuration.EnvironmentVariables.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Configuration.EnvironmentVariables.1.1.0.
Successfully installed 'Microsoft.Extensions.Configuration.EnvironmentVariables 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Configuration.FileExtensions.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Configuration.FileExtensions.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Configuration.FileExtensions.1.1.0.
Successfully installed 'Microsoft.Extensions.Configuration.FileExtensions 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Configuration.Json.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Configuration.Json.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Configuration.Json.1.1.0.
Successfully installed 'Microsoft.Extensions.Configuration.Json 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Logging.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Logging.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Logging.1.1.0.
Successfully installed 'Microsoft.Extensions.Logging 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Logging.Console.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Logging.Console.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Logging.Console.1.1.0.
Successfully installed 'Microsoft.Extensions.Logging.Console 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Logging.Debug.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Logging.Debug.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Logging.Debug.1.1.0.
Successfully installed 'Microsoft.Extensions.Logging.Debug 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.Extensions.Options.ConfigurationExtensions.1.0.0.
Successfully uninstalled 'Microsoft.Extensions.Options.ConfigurationExtensions.1.0.0' from WebApplication3
Installing NuGet package Microsoft.Extensions.Options.ConfigurationExtensions.1.1.0.
Successfully installed 'Microsoft.Extensions.Options.ConfigurationExtensions 1.1.0' to WebApplication3
Uninstalling NuGet package Microsoft.NETCore.App.1.0.1.
Successfully uninstalled 'Microsoft.NETCore.App.1.0.1' from WebApplication3
Installing NuGet package Microsoft.NETCore.App.1.1.0.
Successfully installed 'Microsoft.NETCore.App 1.1.0' to WebApplication3
Executing nuget actions took 729.79 ms
Time Elapsed: 00:00:08.2056394

最佳答案

你试过了吗dotnet restore

第二件事是你有最新的 .Net Core .尝试下载并安装最新版本的SDK

关于visual-studio - Nuget 无法更新 .NET Core 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41101063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com