ASP.NET Core MVC app fails to publish after changing target framework

隐身守侯 提交于 2019-12-13 08:20:11

问题


I have an MVC Core application where the target framework was .NET Core 2.0. It built, ran, and published perfectly. Then I installed the Core SDK 2.1 and upgraded the target framework to .NET Core 2.1. Now the app still builds fine, but when I try and publish it, I get the following error:

Assets file 'C:\Projects\QuickDrive\Code\QuickDrive.Mvc\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project.

I have tried deleting project.assets.json but the publish still fails. What is wrong here, and what can I do to resolve this and get my app published? Why is VS looking for "a target for '.NETCoreApp,Version=v2.0'" when I've set the target framework to 2.1?

I am using VS 2017 v15.6.6 and have also tried an often recommended dotnet restore.


回答1:


This doesn't explain the cause of the error, and even though this question seems so disliked, I'm posting what solved my problem in case anyone else experiences the same thing, and the same solution works for them.

A simple but huge VS2017 upgrade from v15.6.6 to v15.7.3 solved the problem.



来源:https://stackoverflow.com/questions/50836389/asp-net-core-mvc-app-fails-to-publish-after-changing-target-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!