Hi i am using MSBuild Extension Pack to install windows service to the remote machine. I was testing this through command prompt and it successfully installed the service. I now want to call this extension pack using MSBuild arguments.
My code looks like this:
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RemoteMachine>DevRemote</RemoteMachine>
<RemoteUser>RemoteDomain\RemoteUser</RemoteUser>
<RemoteUserPassword>RemotePassword</RemoteUserPassword>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Target Name="Default">
<MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="Backup Management" ServicePath="c:\WINDOWS\system32\taskmgr.exe" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" />
</Target>
How am i able to achieve this? From my guess the build arguments looks something like this:
/p:DeployOnBuild=True /p:DeployWinService=true;TargetWinServiceHost=DevRemote
But i am not sure about the arguments. Any help really appreciated.
I usually have two files, one with properties, another with targets. I also try to store all the needed properties in a file, so there is no need to pass anything from command line.
If you call the file with targets main.msbuild
you can call it like that
msbuild main.msbuild /t:Default
where /t
switch corresponds to the target name, and this is how you can specify which target to execute, so no parameters with /p
needed.
From examples, this is how the default target may look like
<Target Name="Default">
<!-- Install a service on a Remote Machine -->
<MSBuild.ExtensionPack.Computer.WindowsService
TaskAction="Install"
ServiceName="__TestService1"
User="$(User)"
Password="$(password)"
ServicePath="c:\WINDOWS\system32\taskmgr.exe"
RemoteUser="$(RemoteUser)"
RemoteUserPassword="$(RemoteUserPassword)"
MachineName="$(RemoteMachine)" />
</Target>