I am using MSBuild task to start a windows service. I am using following code:
MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Start" ServiceName="AppServices" ContinueOnError='false'/>
If I start the service I am getting following error:
Start Service failed with return code '[7] ServiceRequestTimeout'
Is there any setting or option to tell MSBuild to start service after waiting for a minute or two. Or Is there any way to introduce delay before calling this task within MSBuild?
Thanks
I do not think there is a way to tell the actually WindowsService task to delay the command. You can try putting this before your call though though:
<MSBuild.ExtensionPack.Framework.Thread TaskAction="Sleep" Timeout="1000"/>
This will put the executing thread to sleep for the timeout specified (in milliseconds).
Related
I'm setting up an Azure-DevOps pipeline in which I want to include automated tests via the Newman CLI.
Imagine a pipeline like this.
Build Project
Copy build to test folder
Run the application => (API-Server)
Run Newman
Kill API Server Process
On Success Copy Build to another folder.
My Problem is that my server application is in a waiting state after it's initialization.
The next Task in my build pipeline won't start.
Is there a way to run multiple command lines asynchronously in Azure-DevOps?
Starting the process in via "start" won't work since it throws me an
ERROR: Input redirection is not supported, exiting the process immediately.
start "%TESTDIR%\foo\bar.exe"
timeout 10
I need some help with this.
I've scheduled a task on Windows Task Scheduler, that calls the command SQLCMD using the parameter: -i "path\script.sql"
My problem is this:
My script starts with: USE [DatabaseX]
DatabaseX does not exist on the server, so the script fails.
But the Scheduled Task ends with a Successful result, even if the script fails.
I need to see that the last run failed in the scheduled task. Or other place, but somewhere...
Is this possible?
Thanks,
One of my msbuild targets works as following:
get configuration files
start window service with those configuration files
exec service specific task
stop window service
repeat
The issue is that sometimes service stop executable task (Exec Command="sc stop myservice") takes longer time and when "sc start myservice" is called it says that service is already running. So my question is: how can I wait for "exec" command ot finish? I tried to put each executable in target and call with "CallTarget" and putting appropriate "DependsOnTargets" or "AfterTargets" and it didn't work. Can you help me? Thanks in advance.
The problem was that Exec actually did finished command execution (he simply thrown "sc stop myservice") and after that another exec started to work. I added timeout for the "sc start myservice" for a minute and it solved. The result looked like:
<Exec Command="sc stop myservice" ContinueOnError="true" />
<Exec Command="sc start myservice" ContinueOnError="true" Timeout="60000" />
I'd like to remotely start or stop a windows service on another machine using MSBuild. To accomplish this, I wrote this script:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="MyTarget">
<ServiceController MachineName="Box2" ServiceName="MyService" Action="Stop" />
</Target>
</Project>
When I run that on a machine that can see Box2, I get this:
Project
"C:\Scripts\Test.xml" on node 1 (default
targets).
C:\Scripts\Test.xml(4,5): error : Couldn't
find the 'MyService'
service on 'Box2' Done Building
Project
"C:\Scripts\Test.xml" (default targets) --
FAILED.
I know that I have the service name correct (I copied and pasted it from the actual service list), and I'm pretty sure that it can see Box2 because if I change it to a machine name that doesn't exist (e.g. Box2asdf), it takes about 10 seconds to come back (with the exact same error, mind you), as opposed to the nearly immediate response that I get when I provide the correct machine name.
How might I debug this issue?
You might try this instead...
You can use the command line program sc and execute that...
ie
SC \ServerName stop ServiceName
http://support.microsoft.com/kb/166819
For more information on how to execute a command from msbuild check this out..
execute a command with parameters using msbuild
The community tasks should work. Just use Sc query to check that the service does work. as for using msbuild its still using msbuild if you wrap sc in an exec?
At least you dont have a dependency on a third party dll in your build process.
ServiceController Target internally uses ServiceController Class. But it doesn't return the reason why it couldn't find the service. If you are shure that both computer and service names are correct, the next thing I can suggest to analyze is access violation problems.
And #jsobo's answer can be very useful to diagnose the actual reason because it can show native errors without .Net exception wrappers around them:
sc.exe \Box2 stop MyService
I am attempting to run the following Powershell command to remove a service application. The command never returns and just hangs and hangs. Anyone now why?
Remove-SPServiceApplication -Identity -RemoveData
SharePoint timer service was stopped causing the script to hang.