msbuild.exe_使用多个.NET Core SDK-project.json和msbuild / csproj

msbuild.exe

msbuild.exe

As .NET Core and ASP.NET Core make the transition from project.json style project files to MSBuild (csproj) style files, I'm starting to get myself up to speed on what's needed, what's changing, and why/if it's a good thing. Documentation is still getting updated but there's a great blog post from Nate McMaster who works on the team.

当.NET Core和ASP.NET Core从project.json样式的项目文件过渡到MSBuild(csproj)样式的文件时,我开始着手了解所需的内容,正在发生的变化以及原因/如果需要的话。好东西文档仍在更新,但是Nate McMaster在团队中撰写了一篇很棒的博客文章

As I touched on in a previous post, you can continue working on project.json based projects while experimenting with the newer stuff. Here I have a global.json with the version pinned to an earlier SDK. Then I move to another folder and the .NET CLI gives me another version. Projects can remember and pin their SDK versions.

正如我在上一篇文章中提到的那样,您可以在尝试使用更新的东西的同时继续基于project.json的项目。 在这里,我有一个global.json,其版本固定到了较早的SDK。 然后,我移到另一个文件夹,.NET CLI给了我另一个版本。 项目可以记住并固定其SDK版本。

Global.json is useful

This is assuming that you do have multiple versions (and the ones you want) installed:

这是假设您确实安装了多个版本(以及您想要的版本):

Here I have 4 SDKs installed and I can see them in my installation folder

To be clearer, I'll run "dotnet new" in one folder and again run "dotnet new" in another. Note that one has global.json pinned older "LTS" (Long Term Support) SDK with project.json and one will use the later "Current" (bleeding-edge) stuff.

更清楚地说,我将在一个文件夹中运行“ dotnet new”,然后在另一个文件夹中再次运行“ dotnet new”。 请注意,其中一个将global.json固定为带有project.json的较旧“ LTS”(长期支持)SDK,而另一个将使用较晚的“ Current”(出血边缘)东西。

See how that works?

看看如何运作?

C:\Users\scott\Desktop\csprojstuff> dotnet new
Created new C# project in C:\Users\scott\Desktop\csprojstuff.

C:\Users\scott\Desktop\csprojstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\csprojstuff

01/23/2017 01:09 PM <DIR> .
01/23/2017 01:09 PM <DIR> ..
12/07/2016 09:49 PM 422 csprojstuff.csproj
12/07/2016 09:49 PM 133 Program.cs
2 File(s) 555 bytes
2 Dir(s) 149,845,356,544 bytes free

C:\Users\scott\Desktop\csprojstuff> cd ..\projjsonstuff

C:\Users\scott\Desktop\projjsonstuff> dotnet new
Created new C# project in C:\Users\scott\Desktop\projjsonstuff.

C:\Users\scott\Desktop\projjsonstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\projjsonstuff

01/23/2017 01:10 PM <DIR> .
01/23/2017 01:10 PM <DIR> ..
01/23/2017 01:05 PM 95 global.json
06/21/2016 07:10 PM 214 Program.cs
06/21/2016 07:10 PM 367 project.json
3 File(s) 676 bytes
2 Dir(s) 149,844,484,096 bytes free

Now I can also "migrate" that project.json forward with "dotnet migrate." That's a NEW command so look what happens if I just run it locally there without changing the global.json pinned SDK version? Doesn't work. For this example I'll delete global.json and run it again.

现在,我还可以使用“ dotnet migration”将“ project.json”向前“迁移”。 这是一个新命令,所以,如果我不更改global.json固定SDK版本而直接在本地运行,会发生什么情况? 不起作用对于此示例,我将删除global.json并再次运行它。

C:\Users\scott\Desktop\projjsonstuff> dotnet migrate
No executable found matching command "dotnet-migrate"

C:\Users\scott\Desktop\projjsonstuff> del global.json

C:\Users\scott\Desktop\projjsonstuff> dotnet migrate
Project projjsonstuff migration succeeded (C:\Users\scott\Desktop\projjsonstuff)
Summary
Total Projects: 1
Succeeded Projects: 1
Failed Projects: 0


C:\Users\scott\Desktop\projjsonstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\projjsonstuff

01/23/2017 01:11 PM <DIR> .
01/23/2017 01:11 PM <DIR> ..
01/23/2017 01:11 PM <DIR> backup
06/21/2016 07:10 PM 214 Program.cs
01/23/2017 01:11 PM 944 projjsonstuff.csproj
2 File(s) 1,158 bytes
3 Dir(s) 149,843,054,592 bytes free

Again, go check out Nate's excellent blog on the topic. He also covers briefly how you can publish "Standalone" or "Self-Contained" Deployments, and points out that in MSBuild world, all projects are portable until you decide to target a runtime:

同样,请访问Nate关于该主题的出色博客。 他还简要介绍了如何发布“独立”或“自包含”部署,并指出在MSBuild世界中,所有项目都是可移植的,直到您决定以运行时为目标:

dotnet publish --framework netcoreapp1.0 /p:RuntimeIdentifier=osx.10.11-x64

More on this as it comes!

随之而来的更多信息!

翻译自: https://www.hanselman.com/blog/working-with-multiple-net-core-sdks-both-projectjson-and-msbuildcsproj

msbuild.exe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值