Upgrade. NET Core 1.x App and. NET Standard 1.x Library to version 2.0

Source: Internet
Author: User

Record the process of upgrading the. NET Core 1.x App and the. NET Standard 1.x project to version 2.0 and encountering NuGet dependencies

Today I'm going to put a long, motionless app with. NET Core 1.0.4 and the library that he relies on is written in. NET Standard 1.6 and upgraded to version 2.0

The process of upgrading also encountered some problems on the way, recorded here

I have a visual Studio 2017 (15.4) version that opens a long, open solution that appears

The report shows no errors after the upgrade

But it actually compiles, but it looks like the upgrade process, the. NET Standard NuGet package was dropped, causing other nuget suites that were originally dependent on the newer. NET Standard to become unusable

A want to say to NuGet Netstandard.library upgrade to 2.0, but in the discovery version of 2.0, but can not press ... Show blocked by project

It looks like you can only change the version of the project manually.

First, open the library's Csporj file with a text editor

Change TargetFramework to Netstandard2.0,netstandardimplicitpackageversion 2.0.0

Here is the version after the change

<project sdk= "MICROSOFT.NET.SDK" > <PropertyGroup> <TargetFramework> Netstandard2.0</targetframework> <AssemblyName>Lib</AssemblyName> <packageid>lib</ Packageid> <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> < packagetargetfallback>$ (packagetargetfallback);d nxcore50</packagetargetfallback> < Generateassemblyconfigurationattribute>false</generateassemblyconfigurationattribute> < Generateassemblycompanyattribute>false</generateassemblycompanyattribute> < Generateassemblyproductattribute>false</generateassemblyproductattribute> </PropertyGroup> < itemgroup> <packagereference include= "Newtonsoft.json" version= "10.0.2"/> <packagereference "Include=" SQLITE-NET-PCL "version=" 1.3.1/> </ItemGroup> </project> 

Then open the csproj of the. Net Core App

Change TargetFramework to Netcoreapp2.0,runtimeframeworkversion 2.0.0

<project sdk= "MICROSOFT.NET.SDK" >

  <PropertyGroup>
    <targetframework>netcoreapp2.0</ targetframework>
    <AssemblyName>Project</AssemblyName>
    <outputtype>exe</ outputtype>
    <PackageId>Project</PackageId>
    <runtimeframeworkversion>2.0.0</ Runtimeframeworkversion>
    <packagetargetfallback>$ (packagetargetfallback);d nxcore50</ Packagetargetfallback>
    <generateassemblyconfigurationattribute>false</ Generateassemblyconfigurationattribute>
    <generateassemblycompanyattribute>false</ Generateassemblycompanyattribute>
    <generateassemblyproductattribute>false</ generateassemblyproductattribute>
  </PropertyGroup>

  <ItemGroup>
    < Projectreference include= ". \lib\lib.csproj "/>
  </ItemGroup>

</Project>

After rebuilding, it can be compiled successfully pull ~ ~

========== Rebuild: 2 success, 0 failure, 0 skip ==========

If there is still a mistake, you can go to each project to see if the target Framework is 2.0.
From: Technical notes of dotblogs.com.tw mushroom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.