asp.net-coreazure-devopsazure-pipelineskestrel-http-serverazure-artifacts

Use Azure Pipeline to start Kestrel from command-line?


We're currently using a pipeline to produce an artifact from a .NET Core project, and then deploying that artifact to a VM via a release pipeline. The pipeline grabs the artifact and unzips it to a folder on the VM. After that, we manually connect to the VM and start Kestrel, either by running the executable of the project or by running dotnet ProjectName.dll.

All of this works fine, except that we'd like to automate that last part. If possible I'd like to avoid having to reconfigure everything to use IIS. Is there a way to have the dotnet command executed from the pipeline, perhaps by somehow creating a service which can be started to execute the dotnet command?

For context - this is all for an internal QA environment. None of this will be exposed to the public, all traffic is firewall-restricted to internal IP addresses. The manual stop/start isn't really a huge problem, as we don't envision needing this for very long - just would be nice to have the whole thing fully automated.


Solution

  • Okay - so after doing some digging, I solved this by first using NSSM to register a service which runs the project .exe file, and then adding two additional steps. Before the extract/copy, I added a script task with net stop myService, and after the extract/copy I added a script task with net start myService.