I have a preexisting ASP.NET Core 3.0 application which is successfully deployed to an Azure App Service (using the AspNetCoreModuleV2
module). After upgrading the app to (today's release of) ASP.NET Core 3.1, the application builds and runs correctly on my local version of IIS Express. When I attempt to publish to the Azure App Service using (today's release of) Visual Studio 16.4, however, I receive the following error:
Assets file 'C:\Project\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.0'. Ensure that restore has run and that you have included 'netcoreapp3.0' in the TargetFrameworks for your project.
<PackageReference>
's to Microsoft.AspNetCore
, Microsoft.EntityFrameworkCore
, and Microsoft.Extensions
have been updated to 3.1.0
obj
folder to ensure there aren't any lingering references.3.1.100
version of Microsoft.PackageDependencyResolution.targets
.I get that something is still hanging onto the .NET Core 3.0 dependencies. But it's unclear why that's only causing problems during deployment. Are Azure App Service's not yet ready for .NET Core 3.1? Or is this an issue with the dependency resolution targets?
I got this error from a fresh new net5.0 project in VS2019 (ASP.NET Core Web Application template) when using the VS web-publisher. The solution is as follows:
Open file: {project}\Properties\PublishProfiles\{project} - Web Deploy.pubxml
Add the following line inside the <PropertyGroup>
element:
<TargetFramework>net5.0</TargetFramework>
The element was missing entirely - great work MS
The immediate issue—as identified in the original question—has to do with there being two places where <TargetFramework>
is set:
csproj
)pubxml
)The <TargetFramework>
must be updated in both locations, and they must match exactly. Otherwise, the publishing won't be able to find its targets in the project.assets.json
file, which is built based on the <TargetFramework>
in the csjproj
file.
Note: You may well expect the
pubxml
file to defer to the<TargetFramework>
set in thecsproj
file, but that is not the case.
To make this modification via a text editor,
~/Properties/PublishProfiles
folder. *.pubxml
you wish to edit.<TargetFramework>
to netcoreapp3.1
:<TargetFramework>netcoreapp3.1</TargetFramework>
To make this modification via the Visual Studio 2019 IDE,
netcoreapp3.1
, click the edit icon next to it.netcoreapp3.1
.Warning: When using the IDE, you may run into a problem here. When editing the profile you'll likely see the new value from your project file (i.e.,
netcoreapp3.1
) already selected. When you click Save, however, it will revert back to the original value (e.g.,netcoreapp3.0
in my case). This is because you didn't actually change the value in the interface, which Visual Studio mistakes for there not being a change to the underlying values. If you temporarily toggle another value (e.g., Configuration), then Visual Studio will recognize that a change has occurred, and both values will be updated in the*.pubxml
file.
Thank you, again, to @PanagiotisKanavos for pointing me in the right direction (see comments on original thread).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With