Valid TaskActions are:

Get (Required: Variable Optional: Target Output: Value)

Set (Required: Variable, Value Optional: Target)

Remote Execution Support: For Get TaskAction only

Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 3.5.0.0

Examples

Xml Copy imageCopy
<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <!-- Set an environment variable. Note how special characters need to be escaped (http://msdn.microsoft.com/en-us/library/ms228186(VS.80).aspx) -->
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Set" Variable="PATH" Value="$(VCInstallDir)Common7\IDE%3B$(VCInstallDir)VC\BIN%3B$(VCInstallDir)Common7\Tools%3B$(VCInstallDir)Common7\Tools\bin%3B$(VCInstallDir)VC\PlatformSDK\bin%3B$(SDKInstallDir)bin%3B$(PATH)"/>
        <!-- Set a new Environment Variable. The default target is Process -->
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Set" Variable="ANewEnvSample" Value="bddd"/>
        <!-- Get the Environment Variable -->
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Get" Variable="ANewEnvSample">
            <Output PropertyName="EnvValue" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Computer.EnvironmentVariable>
        <Message Text="Get: $(EnvValue)"/>
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Set" Variable="ANewEnvSample" Value="newddd"/>
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Get" Variable="ANewEnvSample">
            <Output PropertyName="EnvValue" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Computer.EnvironmentVariable>
        <Message Text="Get: $(EnvValue)"/>
        <!-- Set a new Environment Variable on a remote machine -->
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Set" Variable="ANewEnvSample" Value="bddd" MachineName="MediaHub"/>
        <!-- Get an Environment Variable from a remote machine -->
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Get" Variable="INOCULAN" Target="Machine" MachineName="machinename" UserName="Administrator" UserPassword="passw">
            <Output PropertyName="EnvValue" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Computer.EnvironmentVariable>
        <Message Text="INOCULAN Get: $(EnvValue)"/>
        <MSBuild.ExtensionPack.Computer.EnvironmentVariable TaskAction="Get" Variable="FT" Target="User" MachineName="machinename" UserName="Administrator" UserPassword="passw">
            <Output PropertyName="EnvValue" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Computer.EnvironmentVariable>
        <Message Text="FT Get: $(EnvValue)"/>
    </Target>
</Project>

Inheritance Hierarchy

System..::..Object
  Microsoft.Build.Utilities..::..Task
    MSBuild.ExtensionPack..::..BaseTask
      MSBuild.ExtensionPack.Computer..::..EnvironmentVariable

See Also