renevanosnabrugge / vsts-promotepackage-task

Promote a package in VSTS to a Release View
MIT License
20 stars 25 forks source link

Task doesn't work on linux agent #68

Open older opened 3 years ago

older commented 3 years ago

I'm getting the following error message when running on Azure DevOps Linux agent (task version 3.0.9):

##[error]The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.

There's PowerShell Core installed on Linux build agents, can it be used to run this task?

jessehouwing commented 2 years ago

No, this task only runs on windows.

You can add a 2nd job to your pipeline to run this task on a Windows agent.

older commented 2 years ago

But is there anything in task which makes it incompatible with PowerShell Core? I see call to [System.Web.HttpUtility]::UrlEncode($packageVersion) which could probably be replaced with [System.Uri]::EscapeDataString($packageVersion), is there more?

jessehouwing commented 2 years ago

The fact that it's PowerShell at all. The task must be written in Typescript/JavaScript to run on the Linux agent.

image

https://github.com/Microsoft/azure-pipelines-task-lib#powershell-tasks

jessehouwing commented 2 years ago

It may be possible to wrap the existing PowerShell file in a node task... But it would be a bit if a weird construction.

older commented 2 years ago

Ah, that means rewriting it in TypeScript is the only way to make it work. Thanks for explaining!

Maybe then make this explicit? Add Agent.OS -equals Windows_NT demand. Schema for task.json seem to allow custom demands.

jessehouwing commented 2 years ago

Azure pipelines should be clever enough to know it only has a PowerShell handler ;).

On Wed, 12 Jan 2022, 10:35 Oleg Deribas, @.***> wrote:

Ah, that means rewriting it in TypeScript is the only way to make it work. Thanks for explaining!

Maybe then make this explicit? Add Agent.OS -equals Windows_NT demand. Schema for task.json https://github.com/Microsoft/azure-pipelines-task-lib/blob/master/tasks.schema.json#L113 seem to allow custom demands.

— Reply to this email directly, view it on GitHub https://github.com/renevanosnabrugge/vsts-promotepackage-task/issues/68#issuecomment-1010837929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA724S53ZY7P26C7GNDAOMDUVVDPXANCNFSM46AMWTQQ . You are receiving this because you commented.Message ID: @.*** com>

older commented 2 years ago

I agree that it should be, but it is not clever enough, unfortunately ;) Also that error message For example, written for Windows Desktop PowerShell leaves wrong impression that task could replace Windows Desktop PowerShell with PowerShell Core in order to run on Linux agent.

NightOwl888 commented 2 years ago

It is worth noting there is a blog post about how to convert to Node.js without a complete rewrite: https://blogs.blackmarble.co.uk/rfennell/2019/12/28/a-technique-for-porting-powershell-based-azure-devops-extensions-to-node-so-they-can-be-run-cross-platform-without-a-complete-re-write/

Also, there is a (now closed) issue about adding PowerShell Core support on Azure DevOps tasks here: https://github.com/Microsoft/azure-pipelines-tasks/issues/9201. Since Powershell Core became a thing, there is no technical reason why Powershell tasks shouldn't run cross-platform if support were added on Azure DevOps. I suspect to get that done, the community will have to submit a PR, as Microsoft doesn't consider it high enough priority. But it would probably help to vote on that issue and comment that xplat support is needed.

jessehouwing commented 2 years ago

Problem would be having to maintain multiple versions to keep supporting on-premises installations.

Wrapping the PS in a typescript task is the quickest way to add support.

Though on-premises agents may not have pwsh installed and the Node handles will take paesedence over the PowerShell one. I remember options for OS constraints on the execution handler configuration.

This would be the most supportable and quick to realize option apart from a rewrite in Typescript as a whole.

jessehouwing commented 2 years ago

Last time I checked there was very little appetite for a pwsh execution handler, as it would add to the support burden. The team was happy to get rid of the old in-process PowerShell handler. It's just one mort thing to test and one more thing that can break.

And PowerShell 5.1 is available on all windows servers, pwsh isn't.

olegd-superoffice commented 9 months ago

For anyone who might be looking for alternatives. There's another task in typescript which might work: https://github.com/donalfenwick/azuredevops-promote-artifact-version