What's the best way to run a linqpad script from your release pipeline? - powershell

I have a linqpad script which we need to run as part of our release, from VSTS. Best way I can think of is to run this as a Powershell script. There seem to be 2 options to be able to do this
Linqpad's native lprun.exe
Linqpadless lpless.exe
The problem with these however is that I will have to install these on the Build/Release VMs for each environment, which is what I'm trying to avoid at the moment.
Linqpadless does distribute a nuget package but I don't know how to run that from powershell/release pipeline.
Has anyone done something similar. What's the best way to achieve this?

You can add three tasks in your build definition to do this:
Nuget Task to install linqpadless package:
Command Line task to run lpless.exe:
Command Line task to run the script generated by lpless.exe in last step:
If you want to use Powershell script, you just need to call these command in the script one by one.

Related

Azure devops - Preparing self hosted test agents

What is the best way to create a list of Self-hosted agents in Azure Devops (In order to run Automated tests with Smartbear TestExecute) without doing all the steps manually ?
Let's assume that there will be 40-50 PCs running Windows 10 which have to be made an agent and linked with the Azure pipelines.
I'm looking for a way to avoid doing these steps 50 times:
Create these agents manually by following all the steps here https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops and then
Install TestExecute on each of them
Is there a Template that one can create and run to Implement this ?
The --unattended option mentioned here should do it for you.
For the purpose of automating your test environment, probably you can take a look at Ansible: win_package, Ansible extension
Haven't tried it myself, but maybe you could install the downloaded agent, run the PS scripts and then install the Smartbear TestExecute inside one playbook.
You can try installing TestExecute in silent mode from the command line to avoid doing that manually. As for configuring agents, the test agent deployment task is now deprecated, so it looks like there's no way to skip doing that.

Debug Azure Devops powershell scripts locally in VSCode

Judging from the Debugging Azure Functions https://learn.microsoft.com/en-us/azure/azure-functions/functions-debug-powershell-local, it looks possible. Can somebody post a detailed example?
Let's say we have pipeline that run the Build.ps1. The script installs other PS modules builds my Visual studio solution and creates the installer.
The installer part breaks so I guess I have to use a Wait-Debugger before it and try to somehow attach to the agent powershell process. But oi am not certain how to do it.

Does powershell have the ability to run tasks?

Is there an equivalent to Powershell make? The equivalent of make/rake/cake/py-make, even Gulp...etc? I primarily desire a task runner for build automation. I want to be able to select and compose tasks like I can in Gulp.
Ideally, the solution would be native to Powershell. There are very tight security restrictions on software installations for the project. The power of Google has failed me.
nothing built-in, but there are different solutions like psake or invoke-build. maybe something else.
You can also use VScode for that, you can define tasks (basically run scripts or something) and run them on save or on check out, etc

Run powershell build step in VSTS agent installed on mac?

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://github.com/PowerShell/PowerShell) and re-installed the agent, VSTS complains it does not have agent that is capable to run the build.
No agent could be found with the following capabilities:
DotNetFramework, Xamarin.iOS, npm
When I disable the build step, builds work just fine.
Is it possible to run powershell build step on Mac?
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
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.
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
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"
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.
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://learn.microsoft.com/fr-fr/powershell/scripting/install/installing-powershell-core-on-macos).

How to further automate Teamcity

I have successfully configured my project for build in TeamCity. Going a step more, I want to run a deployment script once a build completes successfully. The deployment script is a simple bash command. To make the question more simpler, how would I invoke a shell command once a build successfully completes in Teamcity.
Please help
TeamCity 6.0 has a new feature called Multiple Build Steps:
Multiple Build Steps: Now any build configuration can be comprised of unlimited number of build steps, where each step is represented by a build runner. Don’t limit yourself, and combine as many build runners into one configuration as you need. Feel free to call a NAnt script before compiling VS solutions, run inspections and duplicates finder after your ANT build, add NUnit tests after your Rake build, and so on.
So you can add a new build step with the command line runner which will execute your shell script.