0
votes

I am upgrading our existing platform from .Net Core 1.1 to .Net Core 2.0. I upgraded the framework and Nuget packages associated with it.

My controllers no longer inherit from the Controller class.

However, my project is no longer building and throws cs0012 with message: You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture= neutral, publicKeyToken = cc7b13ffcd2ddd51".

This is my cs.project

<PropertyGroup>   
<AssemblyTitle>Demand1</AssemblyTitle>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>OnDemand</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>OnDemand</PackageId>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>

  <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.7.10" />
<PackageReference Include="OctoPack" Version="3.6.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
<PackageReference Include="StackifyMiddleware" Version="2.0.3" />

I followed suggestions found here: Solution 1 and Another One

  • Reference Include="netstandard" as a ItemGroup
  • PackageReference Update="Microsoft.NETCore.App" Version="2.0.0"
  • Removed the RuntimeFrameworkVersion
  • Updated my vs community to 15.5.7

Could anyone point me to a correct direction please after spending a whole day to try resolving it. Also I thought .net core 2 implements .net standard 2.0.0. Please do correct me if I am completely wrong here.

1
Serilog.Extensions.Logging.File 1.0.0 .. Targerts .NET Standard 1.3, try targetting 2.0.0-dev-00023DOMZE
Microsoft has an official guide, docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x which you do not seem to read yet.Lex Li
@LexLi I forgot to mention that I have read the official documentation of migrating to .net core 2. I even tried using the Microsoft.AspNetCore.All package instead of all the other packages.Yuvi
@DOMZE that was the only I did not update. Will try targeting it as you suggested and seeYuvi
did you upgrade Visual Studio? When you update VS, .Net Core SDK will be updated accordingly (.Net Core 2.0 will be installed)Derviş Kayımbaşıoğlu

1 Answers

0
votes

You need to remove the

<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>

from your .csproj file. This sets the target version in your runtimeconfig.json file to use .NET Core 1.1.1 instead of .NET Core 2.0.

Reference: https://stackoverflow.com/a/46778275

Other Things to Check

  1. Make sure you have the .NET Core 2.0 SDK installed.
  2. Make sure you don't have any global.json files in your solution that are overriding the SDK version.