.NET cdproj build requires Microsoft.NETCore.App’, version ‘3.1.0’ in spite of set to `net5.0`

I’ve never touched C# or .NET development before but was thrown into it for a hobby project two days ago, so please bear with my ignorance.

I am updating a .net project from framework version 2 to 5 using microsoft.net.sdk (ver. 8.0.300 [/snap/dotnet-sdk/245/sdk] installed via snap on Ubuntu 22.04)

I also running an azure pipeline to build my code and the agent I use is windows-2019

I can restore the project successfully, but not build.

When building I get an error requiring me to use framework Microsoft.NETCore.App version 3.1.0 even though I specify framework to be net5.0. This prompted me to think one of my packages required that framework so I went through my package list on the .nuget website, but everything looks to be compatible with net5.0.

What am I missing here – any input will be greatly appreciated.

The Error message is:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> CyroinvestPublicAPI -> D:a1sbinDebugnet5.0CyroinvestPublicAPI.dll
Determining projects to restore...
Restored C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjWorkerExtensions.csproj (in 8.68 sec).
WorkerExtensions -> C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjbuildoutMicrosoft.Azure.Functions.Worker.Extensions.dll
##[error]C:UsersVssAdministrator.nugetpackagesmicrosoft.net.sdk.functions3.0.11buildMicrosoft.NET.Sdk.Functions.Build.targets(32,5): Error : It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- The following frameworks were found:
5.0.17 at [C:hostedtoolcachewindowsdotnetsharedMicrosoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64
</code>
<code> CyroinvestPublicAPI -> D:a1sbinDebugnet5.0CyroinvestPublicAPI.dll Determining projects to restore... Restored C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjWorkerExtensions.csproj (in 8.68 sec). WorkerExtensions -> C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjbuildoutMicrosoft.Azure.Functions.Worker.Extensions.dll ##[error]C:UsersVssAdministrator.nugetpackagesmicrosoft.net.sdk.functions3.0.11buildMicrosoft.NET.Sdk.Functions.Build.targets(32,5): Error : It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '3.1.0' was not found. - The following frameworks were found: 5.0.17 at [C:hostedtoolcachewindowsdotnetsharedMicrosoft.NETCore.App] You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64 </code>
  CyroinvestPublicAPI -> D:a1sbinDebugnet5.0CyroinvestPublicAPI.dll
  Determining projects to restore...
  Restored C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjWorkerExtensions.csproj (in 8.68 sec).
  WorkerExtensions -> C:UsersVssAdministratorAppDataLocalTempojp42vr4.spjbuildoutMicrosoft.Azure.Functions.Worker.Extensions.dll
##[error]C:UsersVssAdministrator.nugetpackagesmicrosoft.net.sdk.functions3.0.11buildMicrosoft.NET.Sdk.Functions.Build.targets(32,5): Error : It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
  - The following frameworks were found:
      5.0.17 at [C:hostedtoolcachewindowsdotnetsharedMicrosoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64

and my csproj file looks like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><!--Project Sdk="Microsoft.NET.Sdk.Web"-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AzureFunctionsVersion>v8</AzureFunctionsVersion>
<FunctionsEnableWorkerIndexing>true</FunctionsEnableWorkerIndexing>
<SelfContained>true</SelfContained>
<!--TargetFramework>netcoreapp5</TargetFramework-->
<!--AzureFunctionsVersion>v2</AzureFunctionsVersion-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity"/>
<PackageReference Include="Azure.Security.KeyVault.Secrets"/>
<PackageReference Include="Microsoft.Azure.Functions.Worker"/>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk"/> <!--.NETFramework 4.7.2-->
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http"/>
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5"/>
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication"/>
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.27"/>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/>
<!--PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/-->
<!--PackageReference Include="Microsoft.NET.Sdk.Functions"/-->
<PackageReference Include="npgsql"/>
<PackageReference Include="SendGrid" Version="9.12.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
<PackageReference Include="Microsoft.Azure.Cosmos" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
</code>
<code><!--Project Sdk="Microsoft.NET.Sdk.Web"--> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> <AzureFunctionsVersion>v8</AzureFunctionsVersion> <FunctionsEnableWorkerIndexing>true</FunctionsEnableWorkerIndexing> <SelfContained>true</SelfContained> <!--TargetFramework>netcoreapp5</TargetFramework--> <!--AzureFunctionsVersion>v2</AzureFunctionsVersion--> </PropertyGroup> <ItemGroup> <PackageReference Include="Azure.Identity"/> <PackageReference Include="Azure.Security.KeyVault.Secrets"/> <PackageReference Include="Microsoft.Azure.Functions.Worker"/> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk"/> <!--.NETFramework 4.7.2--> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http"/> <PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5"/> <PackageReference Include="Microsoft.Azure.Services.AppAuthentication"/> <PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.27"/> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/> <!--PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/--> <!--PackageReference Include="Microsoft.NET.Sdk.Functions"/--> <PackageReference Include="npgsql"/> <PackageReference Include="SendGrid" Version="9.12.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" /> <PackageReference Include="Microsoft.Azure.Cosmos" /> <FrameworkReference Include="Microsoft.AspNetCore.App" /> </ItemGroup> <ItemGroup> <None Update="host.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> <None Update="local.settings.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> </Project> </code>
<!--Project Sdk="Microsoft.NET.Sdk.Web"-->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <AzureFunctionsVersion>v8</AzureFunctionsVersion>
    <FunctionsEnableWorkerIndexing>true</FunctionsEnableWorkerIndexing>
    <SelfContained>true</SelfContained>
    <!--TargetFramework>netcoreapp5</TargetFramework-->
    <!--AzureFunctionsVersion>v2</AzureFunctionsVersion-->
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Identity"/>
    <PackageReference Include="Azure.Security.KeyVault.Secrets"/> 
    <PackageReference Include="Microsoft.Azure.Functions.Worker"/>
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk"/> <!--.NETFramework 4.7.2-->
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http"/>
    <PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5"/>
    <PackageReference Include="Microsoft.Azure.Services.AppAuthentication"/>
    <PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.27"/>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/>
    <!--PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http"/-->
    <!--PackageReference Include="Microsoft.NET.Sdk.Functions"/-->
    <PackageReference Include="npgsql"/>
    <PackageReference Include="SendGrid" Version="9.12.0" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" />
    <PackageReference Include="Microsoft.Azure.Cosmos" />
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project> 

And finally my azure-pipelines.yaml file is:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># https://aka.ms/yaml
trigger:
- master
- update_5_x_x
pool:
vmImage: windows-2019
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.0.x'
displayName: 'Install .Net SDK 5.0.x'
- script: |
dotnet --info
dotnet --list-sdks
displayName: 'Display .NET Info'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
verbosityRestore: Detailed
verbosityPack: Detailed
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
projects: '**/*.csproj'
verbosityRestore: Detailed
verbosityPack: Detailed
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
projects: '**/*.csproj'
arguments: '--no-restore --configuration Release --output $(Build.ArtifactStagingDirectory)'
verbosityRestore: Detailed
verbosityPack: Detailed
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
</code>
<code># https://aka.ms/yaml trigger: - master - update_5_x_x pool: vmImage: windows-2019 steps: - task: UseDotNet@2 inputs: packageType: 'sdk' version: '5.0.x' displayName: 'Install .Net SDK 5.0.x' - script: | dotnet --info dotnet --list-sdks displayName: 'Display .NET Info' - task: DotNetCoreCLI@2 displayName: 'dotnet restore' inputs: command: restore projects: '**/*.csproj' verbosityRestore: Detailed verbosityPack: Detailed - task: DotNetCoreCLI@2 displayName: 'dotnet build' inputs: projects: '**/*.csproj' verbosityRestore: Detailed verbosityPack: Detailed - task: DotNetCoreCLI@2 displayName: 'dotnet publish' inputs: command: publish publishWebProjects: false projects: '**/*.csproj' arguments: '--no-restore --configuration Release --output $(Build.ArtifactStagingDirectory)' verbosityRestore: Detailed verbosityPack: Detailed - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: drop' </code>
# https://aka.ms/yaml

trigger:
- master
- update_5_x_x

pool:
  vmImage: windows-2019

steps:
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '5.0.x'
  displayName: 'Install .Net SDK 5.0.x'

- script: |
    dotnet --info
    dotnet --list-sdks
  displayName: 'Display .NET Info'

  
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'
    verbosityRestore: Detailed
    verbosityPack: Detailed


- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: '**/*.csproj'
    verbosityRestore: Detailed
    verbosityPack: Detailed


- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: '--no-restore --configuration Release --output $(Build.ArtifactStagingDirectory)'
    verbosityRestore: Detailed
    verbosityPack: Detailed


- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

I can restore the project successfully, but when building I get the following error requiring me to use framework Microsoft.NETCore.App even though I specify framework to be net5.0. This prompted me to think one of my packages required that framework so I went through my package list on the .nuget website, but everything looks to be compatible with net5.0.

I have tried different combinations of versions of packages to no avail.

Again: I am very likely overlooking something basic here – any input will be much appreciated!

New contributor

Joakim Sandroos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật