Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a win32 service using MSBuild and Microsoft.Sdc.Tasks

I'm trying to install windows service using the Microsoft.Sdc.Tasks library.

<ControlService Action="Install"
    ServiceName="Service1"
    User="XXX
    Password="XXX"
    ServiceExePath="$(DeployFolder)\XXX.exe"/>

But I keep getting prompted for the user and password! This will not work as I'd like to have it as an automated build on the build server. I mean, the user and password that I want to run the service under are in the actual target. How do I get it to install the service using the configured user and password and not prompt for it?

like image 817
Riri Avatar asked Jan 22 '09 14:01

Riri


People also ask

Where MSBuild?

MSBuild is installed in the \Current folder under each version of Visual Studio, and the executables are in the \Bin subfolder.


1 Answers

Found this post and since all my service does is writing and reading from local file I should be OK running under the Local Service account instead of a specific user. Even after updated the service installer the ControlService-target requires a user and password to run but then I actually doesn't prompt me for the user and password. But then I don't want to run a specific user and the target fails when not provided with a user and password in the config ... Strange.

I solved by shelling out to the InstallUtil.exe instead. That works fine after set the I set service installer to run as a Local Service account.

<Exec WorkingDirectory="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"
            Command="InstallUtil.exe -i XXX.exe" />
like image 113
Riri Avatar answered Sep 29 '22 05:09

Riri