使用Cake脚本定位多个框架 [英] Targeting multiple frameworks with Cake script

查看:108
本文介绍了使用Cake脚本定位多个框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一位同事最近使用新的VS2017 .csproj格式向我们的一个项目中添加了.NET Standard支持:

A co-worker recently added .NET Standard support to one of our projects using the new VS2017 .csproj format:

这似乎破坏了我的脚本,因为在使用Cake MSBuild别名时出现以下错误( http://cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildAliases/C240F0FB ):

This seems to have broken my script as I get the following error when using the Cake MSBuild alias (http://cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildAliases/C240F0FB):

错误:项目'C:\ example \ path \ myproj.csproj'目标为'.NETFramework,Version = v4.6.1'.面向".NETStandard,Version = v1.6"的项目无法引用该文件.

error : Project 'C:\example\path\myproj.csproj' targets '.NETFramework,Version=v4.6.1'. It cannot be referenced by a project that targets '.NETStandard,Version=v1.6'.

Cake是否支持使用新的VS2017项目格式针对多个框架进行构建?如果是这样,是否可以通过我可以传递给MSBuild别名的MSBuildSettings参数来实现?非常感谢.

Does Cake support building against multiple frameworks using the new VS2017 project format? If so, is there a way I can do so with the MSBuildSettings argument I can pass to the MSBuild alias? Thanks a lot.

推荐答案

是的Cake完全支持使用最新的.NET SDK 1.0.4和MSBuild 15.x构建VS2017项目.

Yes Cake fully supports building VS2017 projects both using latest .NET SDK 1.0.4 and MSBuild 15.x.

Cake本身是使用Cake,VS2017和.NET Core SDK 1.0.4构建的 https://github.com/cake-build/cake

Cake itself is built using Cake, VS2017 and .NET Core SDK 1.0.4 https://github.com/cake-build/cake

使用MSBuild别名时,请通过设置 MSBuildToolVersion.VS2017 >.

When using MSBuild alias make sure you're using correct version of MSBuild by setting Tool version to MSBuildToolVersion.VS2017.

MSBuild("./src/Cake.sln", 
    new MSBuildSettings { ToolVersion = MSBuildToolVersion.VS2017
});

如果在非标准位置安装了VS2017,则可以使用VSWhere工具和别名找到正确的MSBuild路径

If you've got VS2017 installed in a non standard location, then you can use the VSWhere tool and alias to locate correct MSBuild path

#tool nuget:?package=vswhere 

DirectoryPath vsLatest = VSWhereLatest();

FilePath msBuildPathX64 = (vsLatest==null) ? null : vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/amd64/MSBuild.exe"); 

MSBuild("./src/Example.sln", 
    new MSBuildSettings { ToolPath = msBuildPathX64
}); 

有关更多信息,请访问: http://cakebuild.net/blog/2017/03/vswhere-and-visual-studio-2017-support

Read more about this at: http://cakebuild.net/blog/2017/03/vswhere-and-visual-studio-2017-support

这篇关于使用Cake脚本定位多个框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆