Network Class

MSBuild Extension Pack

Network Class MSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

GetDnsHostName (Required: HostNameOutput: DnsHostName)

GetFreePort (Output: Port)

GetInternalIP (Output: Ip)

GetRemoteIP (Required: HostName Output: Ip)

Ping (Required: HostName Optional: Timeout, PingCount Output: Exists)

Remote Execution Support: NA

Inheritance Hierarchy

SystemObject  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.ComputerNetwork

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

The Network type exposes the following members.

Constructors

  NameDescription
Public methodNetwork
Top
Properties

  NameDescription
Public propertyDnsHostName
Gets the DnsHostName
Public propertyExists
Gets whether the Host Exists
Public propertyHostName
Sets the HostName / IP address
Public propertyIP
Gets the IP's
Public propertyPingCount
Sets the number of pings to attempt. Default is 5.
Public propertyPort
Gets the free port. ItemSpec is Port. Metadata includes Address, AddressFamily, Port and ToString
Public propertyTimeout
Sets the timeout in ms for a Ping. Default is 3000
Top
Examples

<Project ToolsVersion="4.0" 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">
        <!-- Get the Machine IP Addresses -->
        <MSBuild.ExtensionPack.Computer.Network TaskAction="GetInternalIP">
            <Output TaskParameter="IP" ItemName="TheIP"/>
        </MSBuild.ExtensionPack.Computer.Network>
        <Message Text="The IP: %(TheIP.Identity)"/>
        <!-- Get Remote IP Addresses -->
        <MSBuild.ExtensionPack.Computer.Network TaskAction="GetRemoteIP" HostName="www.freetodev.com">
            <Output TaskParameter="IP" ItemName="TheRemoteIP"/>
        </MSBuild.ExtensionPack.Computer.Network>
        <Message Text="The Remote IP: %(TheRemoteIP.Identity)"/>
        <!-- Ping a host -->
        <MSBuild.ExtensionPack.Computer.Network TaskAction="Ping" HostName="www.freetodev.com">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.Network>
        <Message Text="Exists: $(DoesExist)"/>
        <!-- Gets the fully-qualified domain name for a hostname. -->
        <MSBuild.ExtensionPack.Computer.Network TaskAction="GetDnsHostName" HostName="192.168.0.15">
            <Output TaskParameter="DnsHostName" PropertyName="HostEntryName" />
        </MSBuild.ExtensionPack.Computer.Network>
        <Message Text="Host Entry name: $(HostEntryName)" />
        <!-- Get free port details -->
        <MSBuild.ExtensionPack.Computer.Network TaskAction="GetFreePort">
            <Output TaskParameter="Port" ItemName="FreePort"/>
        </MSBuild.ExtensionPack.Computer.Network>
        <Message Text="Free Port Address: %(FreePort.Address)"/>
        <Message Text="Free Port AddressFamily: %(FreePort.AddressFamily)"/>
        <Message Text="Free Port Port: %(FreePort.Port)"/>
        <Message Text="Free Port ToString: %(FreePort.ToString)"/>
    </Target>
</Project>
See Also

Reference