<p>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.</p>

<p>Example:</p>

<pre><code>msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV
</code></pre>

<p>I want access to the target words <code>ApplicationDeployment</code> in my .Proj file. </p>

<p>Is there a property I can access? Any clue how to do this?</p>

<p><strong>EDIT:</strong> I do not want to have to also pass in a property to get this.</p>

<p><strong>UPDATE:</strong> This is based on <strong>deployment scripts</strong> 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.</p>

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>
```
```