You can ignore the Add some code! call to action as we'll address this from Visual Studio.Īlternatively, if you want to go down the route of having all your scripts in one team project then you can simply create a new team project based on Git - called PowerShellScripts for example. Click on the down arrow next to the currently selected repository and in the popup that appears click on New repository:Ī Create a new repository dialogue will appear - I created a new Git repository called PowerShellScripts.
Navigate to the team project in VSTS and then to the Code tab. If you want your scripts to live in associated team projects then you'll want to create a dedicated Git repository to hold the Visual Studio solution. It's horses for courses so I'll show both ways. VSTS is based around team projects, and the key decision is whether you want your scripts located together in one team project or whether you want scripts to live in different team projects - perhaps because they naturally belong there. Now we know that our PowerShell scripts are going to be version controlled by VSTS the next thing to decide is where in VSTS you want them to reside. In my implementation below I'm using Git as the version control technology, so please amend accordingly if you are using TFVC. If you want to learn about PowerShell Tools for Visual Studio I have a Getting Started blog post with a collection of useful links here.
The great thing is that both these tools are free for small teams.
The aim of this post is to explain how to use Visual Studio and VSTS to version control PowerShell scripts rather than understand how to start using those tools, so if you need a primer then good starting points are here for Visual Studio and here for VSTS. As you've probably already guessed from the blog title, the tools I'm suggesting are Visual Studio (2015, for the script editing experience) and Visual Studio Team Services (VSTS, for version control). Whoa - Visual Studio supports PowerShell as a language? Since when did that happen? Since Adam Driscoll created the PowerShell Tools for Visual Studio extension is since when. And if you aren't a Visual Studio developer then the same tools can still be used - very possibly for free. If you are a Visual Studio developer then tools you are already likely using offer one solution to this problem. How about running your own version of Git server? Nah.
Not passwords or anything like that, just inner workings that I'd rather keep private.
No matter, if you can live without a seamless experience the next question in this scenario is what version control technologies can be used? Probably quite a few, but since Git is the hot topic of the day how about GitHub - the hosted version of Git that's free for public repositories? Ideal since it's hosted for you and there's the rather nice GitHub Desktop to make things slightly less seamless. Hang on though - if you are like me you probably have all sorts of stuff in your PowerShells that you don't want being publicly available on GitHub. Consequently, if you want version control and you want to continue using the ISE you'll need to manage version control from outside the ISE - which in my book isn't the seamless experience I'm used to. Whilst it's a reasonably capable editor it doesn't have integration points to any version control technologies.
Unless you are a heavyweight PowerShell user and have adopted a specialist editing tool, chances are that you are using the PowerShell ISE (Integrated Script Editor) that comes with Windows for editing and running your scripts. In this post I'll be sharing how I solved this, but first let's take a quick look at the problem. Shock, horror I know - but I'm pretty sure I'm not alone. Despite being a developer who's used version control for years to manage application source code one thing I've been guilty of for some time now is not version controlling my PowerShell code scripts. It's a new year and whilst I'm not a big fan of New Year's resolutions I do try and use this time of year to have a bit of a tidy-up of my working environments and adopt some better ways of working. Version Control PowerShell Scripts with Visual Studio and Visual Studio Team Services Posted by Graham Smith on Janu3 Comments (click here to comment)