Highlighted
Absent Member.
Absent Member.
1666 views

Mass Compile

Jump to solution

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

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Mass Compile

Jump to solution

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 ...'

View solution in original post

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Mass Compile

Jump to solution

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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Mass Compile

Jump to solution

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

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Mass Compile

Jump to solution

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Mass Compile

Jump to solution

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 ...'

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.