Recently I wanted to build and run a .NET core console application in Azure DevOps and found out you cannot do that with the default .NET core tasks.
The default tasks in Azure DevOps and tutorials are more geared towards web-development and publishing a zip file that can be used with a WebDeploy command.
For an application,I would have thought that you could run the compiled assembly by calling
dotnet run path-to-assembly on it. Turns out that the run command is used to run the code from a project, not from a compiled assembly (see the docs).
You can just call
dotnet path-to-assembly, but the .NET core tasks in Azure DevOps will not let you do that: you can select a custom command, but you cannot leave that command empty for example.
Here’s how to go around that limitation: publish the application for the platform(s) you want to run: that way you’ll have an executable that can be executed with a PowerShell task. I choose the Windows platform as a target and published the files to a separate
You can then run it in a release. The release just consists of extracting the build artefact, overwriting the application settings with an Azure DevOps Extension and running the executable.
An even easier way to run the assembly is to call the dotnet command on the assembly itself, just do it in a PowerShell task: