dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

Build/Debug with VS'19 keeps asking for latest release of .net core #17673

Open JGCreator opened 3 years ago

JGCreator commented 3 years ago

I have a .net core 3.1 project netcoreapp3.1 that continues to fail to buld/run from visual studio whenever there is a new release of .net core.

Error:

It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '3.1.15' was not found. The following frameworks were found:

  • 2.1.27 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  • 3.1.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  • 3.1.14 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  • 5.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  • 5.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

dotnet --info

.NET Core SDK (reflecting any global.json): Version: 3.1.407 Commit: d3244d0e44

Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.407\

Host (useful for support): Version: 5.0.6 Commit: 478b2f8c0e

.NET SDKs installed: 3.1.407 [C:\Program Files\dotnet\sdk] 5.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

global.json at .sln root

{"sdk": {"version": "3.1.407",}}

What is causing this project to require the latest release of .net core and is preventing it from resprecting my global.json preference?

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

wli3 commented 3 years ago

"Microsoft.NETCore.App', version '3.1.15" is the runtime version, {"sdk": {"version": "3.1.407",}} is the SDK version https://docs.microsoft.com/en-us/dotnet/core/introduction#sdk-and-runtimes

version '3.1.15" is set in the application (in runtimeconfig.json) you plan to run. In this case, you should download and install the runtime 3.1.15.

JGCreator commented 3 years ago

"Microsoft.NETCore.App', version '3.1.15" is the runtime version, {"sdk": {"version": "3.1.407",}} is the SDK version https://docs.microsoft.com/en-us/dotnet/core/introduction#sdk-and-runtimes

version '3.1.15" is set in the application (in runtimeconfig.json) you plan to run. In this case, you should download and install the runtime 3.1.15.

@wli3 This has been closed without answering the question.

Obviously I can read that the error message is telling me to install the 3.1.15 runtime as I quoted said message

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

The question is: why does my app continue to require me to install the latest runtime whenever there is a new patch release and documentation indicates that it should select the latest installed? None of the config of my my app indicates that this should be my desired functionality (I have no runtimeconfig.json specifying anything about runtime configurations so I would expect it to follow documentation).

wli3 commented 3 years ago

could you show me the content of your csproj or a sample repro?

JGCreator commented 3 years ago
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <Nullable>enable</Nullable>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="AutoMapper" Version="9.0.0" />
    <PackageReference Include="Azure.Identity" Version="1.2.0" />
    <PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.0.3" />
    <PackageReference Include="CsvHelper" Version="26.0.1" />
    <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
    <PackageReference Include="LazyCache" Version="2.0.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
    <PackageReference Include="Microsoft.Graph" Version="3.8.0" />
    <PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.5" />
    <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.5.0" />
    <PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
    <PackageReference Include="SonarAnalyzer.CSharp" Version="8.13.1.21947">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
    <PackageReference Include="X.PagedList" Version="8.0.7" />
  </ItemGroup>

</Project>