使用 Perl 调用以 Msbuild 编写的构建脚本
是否可以从 perl 执行 Msbuild 命令?
在 powershell 中,我用来检索所有 Visual studio 2010 环境变量,然后直接调用 Msbuild 命令。
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
}
这是一个很大的帮助。是否可以在 perl 中存档相同的内容?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
perl 具有标准功能,例如 system()(在子 shell 中执行命令)和 exec()(执行替换执行进程的命令)。其他进程处理工具位于 Win32:: 命名空间中。我认为您没有理由不能使用上述工具的组合来运行 Msbuild 命令。
您必须使用与您正在使用的类似的技巧来操纵命令的环境,或者您可以通过简单地操纵 perl 进程的环境(通过访问 %ENV)来获得所需的效果。
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).