.net – Example of using Service Exists MSBuild task in Microsoft.Sdc.Tasks

.netmsbuild

I'm trying to use the Microsoft.Sdc.Tasks.ServiceProcess.Exists to check whether or not a service exists. There is no example of using it in the documentation though. Anyone have one?

Best Solution

I've not actually used this in production myself, and I'm not sure which version you have (I have a copy of Release 2.1.3155.0) and according to the accompanying .chm help file the Task has the following properties:

  • DoesExist Returns TRUE if the service specified exists
  • IsDisabled Returns TRUE if the service is disabled
  • ServiceName The short name that identifies the service to the system.

The ServiceName needs to be set to "The short name that identifies the service to the system, e.g. 'W3SVC'".

You might want to give it a try with a well known service (e.g. mssqlserver) and check the result of the other two properties (DoesExist/IsDisabled).

Update: Here's a sample (works):

Import the tasks, then call (e.g.)

< Microsoft.Sdc.Tasks.ServiceProcess.Exists ServiceName="Server"> < Output TaskParameter="DoesExist" PropertyName="Exists" /> < /Microsoft.Sdc.Tasks.ServiceProcess.Exists >

< Message Text="Service exists? $(Exists)" />