使用 WiX、Inno Setup 和 VS2008 自动构建版本号

发布于 2024-07-11 06:30:28 字数 220 浏览 7 评论 0原文

基本上我需要的是一种自动化的方式来更新 WiX 中的产品版本号(3.0 与 Votive 等),然后将该版本号放入 Inno Setup“引导程序”中,

我几乎使该过程大部分自动化,但是版本号仍然需要手动更新这显然不理想,但我找不到如何在编译时将值传递给 Inno Setup(以及如何引用它们),并且在 WiX 项目中我需要知道如何引用版本Visual Studio 2008 中同一解决方案中不同项目的编号

Basically what I need is an automated way to update the product version number in WiX (3.0 with Votive etc), and then get that version number into an Inno Setup "bootstrapper"

I pretty much have the process mostly automated, however version numbers still need to be updated manually which obviously isn't ideal, but I couldn't find how to pass in values to Inno Setup at compile time (and how to reference them), and in the WiX project I need to know how to reference the version number of a different project in the same solution in Visual Studio 2008

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

居里长安 2024-07-18 06:30:28

不需要传递任何东西! 您可以简单地让 InnoSetup 预处理器直接从二进制版本资源中读取版本信息,例如:

#define AppName "My App"
#define SrcApp "MyApp.exe"
#define FileVerStr GetFileVersion(SrcApp)
#define StripBuild(str VerStr) Copy(VerStr, 1, RPos(".", VerStr)-1)
#define AppVerStr StripBuild(FileVerStr)

[Setup]
AppName={#AppName}
AppVersion={#AppVerStr}
AppVerName={#AppName} {#AppVerStr}
UninstallDisplayName={#AppName} {#AppVerStr}
VersionInfoVersion={#FileVerStr}
VersionInfoTextVersion={#AppVerStr}
OutputBaseFilename=MyApp-{#FileVerStr}-setup

在版本 5.4.1 (2011-02-09) 之前,ISPP 不包含在默认的 InnoSetup 包中。 您必须下载 InnoSetup 快速入门包: http://www.jrsoftware.org/isdl.php #qsp(感谢@Gwyn,更新)

No need to pass anything! You can simply let the InnoSetup Preprocessor read the version info straight from the binary's version resource, e.g.:

#define AppName "My App"
#define SrcApp "MyApp.exe"
#define FileVerStr GetFileVersion(SrcApp)
#define StripBuild(str VerStr) Copy(VerStr, 1, RPos(".", VerStr)-1)
#define AppVerStr StripBuild(FileVerStr)

[Setup]
AppName={#AppName}
AppVersion={#AppVerStr}
AppVerName={#AppName} {#AppVerStr}
UninstallDisplayName={#AppName} {#AppVerStr}
VersionInfoVersion={#FileVerStr}
VersionInfoTextVersion={#AppVerStr}
OutputBaseFilename=MyApp-{#FileVerStr}-setup

Before version 5.4.1 (2011-02-09) ISPP was not included in the default InnoSetup package. You had to download the InnoSetup Quick Start Pack: http://www.jrsoftware.org/isdl.php#qsp (thanks @Gwyn, for the update)

不喜欢何必死缠烂打 2024-07-18 06:30:28

您可以从包中的文件版本获取 WiX 的产品版本。 语法类似于:

<Product Version="$(var.FileVersion.FileId)">

或者您可以使用“-dVersionFromCommandLine=1.0.0.0”开关在命令行上提供它,语法如下:

<Product Version="$(var.VersionFromCommandLine)">

两者都适用于 WiX v3 的最新版本。 只有后者适用于 WiX v2。

You can get the ProductVersion for WiX from a file version in your package. Syntax is something like:

<Product Version="$(var.FileVersion.FileId)">

Or you can provide it on the command line to candle using the "-dVersionFromCommandLine=1.0.0.0" switch with syntax like:

<Product Version="$(var.VersionFromCommandLine)">

Either works in latest builds of WiX v3. Only the latter works on WiX v2.

难理解 2024-07-18 06:30:28

我的方法是使用 WSF 脚本(我使用 JavaScript,但您可以使用 VBScript,甚至使用 Cygwin 的 SH 脚本)创建一个包含版本号定义的头文件。 您可以使用 Wix 语句将版本号拖入。

对于 Inno Setup,我创建一个包含版本号的 .iss 文件,该文件被 #included 到主 iss 脚本中。

我在家,但如果您愿意,明天可以发布一些示例代码。

编辑:我忘了提及,我在各个 VS 项目的预构建阶段运行了生成包含内部版本号的文件的脚本。

The way I do it is with a WSF script (I use JavaScript but you could use VBScript or even an SH script using Cygwin) that creates a header file containing definitions for the version numbers. You can use the Wix <include> statement to drag the version number in.

For Inno Setup I create a .iss file that contains the version number, which is #included into the main iss script.

I am at home but can post some sample code tomorrow if you like.

EDIT: I forgot to mention that I run the script that generates the files containing the build number during the pre-build stage of my various VS projects.

陌上芳菲 2024-07-18 06:30:28

一些示例代码如承诺的那样。 这应该足以让您开始。

以下 JavaScript 可用于创建包含版本号的 InnoSetup iss 文件。 实际的文件将如下所示:

VersionInfoVersion=1.2.3.12345
AppVerName=My App v1.2.3.12345

主 Inno Setup 脚本将通过将以下内容添加到 [Setup] 部分的末尾来包含此文件:

[Setup]
AppId={{...}}
...

#include "version.iss"

这是 JavaScript(这将保存为单独的文件)文件 - 例如 version.js):

createInnoSetupIncludeFile("My App", 1, 2, 3, 12345, "version.iss");

function createInnoSetupIncludeFile(appName, verMajor, verMinor, verSubMinor, buildNumber, headerFileName)
{
    var versionString = verMajor + "." + verMinor + "." + verSubMinor + "." + buildNumber;
    var fileSystemObject = WScript.CreateObject("Scripting.FileSystemObject");
    var fileObject = fileSystemObject.CreateTextFile(headerFileName, true);
    fileObject.WriteLine("VersionInfoVersion=" + versionString);
    fileObject.WriteLine("AppVerName=" + appName + " v" + versionString);
    fileObject.Close();
    fileObject = null;
    fileSystemObject = null;
}

您可以调整此脚本以在不同的文件夹中创建 version.iss 文件。

最后,您需要执行 JavaScript - 最好的位置是在 Visual Studio 项目的预构建事件中。 添加以下内容:

cscript version.js //NoLogo

您需要更改此设置才能构建 Wix 兼容的包含文件。 我曾经这样做过,但放弃了 Wix,转而使用 Inno Setup,所以我手头没有这段代码。 不过,Wix 脚本有一种机制,因此应该为您指明正确的方向 - 概念是相同的 - 生成一个定义版本号的文本文件,然后将其包含在内。

希望这可以帮助。

Some sample code as promised. This should be enough to get you started.

The following JavaScript can be used to create an InnoSetup iss file containing the version number. The actual file will look like this:

VersionInfoVersion=1.2.3.12345
AppVerName=My App v1.2.3.12345

The main Inno Setup script will include this file by adding the following to the end of the [Setup] section:

[Setup]
AppId={{...}}
...

#include "version.iss"

Here is the JavaScript (this would be saved as a separate file - version.js for example):

createInnoSetupIncludeFile("My App", 1, 2, 3, 12345, "version.iss");

function createInnoSetupIncludeFile(appName, verMajor, verMinor, verSubMinor, buildNumber, headerFileName)
{
    var versionString = verMajor + "." + verMinor + "." + verSubMinor + "." + buildNumber;
    var fileSystemObject = WScript.CreateObject("Scripting.FileSystemObject");
    var fileObject = fileSystemObject.CreateTextFile(headerFileName, true);
    fileObject.WriteLine("VersionInfoVersion=" + versionString);
    fileObject.WriteLine("AppVerName=" + appName + " v" + versionString);
    fileObject.Close();
    fileObject = null;
    fileSystemObject = null;
}

You could tweak this script to create the version.iss file in a different folder.

Finally you need to execute the JavaScript - the best place would be in the Pre-Build Event of your Visual Studio project. Add the following:

cscript version.js //NoLogo

You would need to change this to also build a Wix compatible include file. I used to do this, but dumped Wix in favour of Inno Setup, so I don't have this code to hand. There is a mechamism for a Wix script though, so that should point you in the right direction - the concept is the same - generate a text file that defines the version number and then include it.

Hope this helps.

爱,才寂寞 2024-07-18 06:30:28

我在 inno 设置部分找到了这个,看起来它可以工作:

http://agiletracksoftware.com /blog.html?id=4

I found this for the inno setup section which looks like it would work:

http://agiletracksoftware.com/blog.html?id=4

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