0

Is it possible to execute Msbuild commands from perl?

In powershell i use to retrieve all the Visual studio 2010 environment variables then call Msbuild commands directly.

function SetVS2010()

{

    $vs100comntools = (Get-ChildItem env:VS100COMNTOOLS).Value

    $batchFile = [System.IO.Path]::Combine($vs100comntools, "vsvars32.bat")

    Get-Batchfile $BatchFile

    [System.Console]::Title = "Visual Studio 2010 Windows PowerShell"

}



function Get-Batchfile($file)

{

    $cmd = "`"$file`" & set"

    cmd /c $cmd | Foreach-Object {

        $p, $v = $_.split('=')

        Set-Item -path env:$p -value $v

    }

}


SetVS2010

Function Update-VersionInfo {
    &"$MsbuildBinPath\Msbuild.exe" $MSBuildFile /t:UpdateVersionInfo $Logger $AllErrLogger
}

It was a great help. Whether the same can be archived in perl?

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230

1 Answers1

1

perl has standard facilities like system() (Execute a command in subshell) and exec() (executes a command that replaces the executing process). Other process handling facilities are in the Win32:: namespace. I see no reason why you should not be able to run Msbuild commands using a combination of the aforementioned facilities.

You will have to manuipulate the command's environment with a trick similar to the one you are using or you might be able to get the desired effect by simply manipulating the environment of the perl process (by accessing %ENV).

Alien Life Form
  • 1,884
  • 1
  • 19
  • 27