使用 Perl 调用以 Msbuild 编写的构建脚本

发布于 2025-01-05 00:30:52 字数 769 浏览 6 评论 0原文

是否可以从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2025-01-12 00:30:52

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文