Appveyor, Github and Chocolatey: Automatically Build your project and publish updates to Chocolatey

So the aim here is to get the PowerGist project a nice CI process. I want to accept pull requests to the github repository and have these changes build, tested (future) and be published to Chocolatey for people to install/update.

Before I go on, if you haven’t used chocolatey, its a great tool similar to apt-get on linux for installing applications – have a look at it now, I’ll wait. Good, now that’s sorted lets crack on.

As this is a free time project, this CI process needs to be buttery smooth. There is nothing like a bit of friction (anywhere but mainly when releasing) to put you off doing an update, fixing a quick change or adding a feature. At the end of the day I want to write the code, accept a pull request or do a commit and have everything happen automagically.

There is one exception to this, I don’t want every build to release to Chocolatey, I want a release gate. When a build succeeds I want a versioned artifact to be created, I can then review this and click a big “Go” button, when happy, to push this to Chocolatey.

I’ve been looking at appveyor for a while now and this was the perfect project to take it for a spin, didn’t regret it – got exactly what I wanted.

So let’s get into it, first of all setup your Project:

Continue reading

PowerGist – Source Control for Powershell ISE with Github Gists




Get Chocolatey (awesome command line installer for windows)

Open powershell as administrator and type:

C:\> choco install powergist

Once that’s done simply type ISE and you’ll see it pop up on the right.

Login to your Github account and away you go.

*Warning – This was a quick project and should be considered Alpha quality to see if it was possible and/or useful. If you find a bug or issue head over to the github repo site to report it or fix it in a pull request*


One of the reasons I always advise people writing software to provide an API’s or a plugin model is that it allows end users to enhance the functionality of the product. If it doesn’t do what they want they can add it making your product better for free. It’s also a nice way to POC new features, internally, off the critical path.

So when I sat next to @StuartLeeks and said “I wish Powershell ISE integrated with some kind of source control” he pointed me to the addin model for ISE and said “Bet you can’t do it” (well known as a stealth motivation tactic for me within the team). So I set about trying.

The addin model is awesome. It’s nice and quick to get up and running and I was done writing a simple integration for Githubs Gist service (if you’ve never used it think git repos but for snippets) inside a day. I’ll go into a bit of detail on how to write addins in a future post, in the meantime feel free to have a look at the source.

Gracefully Drain Session from IIS Before Restarting/Stopping

I needed to do this recently when working with a team to automated releases of several websites.

The team have a fairly common setup. They’ve got more than one web server behind a load balancer, the load balancer calls a keep alive page to see if the servers are behaving and if they fail to respond stops sending them traffic until they’re healthy again.

What I wanted to do was rename the keep alive page, so the box stops getting new traffic, then wait for the existing sessions to complete and finally start updating it.

The second bit is key here, you don’t want customers using the site to get dropped mid-upload or form post.

I set about seeing what could be done with powershell and put together this little sample. It uses the IIS CmdLets to see how many sessions are still active and waits for them to complete before stopping IIS.

Thought it was a neat little sample worth sharing.

EDIT: I realized that the current script only looked at inflight http requests, I’ve put together a more complex script to interrogate the Active ASP Net sessions on a given IIS Website. See second file in the gist below, hopefully useful.


Get every new post delivered to your Inbox.

Join 312 other followers