1. 程式人生 > >[.NET Core 24]把project.json遷移到.csproj

[.NET Core 24]把project.json遷移到.csproj

window sed nload glob support base ota cspro bsp

鏈接:https://blog.jetbrains.com/dotnet/2017/04/04/rider-eap-update-csproj-based-net-core-support-migrate/

how to migrate from the (deprecated) project.json format to the new .csproj format.

First, Microsoft greatly simplified the .csprojformat. In minimal format, this is what it looks like:

首先,微軟大大簡化.csproj格式。最小的格式,如下:

<Project Sdk="Microsoft.NET.Sdk">
 
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup>
 
</Project>

Second, the good things of project.json were ported over to the new .csproj format:

其次,project.json 的優點都移植到了新的csproj格式:

支持通配符(如果一個文件被添加到項目文件,沒有更多的合並沖突)。
命令行工具如dotnet.exe可以跟他們一起工作。
Multi-targeting很簡單:只需指定目標框架(target frameworks),就可以了。
包引用和項目引用很容易添加。
從項目中構建包也更容易(see full reference)。

遷移:

Let’s look at how we can move from project.json (and the old .xproj) to the new and shiny. Before starting, make sure that the required toolsets are installed. On Windows, you currently need a Visual Studio 2017 install (we’re working on that). On Mac OS / Linux, the Mono tooling is required.

qiongyanzhudeMacBook-Pro:BeibeiCore.Services qiongyanzhu$ dotnet --info
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.10
 OS Platform: Darwin
 RID:         osx.10.10-x64

執行命令出現錯誤

iongyanzhudeMacBook-Pro:BeibeiBasic qiongyanzhu$ dotnet migrate
No executable found matching command "dotnet-migrate"

Note: If you get an error “No executable found matching command dotnet-migrate”, edit the solution’s global.json file and change the SDK version to 1.1.0. The dotnet migratecommand requires .NET Core CLI RC3 or higher.

qiongyanzhudeMacBook-Pro:BeibeiBasic qiongyanzhu$ dotnet migrate

Project BeibeiWeb.FlowUITest migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiWeb.FlowUITest).

Project BeibeiWeb.FlowUI migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiWeb.FlowUI).

Project BeibeiCore.Services migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.Services).

Project BeibeiCore.Utility migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.Utility).

Project BeibeiCore.EF.Test migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.EF.Test).

Project BeibeiCore.EF migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.EF).

Project BeibeiCore.Domain.P2P migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.Domain.P2P).

Project BeibeiCore.Component.IData migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.Component.IData).

Project BeibeiCore.ADO.Flow migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiCore.ADO.Flow).

Project BeibeiBasic.Web migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiBasic.Web).

Project BeibeiBasic.Services migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiBasic.Services).

Project BeibeiBasic.Models migration succeeded (/Users/qiongyanzhu/RiderProjects/BeibeiBasic/BeibeiBasic.Models).
Summary
Total Projects: 12
Succeeded Projects: 12
Failed Projects: 0

The project migration has finished. Please visit https://aka.ms/coremigration to report any issues you‘ve encountered or ask for help.
Files backed up to /Users/qiongyanzhu/RiderProjects/BeibeiBasic/backup/
qiongyanzhudeMacBook-Pro:BeibeiBasic qiongyanzhu$

  Once finished, existing project.json and .xproj will be converted to .csproj. Depending on the project type, Rider will automatically reload the solution after migration completes (worst case, you may have to close and re-open Rider).

Further details on migrating projects from project.json to .csproj can be found on Microsoft’s documentation site:

  • Migrating .NET Core projects to the .csproj format
  • The dotnet migrate command line tool

[.NET Core 24]把project.json遷移到.csproj