Search code examples
windows-servicesazure-devopsazure-pipelinestopshelf

How do I get my Windows service solution to produce an artifact with VSTS Build?


I have a build definition in Visual Studio Team Services (a.k.a. Visual Studio Online? I'm not really sure the right name for it honestly) that is not producing an artifact, and I'm really not sure why. The main project in the solution file is a Windows service that is built using TopShelf. I suspect that maybe the MSBuild arguments in the Visual Studio Build task might be wrong. I copied them from a build definition for an MVC project that is working, but it occurs to me that they might not work for a Windows service.

Here they are:

/p:DeployOnBuild=true 
/p:WebPublishMethod=Package 
/p:PackageAsSingleFile=true 
/p:SkipInvalidConfigurations=true     
/p:PackageLocation="$(build.artifactstagingdirectory)\\"

I have a Copy Files task and a Publish Build Artifacts task later on in the process, but apparently the $(build.artifactstagingdirectory)\\ is empty. I get this warning:

##[warning]Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact

Oddly enough, in another task in the process where I publish the symbols, everything appears to go off without a hitch.

One more bit: I'm using a hosted build agent. Not sure if that matters or not.

That's all of the pertinent information I can think to provide. Am I way off base here? I've used Octopus Deploy in the past and I know I had to install Octopack on my services. Do I need to do something similar here?


Solution

  • You don't need any of those MSbuild arguments; most of them apply to ASP .NET projects and will do nothing for a console application.

    Replace them all with /p:OutDir=$(Build.ArtifactStagingDirectory). That will tell MSBuild to put the build outputs in the artifact staging directory.