We are trying to have a CI/CD pipeline strategy which involves force closing/killing a running dotnet process which is running on our VisualCron server:
The part that we are stuck on is that this VC server is running numerous jobs. In the past this wasn't an issue because a .NET Framework application was named appropriately 'somejob.exe'. However, with dotnet every process is running as dotnet.exe.
Is there a way to target a specific instance of a running dotnet.exe process to close/kill based on the entry point assembly passed into dotnet.exe? For example, dotnet c:\jobs\somejob.dll
-- we need to close/kill just this job (not the other dotnet jobs running).
I found a way to utilize the taskkill
tool to target a specific dotnet application, though the usage may vary based on the scenario.
In our scenario, our assemblies are named in a very unique fashion... All of our applications are namespaced out very well CompanyName.ProductName.ConsoleAppName.dll
. This allows us to use the filter command and filter based on a specific module:
taskkill /FI "Modules eq CompanyName.ProductName.ConsoleAppName.dll"
Clearly, had our assemblies not been named in a unique fashion, this would not work well, for example, if we had our console app named App.dll.