MSBuild - Getting the target called from command line

蹲街弑〆低调 提交于 2019-12-03 23:43:04

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>

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!