D.Chan
D.Chan

Reputation: 51

.netcore-mvc app will not target 2.1.3 after VS forced update to 2.1.4

I started developing a new website prior to .net core framework 2.1.4 was released, we got our production environment all set up with "Coming Soon" pages, etc.

As this server hosts other sites, we do not want to restart for an upgrade to 2.1.4, so I updated the csproj file with

    <RuntimeFrameworkVersion>2.1.3</RuntimeFrameworkVersion>

I also checked the NuGet packages for Microsoft.NETCore.App and it is set to 2.1.3

Yet, when I publish the site and copy it to the folder on the host, it still logs

It was not possible to find any compatible framework version The specified framework 'Microsoft.NETCore.App', version '2.1.4' was not found. - Check application dependencies and target a framework version installed at: "PATH" - Installing .NET Core prerequisites might help resolve this problem: http://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] 2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

I am at a loss as to what to do, how do I change this project to target 2.1.3 instead of 2.1.4??

CSProj:

    <Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkVersion>2.1.3</RuntimeFrameworkVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.3" />
    <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.18" />
  </ItemGroup>

</Project>

Screenshot of Nuget dependencies in VS: Screenshot of Dependencies in VS

Upvotes: 4

Views: 196

Answers (2)

D.Chan
D.Chan

Reputation: 51

After trying to downgrade for 2 days, I decided to stay up and deploy 2.1.4 to the production server during customer off hours, I know this isn't technically the "answer" but it was the only way I could solve the issue within the 4 day time window that it needed to be deployed.

Upvotes: 1

rekiem87
rekiem87

Reputation: 1573

It seems weird to me, the only thing that we need to change the NetCore version in our proiject, is to change the csproj between versions, for example, this is a csproj of one of out projects running in 2.1.4:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
    <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="wwwroot\**" />
    <Content Remove="wwwroot\**" />
    <EmbeddedResource Remove="wwwroot\**" />
    <None Remove="wwwroot\**" />
  </ItemGroup>

  <ItemGroup>
    ...
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.4" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.4" />
    ...
  </ItemGroup>

  ...

</Project>

And we can downgrade it to 2.1.3 by simply changing that two dependencies

    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.3" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.3" />

I can see that we are not using your directive <RuntimeFrameworkVersion>2.1.3</RuntimeFrameworkVersion>

I do not know if that could make any difference.

On the other hand, it would be interesting to know what made you want to go back, since there are no significant changes in the last update, and it is a very necessary one, since it is to fix a vulnerability that could cause you a DOS.

Since the update cycle of dot net core is going to be in very short periods of time and the downtime is a really concern, i also would strongly recommend that you start to use Docker, that could allow you to run several environmnents (2.1, 2.1.2...) in the same docker.

We even hit a bug with core 2.1, so we are runnning a separate container with only one feature in net core 2.0, while our app is happy running in the same server our app in 2.1.4

Also, be sure to make a clean & build, you could try even delete the obj and bin folders manually, just to be sure there is nothing causing you that error

Upvotes: 0

Related Questions