Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

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

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:ProjectsQuickDriveCodeQuickDrive.Mvcobjproject.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...