MSBuild - 从命令行调用目标

发布于 2024-07-06 22:03:01 字数 459 浏览 8 评论 0原文

有谁知道如何获取从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱格式化 2024-07-13 22:03:01

我不确定如何完全按照您的要求进行操作,但是您可以使用 /p 选项传递该字符串吗?

msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV;MyValue=ApplicationDeployment

我能看到的唯一其他方法是在每个目标中使用条件属性,从而建立要调用的第一个目标。

<Target Name="ApplicationDeployment">
<PropertyGroup>
  <InvokedTarget Condition="'${InvokedTarget}'==''">ApplicationDeployment</InvokedTarget>
</PropertyGroup>

...
</Target>

I'm not sure how to do exactly what you ask, but could you pass that string using the /p option?

msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV;MyValue=ApplicationDeployment

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.

<Target Name="ApplicationDeployment">
<PropertyGroup>
  <InvokedTarget Condition="'${InvokedTarget}'==''">ApplicationDeployment</InvokedTarget>
</PropertyGroup>

...
</Target>
丢了幸福的猪 2024-07-13 22:03:01

我找到了答案!

<Target Name="ApplicationDeployment" >
    <CreateProperty Value="$(MSBuildProjectName) - $(Environment) - Application Deployment Complete">
      <Output TaskParameter="Value" PropertyName="DeploymentCompleteNotifySubject" />
    </CreateProperty>

我想部分归功于冷漠。 不知道该怎么做。

I found the answer!

<Target Name="ApplicationDeployment" >
    <CreateProperty Value="$(MSBuildProjectName) - $(Environment) - Application Deployment Complete">
      <Output TaskParameter="Value" PropertyName="DeploymentCompleteNotifySubject" />
    </CreateProperty>

I would like to give partial credit to apathetic. Not sure how to do that.

一刻暧昧 2024-07-13 22:03:01

没有办法做到这一点(据我所知)。 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.

烈酒灼喉 2024-07-13 22:03:01

我建议使用像 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文