链接: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 .csproj
format. 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.
$ 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
执行命令出现错误
$ 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 migrate
command 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: