July 18, 2012

Connect to TFS with different Credentials

Very recently I stumbled upon a problem that launching Vistual Studio 2010 / Team Explorer 2010 to access Team Foundation Server 2010 always took me to the default login which had limited privilege (only few projects were accessible).

runas /netonly /user:domain\username <Program Files>\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

/netonly : Indicates that the user information specified is for remote access only. It just tells runas that the credentials will be used for accessing remote resources

Thanks to stackoverflow for the solution.. here you go with the reference post.

July 12, 2012

SCM Commands - A Comparison

During Build Automation, accessing the source control via command line and performing various operations like getting the source, check-out & check-in of the updated version information files, creating a snapshot branch / labeling etc., plays a cruicial role.
Here is a list of most widely used SCM commands from TFS, Surround SCM and Subversion.
 
SCM Commands - A Comparison

The above table is based on my understanding and any suggestions / comments are welcome.

July 11, 2012

Updating an xml file using VBScript Custom Action

  1. Create a VBScript Custom Action stored in Binary Table (MSI Type Number: 6)
  2. Here is the Sample xml file (say address.xml), which is considered for updating in the below VBScript CA
         <Address>
              <Name>Smitha</Name>
              <Address1>123B, 16th Cross</Address1>
              <City>Bangalore</City>
         </Address>
  3. Write the following code in the VBScript file
Function UpdateXMLFile
     On Error Resume Next               
         
    Set objDOM  = CreateObject("Microsoft.XMLDOM")
    Set objParentNode = CreateObject("Microsoft.XMLDOM")    
    if Err.Number = 0 then             
          
                       ' Declaration
                       
dim FileName
                       dim name
                   
   dim address1
                     
  dim city
   Set objNet = CreateObject("WScript.NetWork")                
   set objNet=nothing                
              
    name=Session.Property("NAME")    
    address1=Session.Property("ADDRESS1")
    city=Session.Property("CITY")
 
     'update address.xml file
      FileName= Session.Property("INSTALLDIR")+"\"+"address.xml" 
      objDOM.async = false  
      objDOM.load(FileName)                                                
     if (trim(name)<>"" and trim(address1)<>"" and trim(city)<>"") then
         ' update name
          strXPath = "
/Address/@Name"
          set objParentNode = objDOM.selectSingleNode(strXPath)
          objParentNode.text = name           
 
         ' update address1
          strXPath = "
/Address/@Address1"
          set objParentNode = objDOM.selectSingleNode(strXPath)
          objParentNode.text = address1           
 
        ' update name
         strXPath = "
/Address/@City"
         set objParentNode = objDOM.selectSingleNode(strXPath)
         objParentNode.text = city 
  
         objDOM.Save(FileName)
                     end if
                 end if
           end function ' End of UpdateXMLFile

  4.    Set the following properties for the Custom Action (RestartIIS)

  Script Function -> UpdateXMLFile
  Return Processing -> Synchronous (Check exit code)
  In-Script Execution -> Immediate Execution
  Install Exec Sequence -> After InstallFinalize
  Install Exec Condition -> &FeatureA=3 and Installed.
This condition means that FeatureA is selected for installation and the FeatureA is installed (Installed state will be true as the CA is scheduled to execute after InstallFinalize).       

  [Note: This code snippet is tested with InstallShield 2012 Basic MSI Project. Should be compatible with earlier versions of InstallShield as well.]

July 10, 2012

Restarting IIS in MSI using VBScript Custom Action

This article focus on writing a Simple VBScript Custom Action to Restart IIS.

1. Create a VBScript Custom Action (RestartIIS) Stored in Binary Table (MSI Type Number: 6)

2. Write the following code in the VBScript file
Function RestartIIS()
     Set wsShell = CreateObject("WScript.Shell")
     Set fso = CreateObject("Scripting.FileSystemObject")

     winPath = WsShell.ExpandEnvironmentStrings( "%windir%" )
     netPath = fso.BuildPath( winPath, "system32" )
     toolPath = fso.BuildPath( netPath, "iisreset.exe" )
     WsShell.Run toolPath, 0, true
     set fso=nothing
     set WsShell=nothing  
End Function
3. Set the following properties for the Custom Action (RestartIIS) 
    Script Function -> RestartIIS
    Return Processing -> Synchronous (Check exit code)
    In-Script Execution -> Immediate Execution
    Install Exec Sequence -> After InstallFinalize
    Install Exec Condition -> &FeatureA=3 and Installed
                                           This condition means that FeatureA is selected for installation and the FeatureA is installed (Installed state will be true as the CA is scheduled to execute after InstallFinalize).
[Note: This code snippet is tested with InstallShield 2012 Basic MSI Project. Should be compatible with earlier versions of InstallShield as well.]

July 2, 2012

How to set Focus on your Installer dialog?

When we run an installer, sometimes the control switches between your installer and other application's screen, which might shift the focus from the installer dialog.

Here is how you can make sure to stay on top of your installer dialog unless you swtich explictly.

Call the function - SetInstallerDlgFocus(), before invoking each dialog, so that your installer will be always available in the foreground.

// Included header files
#include "WinApi.h"  // Required to Make Win32 API Calls

// Function declaration
prototype SetInstallerDlgFocus();

// Function definition
///////////////////////////////////////////////////////////////////////////////
//  FUNCTION:   SetInstallerDlgFocus
//  Purpose:    Bring window to the foreground. 
///////////////////////////////////////////////////////////////////////////////
function SetInstallerDlgFocus()
    HWND hDialog;
begin
      hDialog = GetWindowHandle(HWND_INSTALL);
      SetForegroundWindow(hDialog);
end; // end of SetInstallerDlgFocus


[Note: This applies to InstallScript MSI and Pure InstallScript type projects.]