This project is read-only.

Read in a list of services to start / stop

May 5, 2010 at 3:36 AM

I am currently trying to read in a list of services from a text file using the ReadLinesFromFile command and have the extension pack read in the services returned and stop all the services in the file, deploy their code, and then start the services again. All the services are on remote servers (although in the same domain). I am unable to get the MSBuild.ExtensionPack.Computer.WindowsService Stop / Start command to recognize the list of services to start and stop. I always get the error "Service does not exist: ". Does anyone know a way to do this?

The text file that we are using to read in the services looks like:


The MSBuild project to do so currently looks like:

    <ReadLinesFromFile File="$(ConfigDir)\Services.txt">
      <Output TaskParameter="Lines" PropertyName="Services"/>

    <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Stop" ServiceName="@(Services->'%(Identity)')" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="ServerName" />
    <Exec Command="xcopy &quot;$(StagingDir)\services\*&quot; &quot;\\ServerName\ProgramFiles&quot; /s /r /y" WorkingDirectory="$(StagingDir)" />
    <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Start" ServiceName="@(Services->'%(Identity)')" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="ServerName" />
May 5, 2010 at 8:40 AM


ReadLinesFromFile outputs an Item, not property, so you need


 <ReadLinesFromFile File="$(ConfigDir)\Services.txt">
      <Output TaskParameter="Lines" ItemName="Services"/>


then in your call to the task just use 


May 5, 2010 at 7:07 PM

Thanks for the help. That worked like a charm.