2
votes

I am getting this error when I try to deploy my .netcore 2.2 application:

It was not possible to find any compatible framework version The specified framework 'Microsoft.NETCore.App', version '2.2.4' was not found. - Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\ - Installing .NET Core prerequisites might help resolve this problem: https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 - The .NET Core framework and SDK can be installed from: https://aka.ms/dotnet-download - The following versions are installed: 1.0.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 1.1.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 1.1.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.2.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

In my local machine when I run:


    dotnet --version

I get this response: "2.2.102" and the app runs fine. I have also only installed Microsoft.NET Core Runtime - 2.2.1 and Microsoft .NET Core SDK 2.2.102. So version 2.2.4 is not supported.

This is my web.config:


    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
          </handlers>
          <modules runAllManagedModulesForAllRequests="true">
              <remove name="WebDAVModule"/> 
          </modules>
          <aspNetCore processPath="dotnet" arguments=".\Optics.API.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
        </system.webServer>
      </location>
    </configuration>

This my .csproj:


    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>netcoreapp2.2</TargetFramework>
        <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
        <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" PrivateAssets="All"/>
        <PackageReference Include="Hangfire.Core" Version="1.7.0"/>
        <PackageReference Include="Hangfire.SqlServer" Version="1.7.0"/>
        <PackageReference Include="Hangfire.AspNetCore" Version="1.7.0"/>
        <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.1"/>
        <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="4.0.1"/>
        <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0"/>
      </ItemGroup>
    </Project>

I have also tested by removing the version of Microsoft.AspNetCore.App


    <PackageReference Include="Microsoft.AspNetCore.App"/>

But even with that change I get the same error. Furthermore the app is deployed in a shared hosting server and I have no authority to install any sdk or runtime, so I should work with the existing. Any clues?

1
What is the output of dotnet --info command on your local machine? Dependency graph can also be helpful. You can generate it by navigating to your project and then run dotnet msbuild /t:GenerateRestoreGraphFile /p:RestoreGraphOutputPath=graph.dg command which will generate graph.dg file which is json file.Mohsin Mehmood
I run dotnet msbuild /t:GenerateRestoreGraphFile /p:RestoreGraphOutputPath=graph.dg but there was no reference for version 2.2.4tenten

1 Answers

0
votes

I fixed the problem.

So when I was publishing the app, I will run this command in vs code:

dotnet publish -c release

** This command still work in my gcp cloud vm, but not in shared hosting.

To fix it, I followed these steps:

  1. Opened visual studio this time, not vs code.
  2. Right click project's name and click publish.
  3. In pick a publish target, I selected IIS,FTP,etc.
  4. For connection, I selected File System and selected a target location.
  5. In settings tab, I selected Configuration: Release, Target Framework: netcoreapp2.2, Deployment Mode: Self-Contained and Target Runtime: win-x64

I can't understand why my app was previously working for 2 months until now, with that code. I don't have a lot of experience, but my guess is that they uninstalled something from the server and in order to run the app needed to upload more files.