我已将ASP.NET Core 2.2项目迁移到Core 3.0,并收到错误消息:
项目[项目位置]必须为Configuration提供一个值。
该错误消息并没有太多内容,有人知道如何解决该错误吗?
这看起来可能类似于this issue on the dotnet cli github repo。
答案 0 :(得分:44)
原来的问题是,我仍然在.proj文件的程序包引用中引用Microsoft.AspNetCore.Razor.Design Version="2.2.0"
。删除该引用(AspNetCore库的一部分现在完全不需要Razor.Design
)解决了该问题。
一旦这样做,我就会收到关于可空对象是与剃须刀不兼容的新功能的数百个错误。那是因为我的.proj文件中有<LangVersion>Latest</LangVersion>
。删除该行解决了该问题,并使项目再次运行。
(根据github线程上的评论,在某些情况下,您可能还需要清理,重建和/或重新启动VS)
如果仍然不能解决问题,则可能是项目使用的NuGet软件包之一。尝试删除依赖项以查看是否可以解决问题,然后一次重新添加一个以找出是哪个NuGet软件包引起的。
答案 1 :(得分:2)
我遇到了同样的问题,并且通过删除以下参考文件解决了该问题:
"Microsoft.AspNetCore.Mvc" Version="2.2.0"
"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.2.0"
答案 2 :(得分:1)
有一个MS文档标题“ Migrate from ASP.NET Core 2.2 to 3.0”。在“更新项目文件”下,状态为
“没有为ASP.NET Core生产大量的NuGet软件包 3.0。此类软件包引用应从您的项目文件中删除。”
作为示例给出的两个是:
在这之后,您可以展开以查看所有不再生产的软件包:
- Microsoft.AspNetCore
- Microsoft.AspNetCore.All
- Microsoft.AspNetCore.App
- Microsoft.AspNetCore.Antiforgery
- Microsoft.AspNetCore.Authentication
- Microsoft.AspNetCore.Authentication.Abstractions
- Microsoft.AspNetCore.Authentication.Cookies
- Microsoft.AspNetCore.Authentication.Core
- Microsoft.AspNetCore.Authentication.OAuth
- Microsoft.AspNetCore.Authorization.Policy
- Microsoft.AspNetCore.CookiePolicy
- Microsoft.AspNetCore.Cors
- Microsoft.AspNetCore.Diagnostics
- Microsoft.AspNetCore.Diagnostics.HealthChecks
- Microsoft.AspNetCore.HostFiltering
- Microsoft.AspNetCore.Hosting
- Microsoft.AspNetCore.Hosting.Abstractions
- Microsoft.AspNetCore.Hosting.Server.Abstractions
- Microsoft.AspNetCore.Http
- Microsoft.AspNetCore.Http.Abstractions
- Microsoft.AspNetCore.Http.Connections
- Microsoft.AspNetCore.Http.Extensions
- Microsoft.AspNetCore.HttpOverrides
- Microsoft.AspNetCore.HttpsPolicy
- Microsoft.AspNetCore.Identity
- Microsoft.AspNetCore.Localization
- Microsoft.AspNetCore.Localization.Routing
- Microsoft.AspNetCore.Mvc
- Microsoft.AspNetCore.Mvc.Abstractions
- Microsoft.AspNetCore.Mvc.Analyzers
- Microsoft.AspNetCore.Mvc.ApiExplorer
- Microsoft.AspNetCore.Mvc.Api.Analyzers
- Microsoft.AspNetCore.Mvc.Core
- Microsoft.AspNetCore.Mvc.Cors
- Microsoft.AspNetCore.Mvc.DataAnnotations
- Microsoft.AspNetCore.Mvc.Formatters.Json
- Microsoft.AspNetCore.Mvc.Formatters.Xml
- Microsoft.AspNetCore.Mvc.Localization
- Microsoft.AspNetCore.Mvc.Razor
- Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
- Microsoft.AspNetCore.Mvc.RazorPages
- Microsoft.AspNetCore.Mvc.TagHelpers
- Microsoft.AspNetCore.Mvc.ViewFeatures
- Microsoft.AspNetCore.Razor
- Microsoft.AspNetCore.Razor.Runtime
- Microsoft.AspNetCore.Razor.Design
- Microsoft.AspNetCore.ResponseCaching
- Microsoft.AspNetCore.ResponseCaching.Abstractions
- Microsoft.AspNetCore.ResponseCompression
- Microsoft.AspNetCore.Rewrite
- Microsoft.AspNetCore.Routing
- Microsoft.AspNetCore.Routing.Abstractions
- Microsoft.AspNetCore.Server.HttpSys
- Microsoft.AspNetCore.Server.IIS
- Microsoft.AspNetCore.Server.IISIntegration
- Microsoft.AspNetCore.Server.Kestrel
- Microsoft.AspNetCore.Server.Kestrel.Core
- Microsoft.AspNetCore.Server.Kestrel.Https
- Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions
- Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
- Microsoft.AspNetCore.Session
- Microsoft.AspNetCore.SignalR
- Microsoft.AspNetCore.SignalR.Core
- Microsoft.AspNetCore.StaticFiles
- Microsoft.AspNetCore.WebSockets
- Microsoft.AspNetCore.WebUtilities
- Microsoft.Net.Http.Headers
答案 3 :(得分:1)
这有点奇怪。
对我来说,问题出在“ Microsoft.AspNetCore.Mvc”软件包。
我将其卸载并安装了“ Microsoft.AspNetCore.Mvc.Core”。
我需要补充一点,我也安装了“ Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation”。