Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1080631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:03:44+00:00 2026-05-16T22:03:44+00:00

I am setting up a project to run under the teamcity integration server on

  • 0

I am setting up a project to run under the teamcity integration server on windows server 2003 (with sp2). The integration tests run using msbuild with the latest version of msbuildtasks v1.2.0.306. All code is build with .net 2.0.

In our build.xml file we remove all the services used by the systems, rebuild them all recreate them and then run a bunch of nunit tests to make sure they play well together.

To remove the services we use the UninstallAssembly task like this:

<UninstallAssembly
   AssemblyFiles='..\src\FolderName\ProjectName\bin\Debug\ProjectName.exe'
   ContinueOnError='true'>
</UninstallAssembly>

When I look at the build output this runs the installUtil command:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /uninstall ..\src\FolderName\ProjectName\bin\Debug\ProjectName.exe

We then re-install the service using the InstallAssembly task:

<InstallAssembly
  AssemblyFiles='..\src\FolderName\ProjectName\bin\Debug\ProjectName.exe'>
</InstallAssembly>

this is often fine but sometimes we get this error:

error MSB6006: “InstallUtil.exe”

exited with code -1.

I have a look and the service is there but it cannot be started/stoped/etc.

If I try to delete with sc delete servicename I get the error

[SC] DeleteService FAILED 1072:

The specified service has been marked
for deletion.

When a service is in this “marked for deletion” state is there any way to get rid of it?

I found this note from microsoft that says to restart the computer, this works but we don’t really want to restart our integration testing server between builds.

edit:

This problem seems to happen when on the previous run the service failed to start. eg. where we get the error:

ServiceName service is starting …

f:\TeamCityUser\Checkout\trunk\dev\build.xml(187,
5): Cannot start service ServiceName
on computer ‘COMPUTERNAME’.

So it looks like it is after failing to start the service when we cannot remove the service until after a reboot. I believe in this instance the reason the service didn’t start was because the constructor of the main service class threw a FileNotFoundException. The class is derived from ServiceBase.

I would still like to know how to delete a service without having to reboot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:03:45+00:00Added an answer on May 16, 2026 at 10:03 pm

    As indicated in the note, you should stop the service before uninstalling it. To do so you could use the ServiceController task to stop the service and ServiceQuery to check that it has been stopped.

    <PropertyGroup>
      <ServiceName>Service</ServiceName>
    </PropertyGroup>
    
    <Target Name="StopService">
      <ServiceController ServiceName="$(ServiceName)" Action="Stop" />
    
      <CallTarget Targets="WaitStop"/>
    </Target>
    
    <Target Name="WaitStop">
      <Sleep Milliseconds="1000" />
    
      <ServiceQuery ServiceName="$(ServiceName)">
        <Output TaskParameter="Status" PropertyName="ServiceStatus" />
      </ServiceQuery>
    
      <!-- If the service isn't stopped we execute WaitStop again -->
      <MSBuild Condition="'$(ServiceStatus)' != 'Stopped'"
               Projects="$(MSBuildProjectFile)"
               Targets="WaitStop"/>
    </Target>
    
    <Target Name="UninstallService" DependsOnTargets="StopService">
      <UninstallAssembly
        AssemblyFiles="..\src\FolderName\ProjectName\bin\Debug\ProjectName.exe"
        ContinueOnError="false">
      </UninstallAssembly>
    </Target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting up a project using Hibernate 3.3.1 GA and PostgreSQL 8.3 .
I'm setting up a new project using CruiseControl.net 1.4. I see from ccnet contributions
I'm running Eclipse Europa (3.3). I leave the Build Automatically setting, under the Project
I'm using Moq to write the unit tests for a project, and one of
We're setting up a new build server with CruiseControl.Net and MSBuild. After quite a
I was wondering if the C# project setting Allow unsafe code applies only to
I'm in the process of setting up a php project, but am not very
In a .NET project, say you have a configuration setting - like a connection
Why isn't Visual Studio 2005 generating a serialization setting when I set the project
I've got a setup project for a Windows Service (.net 3.5, visual studio 2008).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.