0

我是 Powershell 的新手。我正在使用 power shell 脚本来构建 VB6 dll。

$compiler = "C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE".
$vbpPath= "C:\...\Desktop\ProjectFile\ProjectName.vbp"
$Outputpath = "C:\...\Desktop\Destination\ProjectName.dll"

Start-Process -FilePath "`"$compiler `"" -ArgumentList "/out
error.txt /make `"$vbpPath`" `"$Outputpath `""  -PassThru -Wait

我们可以在构建的时候自己设置它的产品版本吗?假设将产品版本设置为“Mysoftware 5.1 Beta 6”。提前致谢。

4

1 回答 1

0

嗨,遇到类似问题的任何人,

参考此链接后: 如何设置现有 .exe、.dll 的版本信息?

我能够在特定文件夹下更改 dll 和 exe 的产品版本。这一步是在所有 dll 和 exe 构建完成后完成的。

  1. 使用Resource Hacker从 exes/ dlls 中提取 *.RC 文件:

    $ResourceHackerPath = "C:\Tools\resource_hacker\ResourceHacker.EXE"
    $Dllpath = "...\MySoftware\Mydll.dll" 
    $RCpath = "...\MySoftware\Mydll.RC"
    Start-Process -FilePath "`"$ResourceHackerPath`""  -ArgumentList "-extract `"$ProductPath`",`"$RCpath`",versioninfo,," -wait                                                                          
    
  2. 在 *.RC 文件中编辑产品版本:

    $OriProVer = (Get-Item -literalpath $Dllpath ).VersionInfo.ProductVersion
    $NewProVer = "Mysoftware 5.1 Beta 6"
    (Get-Content $Dllpath).Replace($OriProVer, $NewProVer ) | Set-Content $Dllpath
    
  3. 使用GoRC将 *.RC 文件格式更改为 *.RES 文件:

    Start-Process -FilePath "`"$GoRCPath`""  -ArgumentList "/r `"$RCpath`"" -wait
    
  4. 再次使用 Resource Hacker 将 *.RES 文件添加到 dll 或 exe

    $RESpath = "...\MySoftware\Mydll.RES"
    Start-Process -FilePath "`"$ResourceHackerPath`""  -ArgumentList "-addoverwrite  `"$Dllpath `",`"$Dllpath `",`"$RESpath`", , ," -wait
    

您的 dll 的产品版本应该更新为您想要的任何字符串。

额外提示,如果你想更新很多 dll 和 exe 产品版本:你可以试试这个:

  1. 搜索特定文件夹下的所有 dll 和 exe:

    $directory = "...\Desktop\New Folder"
    $FileNameList = Get-ChildItem -literalpath  $directory -Include *.dll, *.exe  -recurse | foreach-object { "{0}" -f [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileName}
    
  2. 在 for 循环中执行上述所有 4 个步骤:

    for ($i = 0;$i -lt $FileNameList.count;$i++){...}
    

谢谢,祝你有美好的一天:)

于 2016-08-08T07:31:00.763 回答