I was following this lab guide when I come up against this error, while studying for the AZ-400 certification.
The Hands on Labs really are great and should be used if you are learning Azure DevOps.
Once I followed through the lab I was faced with "The current operating system is not capable of running this task. That typically means that the task was written for Windows only." when I tried to run the Release Pipeline. The Build Pipeline completed without issue so I decided to dig in a bit to find the cause, for once the error message was pretty descriptive.
The fix here was to change this to a Windows-based agent pool so that the code could execute.