A few weeks ago I wrote a (long) post on InRelease, since it has been released on November 13th, it is now officially called Release Management.
Release Management comes packed with useful Tools, Actions and the ability to create Components. With these items you can really shape your ReleasePath to your needs. But it could happen that there is something you want to achieve that is unavailable.
While there are several other options available in preparing your Web solution for deployment with Release Management, I recommend reading Colin Dembosky’s post on Web Deploy and Release Mangement – the proper way, I want to explore PowerShell options. Another option would be using the Tokonization functionality (not checked this against the Release Management release).
The following steps will guide you through the process on calling a custom PowerShell action from your Release Template.
Disclaimer: I am a PowerShell newbie, so there probably are more powerful or optimized scripts possible…
1. Lets create a PowerShell Script for your desired actions. Using the PowerShell ISE Editor will help you in getting the syntax right.
2. Lets create a very basis script first. Containing all hard-coded raw materials. Test the script to see if you got all the syntax and desired outcome. In this case, ‘BlogEngineData’ is replaced by ‘BlogEngineDEV’.
3. Now we have a functional script, lets add some parameters, so we enable reuse of the script. Validate the script by executing it.
4. Now open [Release Mangement], navigate to [Inventory] and then [Tools]. Then create a new [Tool]. The tool is capable of executing the powershell script, that will be added as a resource.
Notice that in the [Arguments] options we use the Release Management parameter syntax ‘__Parameter__’ (yes that is two! underscores to start and end with). All recognized parameters are listed in the Parameters section. For our script that is four.
5. Make sure you upload the PowerShell script as a Resource. Find my sample PowerShell Script here
6. To be able to use a [Tool] you need to create an [Action], so navigate to the [Actions] section within the [Inventory] and create a new [Action]. Follow the options below and you will be OK.
Tip: Create a Category for your ‘Custom’ actions. This will help you in adding them to the Release Template.
7. Now we have a new Tool and Action we are ready to use it on our Release Template. Navigate to [Configure Apps], [Release Templates] and open a template. Find your ‘Custom’ Action, drag it to the canvas, and fill all the properties.
8. Repeat this for all your Environments / Templates.
The Release Template is now ready to be used! With this example I hope to show the potential of using a custom PowerShell script to extend the Release Management Toolbox.
Happy Releasing!
Using this exact power shell script as an example while testing the Release Management software gives me an error as below at logs during the deployment. The deploy step status is succeeded and the change is not done with error in logs.
Error is
ReplaceTarget’4.0.0 <<<< '
is missing the terminator: '.
I have tried with other custom scripts which has been validated by executing it. Even those scripts throws the same 'missing terminator' error.
Hi,
Thank you for your comment, i think this has to be somewhat related to the values you are sending to be replaced.
Please check that the strings are properly between qoutes, and then you should be fine.
Regards,
Jasper
Can you please tell me where do you place the power shell script? Do we have to manually upload the script at some location?
Also is possible to create a exe file which does some XDT transformations for web.config file?
Where to keep those exe files so Release Management can have access to exe file when it runs.
Also within the exe project how do I get access to web.config file for the current release?
To run a powershell script downloaded from build output to the deployment agent (a script available in deployment machine) you can create general tool and action as I have explained here http://chamindac.blogspot.com/2014/07/tool-action-to-run-custom-powershell.html
If anyone is looking for a tool and action which can run a given powershell script in the deployment agent machine, without adding it as a resource to a tool as explained in this post refer to my post http://chamindac.blogspot.com/2014/07/tool-action-to-run-custom-powershell.html