Search code examples
.netdeploymentmsbuildpsexectopshelf

Cannot install TopShelf service using MSBuild and PSExec


Having copied over the bin directory, I am attempting to install a Topshelf service from a TeamCity build server onto our dev server, using MSBuild & psexec:

<Exec Command="psexec \\$(ServerName) $(ServerBinDirLocal)\$(ProjectName).exe install -displayname $(ApplicationLongName) -description &quot;$(ServiceDescription)&quot; --networkservice --delayed" ContinueOnError="false" />

However, whatever combination of quotes I try, I always get:

The command "psexec \\srv06541wn d:\Bin\Service.DEV\Service.exe install ..." exited with code 9009. 

This is a DNS error, apparently, but I can't see how this is the issue, as I am supplying a local and not UNC path. The build server account is an administrator on the destination server, so this should work?


Solution

  • So there's a couple possible solutions here but this isn't a Topshelf issue specifically. I'm guessing that 9009 is lie though.

    1. The first possible is that you need the full path for psexec. C:\...\psexec. You can test this out by changing the command to be something really simple and making sure it works. psexec might not be on the path for TeamCity.
    2. Verify that it works with the hostname without the FQDN. TeamCity might not have the same context as you do.