MSBuild - 从命令行调用目标
有谁知道如何获取从 MSBuild 命令行调用的 TARGET (/t) 的名称? 有几种类型的目标可以调用,我想在向用户发出的通知中使用该属性。
示例:
msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV
我想要访问 .Proj 文件中的目标词 ApplicationDeployment
。
有我可以访问的房产吗? 有任何线索如何做到这一点吗?
编辑:我不想还必须传递一个属性才能得到这个。
更新:这是基于使用 MSBuild 脚本的部署脚本。 我的构建服务器不用于部署代码,仅用于构建。 构建服务器本身具有可以选择加入的构建通知。
Does anyone know how to get the name of the TARGET (/t) called from the MSBuild command line? There are a few types of targets that can be called and I want to use that property in a notification to users.
Example:
msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV
I want access to the target words ApplicationDeployment
in my .Proj file.
Is there a property I can access? Any clue how to do this?
EDIT: I do not want to have to also pass in a property to get this.
UPDATE: This is based on deployment scripts using MSBuild scripts. My build server is not used for deploying code, only for building. The build server itself has build notifications that can be opted into.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不确定如何完全按照您的要求进行操作,但是您可以使用 /p 选项传递该字符串吗?
我能看到的唯一其他方法是在每个目标中使用条件属性,从而建立要调用的第一个目标。
I'm not sure how to do exactly what you ask, but could you pass that string using the /p option?
The only other way I can see to do it is to use a conditional property in each target, and thus establish the first target to be invoked.
我找到了答案!
我想部分归功于冷漠。 不知道该怎么做。
I found the answer!
I would like to give partial credit to apathetic. Not sure how to do that.
没有办法做到这一点(据我所知)。 MSBuild 没有请求构建的目标列表的属性。
但是,如果您找到一种方法,请记住它可能不是单个目标,而是要构建的目标列表。
There's no way to do this (that I am aware of). MSBuild doesn't have a property for the list of targets requested to build.
However, if you find a way, keep in mind that it might not be a single target, but instead a list of targets to build.
我建议使用像 CCNET 这样的服务器来处理构建执行和通知。 当然,您可以对 MSBuild 脚本执行一些操作来发送通知,但该域属于构建服务器。
I'd recommend using a server like CCNET to handle build executions and notification. Sure, you can do things to your MSBuild script to send out notificatioms, but that domain belongs to the build server.