Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build .Net 5 in pipeline

I created a new solution 2 weeks ago using .Net 5 RC2. I've upgraded it to the new release (5.0.0). I'm trying to created a standard ASP.Net pipeline to build it, agent pool is Azure Pipelines, and agent specification I've tried both windows-2019 and vs2017-win2016. Both give the same errors as below Why is it trying to use 2.1?

Checking compatibility for System.Composition.AttributedModel 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Checking compatibility for System.Composition.Runtime 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Checking compatibility for System.Composition.TypedParts 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Incompatible packages: 4
Committing restore...
Generating MSBuild file D:\a\1\s\XXX\obj\XXX.csproj.nuget.g.props.
Generating MSBuild file D:\a\1\s\XXX\obj\XXX.csproj.nuget.g.targets.
Writing lock file to disk. Path: D:\a\1\s\XXX\obj\project.assets.json
Writing cache file to disk. Path: D:\a\1\s\XXX\obj\XXX.csproj.nuget.cache
Restore failed in 38.96 sec for D:\a\1\s\XXX\XXX.csproj.
NuGet Config files used:
D:\a\1\Nuget\tempNuGet_3.config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
71 package(s) to D:\a\1\s\XXX\XXX.csproj
##[error]The nuget command failed with exit code(1) and error(NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Errors in D:\a\1\s\XXX\XXX.csproj
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1))
##[error]Packages failed to restore
Finishing: NuGet restore ```
like image 871
waleed Avatar asked Nov 15 '20 19:11

waleed


1 Answers

It was using an older version of Nuget.

I changed it to 5.x before the restore and it works now.

Pipeline yaml

- task: NuGetToolInstaller@1
          inputs:
              versionSpec: 4.x.x

EDIT: Then ran into a problem of build not working because MSBuild 16.8 not released yet. Changed to dotnet build and put Use Dotnet 5 task before it

like image 55
waleed Avatar answered Nov 05 '22 14:11

waleed