I upgrade my MVC Core Project from 2.2 to 3.0 with microsoft
and change many recommended here: https://stackoverflow.com/
It works fine when run it in Local, but when I want publish in local folder I get this error :
Assets file 'obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project
Ii have 3 projects and all of them upgrade to MVC core 3.0 also upgrade all packages to 3.0 also remove object folder and bin folder and build projects again, close VS and open it again but the error stil exists.
UPDATE: mvc project csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!--<PackageReference Include="Microsoft.AspNetCore.App" />-->
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0"
/>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Admin\Data\" />
<Folder Include="Areas\Admin\Models\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\project.Model\project.Model.csproj" />
<ProjectReference Include="..\project.Repo\project.Repo.csproj" />
</ItemGroup>
</Project>
My project.Model.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference
Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design"
Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design"
Version="1.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
In our case we had a very similar error when Publishing, after switching from netcoreapp30 to netcoreapp31 as the target Framework. We solved it by:
After that we were able to Publish the project fine.
In your Package Manager Console run the following command: dotnet restore SolutionName.sln
Make sure your Publish Profile says netcoreapp3.0 for the TargetFramework.
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