在MsBuild命令行参数中使用$(SolutionName) [英] Use $(SolutionName) in the MsBuild commandline parameters

查看:184
本文介绍了在MsBuild命令行参数中使用$(SolutionName)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在新的基于Build 2015任务的版本中模拟TFS 2013的XAML版本中的"PerProject"选项,我希望能够将SolutionName传递给msbuild命令行参数,而不必每次都手动进行设置

In order to emulate the "PerProject" option in TFS 2013's XAML build in the new Build 2015 task based builds, I'd like to be able to pass the SolutionName to the msbuild commandline arguments without having to manually set it every time.

我想做类似的事情:

/p:OutputPath=$(Build.BinariesDirectory)\$(SolutionName)\

我希望MsBuild推断$(SolutionName)参数.但是,当在命令行上传递此命令时,新任务运行程序将用正确的目标路径替换$(Build.BinariesDirectory),而单独留下$(SolutionName).不幸的是,MsBuild随后也将其保留为空:

Where I'd like MsBuild to infer the $(SolutionName) parameter. But when passing this on the commandline, the new task runner will substitute the $(Build.BinariesDirectory) with the correct target path and leaves $(SolutionName) alone. Unfortunately MsBuild subsequently also leaves the property alone:

Copying file from "obj\Debug\TFSBuild.exe" to "bin\debug\$(SolutionName)\TFSBuild.exe".
TFSBuild -> b\$(SolutionName)\TFSBuild.exe
Copying file from "obj\Debug\TFSBuild.pdb" to "b\$(SolutionName)\TFSBuild.pdb".

我不记得一种将属性传递给命令行并让它进行后期扩展的方法了...有什么提示吗?

I can't remember a way to pass a property to the commandline and have it do late-expansion... Any tips?

对于那些希望模仿SingleFolderAsConfigured的人,这些很容易:

For those looking to emulate SingleFolder or AsConfigured, those are easy:

SingleFolder -> /p:OutputPath="$(Build.BinariesDirectory)"
Asconfigured -> don't pass OutputPath
PerProject   -> /p:OutputPath="$(Build.BinariesDirectory)\HARDCODESOLUTIONNAME"

推荐答案

正如我所担心的那样,似乎没有一种简单的方法可以从命令行覆盖属性并将另一个"属性的值注入"到命令行中.评估阶段.

As I feared there doesn't seem to be a simple way to override a property from the commandline and "inject" the value of another property into it during the evaluation stage.

有几种解决方法,但是对于MsBuild支持的每种语言,它们都不是理想的,而且也不是通用的.可惜.

There are a few ways to get around it, but they're not ideal and certainly not universal for each language supported by MsBuild. A pity.

我已经调试了MsBuild目标文件,并找到了一种解决方案来重现2005/2008年代的旧行为.并非完全按解决方案,但是它确实将项目重定向到子文件夹中.

I've debugged the MsBuild targets files and found a solution to reproduce the old behaviour from the 2005/2008 era. Not entirely per solution, but it does redirect projects into a subfolder.

 /p:GenerateProjectSpecificOutputFolder=true /p:OutDirWasSpecified=true
 /p:OutputPath=$(Build.BinariesDirectory)

这篇关于在MsBuild命令行参数中使用$(SolutionName)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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