Archive

Posts Tagged ‘PowerShell’

Powershell principles

October 24th, 2009 No comments

We have a document checked-in in the root of our source-control system for Applications. The document is the development principles we strive for. Most of them are basic, SOLID principles with highlights in how our code works.

Currently we’re focusing on automating the installation process for applications, the goal is to be able to handle a lot more installations without increasing the amount of people needed to handle our operations department. We’re removing a lot of manual error-prone steps, and were doing it using PowerShell.

Now my colleague is doing a lot of PowerShell work, and research, to automate different parts of the installation process. We identified that we needed to have a document to make sure that the PowerShell scripts follow guidelines just like with the rest of the code.

Now Johan has been doing a lot of work on this and we’re trying to get a lot of feedback on the guidelines. To increase the feedback we can get Johan has published the PowerShell guidelines on his blog. Please, have a read and any comment is appreciated.

Tags: ,

Updating ClickOnce deployment manifest with PowerShell

May 20th, 2009 No comments

We are automating some of our deployment using powershell. As such we use the command line tool mage.exe for signing our deployment manifests, in effect were creating them using mage.exe as well.

We needed to add the trustUrlParamter setting to one of our manifests. Using mageui.exe you just check the box for allowing the application to see the query string, but with mage.exe this isn’t possible.

What you need to do is modify the XML of the application.deployment manifest, adding the parameter as an attribute to the deployment tag.

<deployment install="true" >

Should become

<deployment install="true" trustURLParameters="true">

As I said, we’ve already automated the process of creating and signing deployment manifests using powershell, now we just need to add the element attribute before signing the manifest. Powershell has some nifty features for updating XML, part 3 of  Windows PowerShell in Action: Working With Text and Files in Windows PowerShell (Part 3) demonstrates this.

So just before invoking mage.exe to sign the manifest we add this litle piece of powershell code:

    $xml = [xml]( Get-Content $deploymentManifestPath )
    $trustUrl = $xml.CreateAttribute("trustURLParameters")
    $trustUrl.psbase.Value = "true"
    $null = $xml.assembly.deployment.SetAttributeNode($trustUrl)

Voila, the manifest now has the trustURLParameters set.