I have a Microsoft Visual Studio 2010 solution that contains a .net logging component and a customer solution that uses this .net logging component. When I fix a bug in the .net logging component I use a PowerShell script to automatically update the .net logging component in the customer solution:

 

"Settings"
$vsPath                     = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\{0}"
$devEnvPath                 = [string]::Format($vsPath, "devenv.exe")
$tfPath                     = [string]::Format($vsPath, "tf.exe")
$rebuildLoggingSolution     = $true
$checkOutFiles                 = $true
$copyFiles                     = $true
$rebuildCustomerSolution    = $true
$checkInFiles                 = $true
$files                         = @("LoggingComponent.BC.dll",
                                "LoggingComponent.BE.dll"
                                )

"Settings Logging Component Solution"
$lcPath                         = "C:\Projects\LC\Main\{0}"
$lcSolutionPath                    = [string]::Format($lcPath, "Main.sln")
$lcReleasePath                     = [string]::Format($lcPath, "Source\LC\bin\Release\{0}")

"Settings Customer Solution"
$cPath                             = "C:\Projects\Customer\Main\{0}"
$cSolutionPath                     = [string]::Format($lpPath, "Main.sln")
$cSharedBinariesPath            = [string]::Format($lpPath, "Shared Binaries\{0}")

if($rebuildLoggingSolution)
{
    $parameters = """$lcPath"" /rebuild Release"
    "Process to start [$devEnvPath $parameters]"
    $process = [System.Diagnostics.Process]::Start( "$devEnvPath", $parameters )
    $process.WaitForExit()
}

if($checkOutFiles)
{       
    foreach($file in $files)
    {
        $path = [string]::Format($cSharedBinariesPath, $file)
        $parameters = "checkout ""$path"""
        "Process to start [$tfPath $parameters]"
        $process = [System.Diagnostics.Process]::Start( "$tfPath", $parameters )
        $process.WaitForExit()
    }
}

if($copyFiles)
{
    foreach($file in $files)
    {
        $source = [string]::Format($lcReleasePath, $file)
        $destination = [string]::Format($cSharedBinariesPath, “”)
        Copy-Item "$source" -Destination "$destination" -Force
    }
}

if($rebuildLocatiePlatform)
{
    $parameters = """$lpSolutionPath"" /rebuild Release"
    "Process to start [$devEnvPath $parameters]"
    $process = [System.Diagnostics.Process]::Start( "$devEnvPath", $parameters )
    $process.WaitForExit()
}

if($checkInFiles)
{
    foreach($file in $files)
    {
        $path = [string]::Format($cSharedBinariesPath, $file)
        $parameters = "checkin ""$path"" /noprompt"
        "Process to start [$tfPath $parameters]"
        $process = [System.Diagnostics.Process]::Start( "$tfPath", $parameters )
        $process.WaitForExit()
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.