Mass Compile

Hi , 

On Unix system we could do a mass compilation using shell scripting . Getting the Program names from a single location and passing them to the cob command for compilation.

How do i implement that in Visual COBOL Powershell Environment . How do i compile my various Projects under D:\Visual Studio 2013\Projects i one go.

In Unix i could get my program name dynamically from a particular directory as source pgms are at one location, but using MSBUILD i need to go inside the Project folder containing the .cblproj for each project

Thanks,

Zoeb

  • Why are you not simply using msbuild.exe on the solution file or files? It's not clear what problem you're trying to solve.

  • I want to compile multiple projects in one go ... without passing the project name manually.

  • I want to compile multiple projects in one go ... without passing the project name manually.

  • You just use batch file that has a recursive for, for example:

    buildall.bat that contains:

    setlocal
    cd /D "D:\Visual Studio 2013\Projects"
    for /R %%i in (*.sln) do msbuild %%i
    
  • Verified Answer

    Thanks I wrote one Powershell scripts to do that.

    ####This Script is used for Mass Compilation of Projects under BaseDir

    ####Author - Zoeb Patrawala

    ####Date Written - 29/08/2016

    ####Script Name - MassCompile

    Clear-Host

    Write-Host 'Mass Compilation Started .....'

    ###set Up MSBUILD Parameters

    $msbuild = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe'

    $OutputPath = '/p:OutDir="D:\Visual Studio 2013\Build_Executables\\"'

    $Releaseoptions = '/p:Configuration=Release'

    ###set up Directory Path

    $baseDir = 'D:\Visual Studio 2013'

    $projectDir = $baseDir '\Projects'

    $TempFile = $baseDir '\temp.txt'

    $LogFile = $baseDir '\Build_Log.txt'

    $ErrFile = $baseDir '\Build_Err.txt'

    ###Delete the Old Temp file

    if (Test-Path $TempFile)

    {

     Remove-Item $TempFile

    }

    if (Test-Path $LogFile)

    {

     Remove-Item $LogFile

     New-Item $LogFile -type file

    }

    if (Test-Path $ErrFile)

    {

     Remove-Item $ErrFile

    }

    ###Start gathering Information

    cd $projectDir

    Get-ChildItem -name > $TempFile

    ###Compile Each Project Solution

    foreach($fileName in Get-Content $TempFile )

    {

     $solnPath = $projectDir '\' $fileName

     $solnFile = $solnPath '\' $fileName '.sln'

     if(Test-Path $solnFile)

     {

       cd $solnPath

       $clean = $msbuild ' ' $fileName '.sln ' ' /t:Clean ' $OutputPath ' ' $Releaseoptions

       $build = $msbuild ' ' $fileName '.sln ' ' /t:Build ' $OutputPath ' ' $Releaseoptions

       Write-Host 'Compiling : ' $solnPath

       Invoke-Expression $clean >> $LogFile

       Invoke-Expression $build >> $LogFile

       if ($LastExitCode -ne 0)

       {

    #To Halt further Execution use throw

    #    throw "MSBUILD Command failed with exit code $LastExitCode."

          if (Test-Path $ErrFile)

          {

             Write-Host ' ' >> $ErrFile  

          }  

          else

          {

             New-Item $ErrFile -type file  

          }

          Write-Host 'MSBUILD Command failed with exit code $LastExitCode.'

          Write-Host 'MSBUILD Command failed for : ' $solnPath >> $ErrFile

       }

     }  

    }

    if (Test-Path $ErrFile)

    {

     Write-Host ' '

     Write-Host 'Check Error File at loaction : ' $ErrFile

    }

    Write-Host 'Mass Compilation Completed ...'