Gaweringo
Gaweringo
CC#
Created by Gaweringo on 11/2/2023 in #help
`dotnet build` errors NU1202 but building in IDE works
I have Npgsql.EntityFrameworkCore.PostgreSQL as my package for EF and I tried to run dotnet ef migrations add to create a new migration but it returns with Build failed. Use dotnet build to see the errors.. When I then run dotnet build I get this error:
❯ dotnet build
MSBuild version 17.7.3+8ec440e68 for .NET
Determining projects to restore...
C:\...Web.csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Tools 7.0.13 is not compatible with net70 (.NETFramework,Version=v7.0).
Package Microsoft.EntityFrameworkCore.Tools 7.0.13 supports: net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 is not compatible with net70 (.NETFramework,Version=v7.0). Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 supports:
C:\...Web.csproj : error NU1202: - net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: - net7.0 (.NETCoreApp,Version=v7.0)
C:\...Web.csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Tools 7.0.13 is not compatible with net70 (.NETFramework, Version=v7.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 7.0.13 supports: net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 is not compatible with net70 (.NETFramework,Version=v7.0) / win7-x86. Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 supports:
C:\...Web.csproj : error NU1202: - net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: - net7.0 (.NETCoreApp,Version=v7.0)
Failed to restore C:\...Web.csproj (in 157 ms).

Build FAILED.
❯ dotnet build
MSBuild version 17.7.3+8ec440e68 for .NET
Determining projects to restore...
C:\...Web.csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Tools 7.0.13 is not compatible with net70 (.NETFramework,Version=v7.0).
Package Microsoft.EntityFrameworkCore.Tools 7.0.13 supports: net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 is not compatible with net70 (.NETFramework,Version=v7.0). Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 supports:
C:\...Web.csproj : error NU1202: - net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: - net7.0 (.NETCoreApp,Version=v7.0)
C:\...Web.csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Tools 7.0.13 is not compatible with net70 (.NETFramework, Version=v7.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 7.0.13 supports: net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 is not compatible with net70 (.NETFramework,Version=v7.0) / win7-x86. Package Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11 supports:
C:\...Web.csproj : error NU1202: - net6.0 (.NETCoreApp,Version=v6.0)
C:\...Web.csproj : error NU1202: - net7.0 (.NETCoreApp,Version=v7.0)
Failed to restore C:\...Web.csproj (in 157 ms).

Build FAILED.
But when I use the build or run functions in Rider or Visual Studio it builds and runs fine. (Rider also shows errors after running dotnet buildwhich go away after building with rider itself) What I tried: TargetFramework in my .csproj is set to net7.0. I tried net6.0 and I got the same error but with net60.
13 replies