Hi,
Here is a way how you can achieve this using MSBuild (assuming you are doing
.NET development). It's pretty easy (maybe something that Gábor may want to
include in his tutorial - this way or a more generic one, or something that
someone would like to write a task for that can be included in the WixTasks
assembly)
1. Get the AssemblyIdentity
<GetAssemblyIdentity AssemblyFiles="$(CoreDll)">
<Output TaskParameter="Assemblies" PropertyName="AssemblyName"/>
</GetAssemblyIdentity>
2. Get the version number and make it a string
<GetBuildNumber AssemblyName="$(AssemblyName)" Full="True">
<Output TaskParameter="Build" PropertyName="Build"/>
</GetBuildNumber>
The source code for this task:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.Reflection;
using System.IO;
namespace VIA.Build
{
public class GetBuildNumber : Task
{
private bool _full = false;
public bool Full
{
get { return _full; }
set { _full = value; }
}
private string _assemblyName;
[Required()]
public string AssemblyName
{
get { return _assemblyName; }
set { _assemblyName = value; }
}
private string _build;
[Output()]
public string Build
{
get { return _build; }
}
public override bool Execute()
{
AssemblyName name = new AssemblyName(AssemblyName);
if (Full)
{
_build = name.Version.ToString();
}
else
{
_build = string.Format("{0}-{1}",
name.Version.Build.ToString(), name.Version.Revision.ToString());
}
return true;
}
}
}
3. Write out our .wxi file:
<WriteLinesToFile File="$(TempDirectory)\version.wxs"
Lines="<Include>" Overwrite="true"/>
<WriteLinesToFile File="$(TempDirectory)\version.wxs" Lines="<?define
Version = $(Build) ?>"/>
<WriteLinesToFile File="$(TempDirectory)\version.wxs"
Lines="</Include>"/>
And then refer to this constant in your wix files.
Hope it helps!
Frederik.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:wix-users-
> [EMAIL PROTECTED] On Behalf Of Albert van Peppen
> Sent: maandag 26 juni 2006 15:24
> To: [email protected]
> Subject: Re: [WiX-users] [WiX-devs] [ wix-Feature Requests-1509926 ]
> Fillproperty withfileversion
>
>
> Ok, but then I still cannot point to my main exefile for the version?
> So what I should do in my nightly build is generate a file with the
> version and buildnumer in it (like MyVersion.wxi) in which the version
> and buildnumbers are defined.
> This file I can then add tou my wxs file and done..
>
> IMHO it would be easier to let candle read the version from the
> generated EXE file :)
> (Maybe it is possible, but I didn't found it)
>
> Albert
>
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens SourceForge.net
> Verzonden: zondag 25 juni 2006 0:57
> Aan: [EMAIL PROTECTED]
> Onderwerp: [WiX-devs] [ wix-Feature Requests-1509926 ] Fill property
> withfileversion
>
> Feature Requests item #1509926, was opened at 2006-06-21 05:42 Message
> generated for change (Settings changed) made by derekc You can respond
> by visiting:
> https://sourceforge.net/tracker/?func=detail&atid=642717&aid=1509926&gro
> up_id=105970
>
> Please note that this message will contain a full copy of the comment
> thread, including the initial issue submission, for this request, not
> just the latest update.
> Category: compiler
> Group: Denied
> >Status: Closed
> Priority: 5
> Submitted By: The Mad Butcher (mad_burcher) Assigned to: Derek (derekc)
> Summary: Fill property with fileversion
>
> Initial Comment:
> Make it possible to implement a way to assign the fileversion of a file
> (embedded in the MSI) to a property.
>
> This property might be used in the rest of the wix- code (eg. my goal is
> that the Product/@Version can be filled based on my main application in
> the msi file)
>
> But it should also be possible to check for upgrades based on this
> property.
>
> Greetings,
>
>
> Albert van Peppen
>
>
> ----------------------------------------------------------------------
>
> Comment By: Derek (derekc)
> Date: 2006-06-24 15:56
>
> Message:
> Logged In: YES
> user_id=518766
>
> You can already do something like this by using the wix preprocessor.
> We had a discussion about a feature like this a while ago and the
> consensus was that its cleanest to just pass in any versioning
> information as a preprocessor variable which is then used in the
> appropriate places in the authoring. For example, the upgrade
> information cannot be populated with a property because it doesn't
> support formatted columns - so this can only be done with the
> preprocessor.
>
> ----------------------------------------------------------------------
>
> You can respond by visiting:
> https://sourceforge.net/tracker/?func=detail&atid=642717&aid=1509926&gro
> up_id=105970
>
> Using Tomcat but need to do more? Need to support web services,
> security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> WiX-devs mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-devs
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> WiX-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-users
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users