2010-06-11 17 views
1

J'ai une solution avec 2 projets:Comment puis-je transmettre la version d'assembly d'un projet Visual Studio à un autre projet pour l'utiliser dans un événement post-build?

  • Mon application 1.2.54 (C# WinForms)
  • Mon programme d'installation d'application 1.0.0.0 (Configuration WiX)

Je voudrais J'aime ajouter un événement de post-construction au projet d'installation de WiX pour exécuter un fichier de commandes et lui passer un paramètre de ligne de commande du numéro de version de l'assemblage de ma demande. Le code peut ressembler à ceci:

CALL MyBatchFile.bat "$(fileVersion.ProductVersion($(var.My Application.TargetPath)))" 

Mais cela se traduit par l'erreur suivante:

Unhandled Exception:The expression """.My Application" cannot be evaluated. Method 'System.String.My Application' not found. C:\My Application\My Application Setup\My Application Setup.wixproj

Error: The expression """.My Application" cannot be evaluated. Method 'System.String.My Application' not found. C:\My Application\My Application Setup\My Application Setup.wixproj

Je voudrais pouvoir passer « 01/02/54 » à MyBatchFile.bat en quelque sorte.

Répondre

2

Dans votre fichier de projet Wix (*.wixproj) passer outre la cible AfterBuild appeler votre fichier batch:

<Target Name="AfterBuild"> 
    <!-- Get "My Application" assembly version --> 
    <GetAssemblyIdentity AssemblyFiles="../my_assembly_dir/MyAssembly.dll"> 
    <Output TaskParameter="Assemblies" ItemName="AssemblyIdentity"/> 
    </GetAssemblyIdentity> 

    <Exec Command="MyBatchFile.bat %(AssemblyIdentity.Version)"/> 
</Target> 
+0

Cela a fonctionné! Merci! – Coder7862396