aspnet/Razor

Razor Class Library, error NU1201: Project ... is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project ... supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1)

luboid opened this issue · 3 comments

Hi
I have problem with compiling Razor Class Library which depend on lib Class Library 2.1, Visual Studio don't allow change framework from netstandard2.0 to netstandard2.1 for Razor Class Library

F:\b3next\B3Next.Clients>dotnet build
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for F:\b3next\B3Next.Clients\B3Next.Clients.Web.csproj...
  Restore completed in 62,68 ms for F:\b3next\B3Next.Clients.Interfaces\B3Next.Clients.Interfaces.csproj.
F:\b3next\B3Next.Clients\B3Next.Clients.Web.csproj : error NU1201: Project B3Next.Clients.Interfaces is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project B3Next.Clients.Interfaces supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1)
  Generating MSBuild file F:\b3next\B3Next.Clients\obj\B3Next.Clients.Web.csproj.nuget.g.props.
  Restore failed in 1,06 sec for F:\b3next\B3Next.Clients\B3Next.Clients.Web.csproj.

Build FAILED.

F:\b3next\B3Next.Clients\B3Next.Clients.Web.csproj : error NU1201: Project B3Next.Clients.Interfaces is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project B3Next.Clients.Interfaces supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1)
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.67

F:\b3next\B3Next.Clients>dotnet --version
2.1.402

image

What's the target framework that B3Next.Clients.Web targets? My guess is that it's targeting netstandard2.0 while the project you're referencing (B3Next.Clients.Interfaces) is netcoreapp2.1. You could change the Web project's target framework to netcoreapp2.1 too if that's the issue.

Hi,
Visual Studio don't allow me to set 2.1 version

Project:B3Next.Clients.Web
image

here is test repo:
https://github.com/luboid/test-razor-class-library.git

PS:
If I manually change TargetFramework in B3Next.Clients.Web.csproj from netstandard2.0 to netcoreapp2.1, all is gone in right direction,
but Visual Studio scaffold project with netstandard2.0

@luboid, the way you got it working by manually changing the TargetFramework in the csproj file is fine. Alternatively, there is a different type of class library project, which would target .Net Standard, and that's what you could create from the beginning.