Run powershell build step in VSTS agent installed on mac?

后端 未结 6 812
暖寄归人
暖寄归人 2021-01-23 22:46

I installed VSTS build agent on mac to build xamarin iOS project. Builds worked fine until I added powershell build step. Even though I installed powershell for mac (https://git

相关标签:
6条回答
  • 2021-01-23 23:29

    This is a follow-up to the accepted answer to address a question in a comment which I also had.

    Thanks to spatialguy for posting and finding a simple solution to this problem. I had the same problem as KeithA45:

    QUESTION: What if you wanted to do the same, but also pass arguments to the Bash script which passes them to the Powershell script?

    I found a solution to this, first off, I modified the shell script task to include the Visual Studio Team Services (VSTS) environmental variables that I wanted to pass to the powershell script.

    Next, I pass the arguments through to the called powershell script by slightly modifying the shell script mentioned by the accepted answer.

    #!/bin/bash
    powershell ./Version.ps1 $1 $2
    

    Finally, in the powershell script, I catch the arguments that have been passed through using using param like this:

    param([string]$version, [string]$path)
    

    Wherein I can now use the variables $version and $path which contain the original arguments entered in VSTS to the needs of my powershell script.

    0 讨论(0)
  • 2021-01-23 23:32

    If you're sure that DotNetFramework is installed then you can go to the Agent Queues settings and add a custom Capability to it called exactly that.

    That should allow it to run but it might fail after that if the agent can't actually find them, but it might also succeed so it's probably worth a try.

    0 讨论(0)
  • 2021-01-23 23:32

    In TFS build go to Agents Queues=>Capablilities=>Add variable named as DotNetFramework and give value for mac agent's dotnet framework path.

    It's fix for the issue "No agent could be found with the following capabilities:DotNetFramework"

    0 讨论(0)
  • 2021-01-23 23:32

    Things seem to have moved forward because I ran successfully today a PowerShell@2 task on a Mac Self-Hosted Agent from an Azure DevOps build pipeline.

    By checking "Enable system diagnostics" when queuing the build, the log shows me that the task found itself the path to the PowerShell Core (pwsh) that I installed on my Mac with the help of Homebrew (brew cask install powershell - see https://docs.microsoft.com/fr-fr/powershell/scripting/install/installing-powershell-core-on-macos).

    0 讨论(0)
  • 2021-01-23 23:39

    No, you can't use a PowerShell task on a Mac, only node tasks are supported.

    PowerShell tasks as currently written in PowerShell3 which is not supported on Mac. You can request that the team implement this on http://visualstudio.uservoice.com

    0 讨论(0)
  • 2021-01-23 23:43

    As MrHinsh clarified, the PowerShell task cannot be used on Mac.

    As a workaround I used ShellScript task:

    With the following bash script:

    #!/bin/bash
    powershell ./SetAppVersion.ps1
    

    Also, the powershell installer did not seem to add powershell to my PATH so I had to add it:

    $ export PATH=$PATH:/usr/local/microsoft/powershell/6.0.0-alpha.16
    
    0 讨论(0)
提交回复
热议问题