Software installation on multiple systems with PowerShell

Posted on by 0 comment

In this exercise, I will try to install a software on multiple systems with PowerShell, which could reduce some maintenance effort when we need to install or patch some software regularly. The way here is to copy installation file to c:\temp first to remote systems, then install it with remote session, and then check registry and see the installation details.

Category: PowerShell

psake script in Visual Studio

Posted on by 0 comment

A sample project will be set up in Visual Studio for writing psake script,

  • Create a new Class Library Project
  • Install Nuget Package – psake
  • Add a default.ps1 file with some test script, or that can be copied from packages\psake.x.x.0\tools\examples default.ps1
  • Execute the script:
Category: psake

Team City Meta-Runner for TOSCA CI

Posted on by 0 comment

In TOSCA Distributed Execution, we discussed how to integrate TOSCA Distributed Execution with Team City, which we have two steps for triggering the execution. Since we need to use them for multiple build configuration, so considering to wrap them one step with Team City Meta-Runner.

The Meta-Runner can be extracted from an existing build configuration. In this case, open the build configuration to be extracted, and go to Actions -> Extract Meta-Runner, Enter or adjust values for Project, Name, ID, Description, and then click Extract button, then make changes if required.

Or we could write it manually as long as we have the right XML structure.

Below is the sample Meta-Runner for TOSCA execution, which can be uploaded into your Team City project.
It will take parameters:

  • Test Configuration: Part of TOSCA test configuration file, which insides of node testConfiguration
  • Result file: the junit format result XML file

Category: Team City, TOSCA

Restore MSSQL Database

Posted on by 0 comment

Kill active sessions

Firstly, it would be better to stop all the applications/services which are connecting to the Database which needs a restore.
Then, kill the active sessions as this will block the restore process if there are any active sessions.

Restore DB

Change user

Category: MSSQL

Simple Dependency Injection with dynamic finder at runtime

Posted on by 0 comment

Sometimes, we have multiple methods to be called, but it has to be determined at run time, so try to make it less coupled and use reflection to achieve this. The sample scenario here is for Field Type. We have different implementation for each different field type, such as text, date etc., and at run time, a DoSomething method should be called based on the field type.

Firstly, an interface is defined, which has methods called IsValid and DoSomething, IsValid method is used for a certain implementation which is valid for certain Fieldtype.

Then, implement the finder method which accepts a TestFieldType parameter. And now we are able to GetTestField based on the parameter we pass, and call the respective DoSomething method as desired.

Category: C#