Install PowerShell Modules on hosted agent in VSTS (Visual Studio Team Services)

Visual Studio Team Services (VSTS) is popular tool of choice for various purposes where product is heavily dependent on Microsoft technologies like .NET, Azure, etc. It does lot of work such as Source code management, Building CI/CD pipelines, Package Management, Agile Issue tracking, etc. It is a cloud hosted service offering from Microsoft.

Hosted agent is a build agent that is provided by Microsoft for build and continuous integration purposes. However, you don’t have much control over the configuration of the hosted agent. It comes with most of tools you would normally require for building your source code. Now, when building PowerShell, it will come with latest version of PowerShell, so you can use built in package management cmdlets like Install-Module. Occasionally, you would need to install custom PowerShell modules such as SqlServer (Formerly known as SQLPS). Continue reading “Install PowerShell Modules on hosted agent in VSTS (Visual Studio Team Services)”

VSTS Azure SQL Database Deployment task keeps failing with Error: Login failed for user

The task is used to deploy Azure SQL Database to an existing Azure SQL Server, either by using DACPACs or SQL Server scripts. The DACPACs are deployed using SqlPackage.exe and the SQL Server scripts are deployed using the Invoke-Sqlcmd cmdlet. DACPACs and SqlPackage.exe and Invoke-Sqlcmd cmdlet provides for fine-grained control over the database creation and upgrades, including upgrades for schema, triggers, stored procedures, roles, users, extended properties etc. Using the task, multiple different properties can be set to ensure that the database is created or upgraded properly.  Continue reading “VSTS Azure SQL Database Deployment task keeps failing with Error: Login failed for user”

Debugging PowerShell in Visual Studio Code – Part 02

In this blog post, we’ll continue from where we left earlier in the previous post on debugging PowerShell using Visual Studio code. You may be beginning to notice that the debugging features offered in Visual Studio code are far ahead in terms of usability.

Not only that, we can set line breakpoints (which can be specified by pressing F9 on code line in reference), we can also set conditional breakpoints, functional breakpoints and trace breakpoints.

A functional breakpoint can be defined as breakpoint which is invoked on calling of a particular function. You can set a function breakpoint to break into the debugger not only on a particular function invocation but also on an alias, a built-in command, or application invocation.  Continue reading “Debugging PowerShell in Visual Studio Code – Part 02”

Debugging PowerShell in Visual Studio Code – Part 01

In one of the previous post, we discussed how to use visual studio code for PowerShell development. Writing scripts in Visual Studio code is now more or less at par with ISE (Integrated scripting environment) and in a few cases, is more useful. However, you do need to be able to make sure that whatever code you have written in PowerShell, should be able to run as intended. Also, if its not working as intended, you should be able to debug and see where you went wrong. In this blog post, we’ll discuss how to use Visual Studio code for debugging. These features are provided by the PowerShell extension, or, more accurately, by the PowerShell Editor Services module which comes with the PowerShell extension. PowerShell Editor services not only provides language services to the Extension (which in turns provide services to Visual Studio code) but also provides useful debugging features. Continue reading “Debugging PowerShell in Visual Studio Code – Part 01”

Compare files with Visual Studio

Visual Studio 2015 file comparison tool can be considered good enough for most of the use cases. Before learning how to compare files with Visual Studio, I used to use WinMerge, or another tool to compare. Not anymore of that!

What is still missing in the IDE is a small menu that allows us to select 2 files and compare them. From command line, you can do it with devenv.exe /diff which compares two files. It takes four parameters:
SourceFile, TargetFile, SourceDisplayName(optional), TargetDisplayName(optional) Continue reading “Compare files with Visual Studio”

Customize Visual Studio Code settings for PowerShell development

This post is continuation of series of PowerShell development using Visual Studio code. In this blog post, we’ll see how to customize Visual Studio code for PowerShell development. One of the great features of Visual Studio Code is the extent to which you can customize it. Each extension usually provides customizable settings, too. To begin to customize Visual Studio Code, select the Command Palette from the View menu, or press Ctrl+Shift+P (Cmd + P on the Mac), type user, and then select Preferences: Open User Settings.  This will open two editor windows as shown in the following screenshot:  Continue reading “Customize Visual Studio Code settings for PowerShell development”

Using Visual Studio Code for PowerShell Development

It has been a long time since the PowerShell integrated scripting environment (ISE) shipped with Windows PowerShell 2.0 in 2009. Since then .NET has become open source and cross-platform in form of .NET Core. Since PowerShell is built on top of .NET, it was an important pre-requisite before making PowerShell cross platform. Also, PowerShell has become cross-platform as of today. It is also open-source like .NET core. You can find the same at GitHub as well. In fact, we did discuss the open-source PowerShell namely 6.0 installation in few of the earlier posts as wellContinue reading “Using Visual Studio Code for PowerShell Development”