Having wasted a couple of hours on this stupid issue, I thought I’d better note it down here, as I’m bound to hit it again, and will no doubt not remember how to fix it.
I upgraded an ASP.NET Core app from .NET7 to .NET8, and all seemed fine, until I tried to publish it. The published failed with the message shown in the title.
Now given that the app was now targeting .NET8, I couldn’t see why VS was looking for anything related to .NET7.
Turns out that the publish profile includes the target version, and it was still pointing at .NET7. Not sure why VS couldn’t have picked up on this, but it didn’t.
So, all you need to do is look in the Properties\PublishProfiles
folder in your project, and open up any .pubxml
files you find there. You need to update the following line to point at the correct version…
<TargetFramework>net8.0</TargetFramework>
Simple, but not obvious.
Be First to Comment