Scaffolding: .NET 5 RC: Project \obj\project.assets.json' doesn't have a target for 'net50'.

Created on 23 Sep 2020  Â·  2Comments  Â·  Source: dotnet/Scaffolding

Scaffolding works perfect from VS, only the CLI fails

SOLVED

dotnet tool uninstall --global dotnet-ef
Tool 'dotnet-ef' (version '3.1.7') was successfully uninstalled.

dotnet tool install --global dotnet-ef --version 5.0.0-*

Steps to reproduce:

dotnet new webapp -o ContosoUniversity
cd ContosoUniversity

Add the following Student model:

public class Student
{
    public int ID { get; set; }
    public string LastName { get; set; }
    public string FirstMidName { get; set; }
}

Run the following .NET Core CLI commands to install required NuGet packages:

dotnet tool install --global dotnet-aspnet-codegenerator --version 5.0.0-*
dotnet add package Microsoft.EntityFrameworkCore.SQLite -v 5.0.0-*
dotnet add package Microsoft.EntityFrameworkCore.SqlServer -v 5.0.0-*
dotnet add package Microsoft.EntityFrameworkCore.Design -v 5.0.0-*
dotnet add package Microsoft.EntityFrameworkCore.Tools -v 5.0.0-*
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design -v 5.0.0-*
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore -v 5.0.0-*

Scaffold command

dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Data.SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries

Expected behavior:

Scaffold Student

Actual behavior:

error NETSDK1005: Assets file 'c:\tmp\x\ContosoUniversity\obj\project.assets.json' doesn't have a target for 'net50'. Ensure that restore has run and that you have included 'net50' in the TargetFrameworks for your project. [c:\tmp\x\ContosoUniversity\ContosoUniversity.csproj]

See project.assets.json

Build FAILED.

C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1005: Assets file 'c:\tmp\x\ContosoUniversity\obj\project.assets.json' doesn't have a target for 'net50'. Ensure that restore has run and that you have included 'net50' in the TargetFrameworks for your project. [c:\tmp\x\ContosoUniversity\ContosoUniversity.csproj]
0 Warning(s)
1 Error(s)

Environment

Windows 10, fully patched
5.0.100-rc.1.20452.10

Most helpful comment

Hi @en1tan

I had the same issue.

I updated dotnet-aspnet-codegenerator and it worked fine.

please check document

スクリーンショット 2020-12-07 11 59 24

All 2 comments

Facing same issue
Ubuntu 18.04

Hi @en1tan

I had the same issue.

I updated dotnet-aspnet-codegenerator and it worked fine.

please check document

スクリーンショット 2020-12-07 11 59 24

Was this page helpful?
0 / 5 - 0 ratings