2013-03-22 53 views
0

我有一個腳本,讓我的產品給一個變量「的ProductVersion」的IE版本號期間在威克斯動態改變產品版本,如何每個MSI創建

PRODUCTVERSION= subprocess.check_output('svnversion c:\sandbox -n', shell=False) 

我想通過這個變量「 PRODUCTVERSION'作爲wix的msbuild屬性。下面是我試過,但有一個錯誤結束了他說的代碼,

light.exe : error LGHT0001: Illegal characters in path.  

這裏是我的腳本,

def build(self,projpath): 
    PRODUCTVERSION= subprocess.check_output('svnversion c:\sandbox -n', shell=False) 
    arg1 = '/t:Rebuild' 
    arg2 = '/p:Configuration=Release' 
    arg3 = '/p:Platform=x86' 
    arg4 = '/p:ProductVersion=%PRODUCTVERSION%' 
    p = subprocess.call([self.msbuild,projpath,arg1,arg2,arg3]) 

凡在我的WiX的項目性質是,

<PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform> 
    <ProductVersion>$(ProductVersion)</ProductVersion> 
    <ProjectGuid>{d559ac98-4dc7-4078-b054-fe0da8363ad0}</ProjectGuid> 
    <SchemaVersion>2.0</SchemaVersion> 
    <OutputName>myapp.$(ProductVersion)</OutputName> 
    <OutputType>Package</OutputType> 
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> 
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> 
    <WixVariables>Version=$(ProductVersion)</WixVariables> 
</PropertyGroup> 

我想將我的輸出名稱顯示爲'myapp-2.0.PRODUCTVERSION',其中PRODUCTVERSION是我從我的python腳本獲得的版本號。請幫我找到一個解決方案。

回答

2

documentation表明對於ProductVersion Light期望的格式爲x.x.x.

如果你希望得到您的MSI與版本命名的,我一直使用的生成後命令重命名文件,從而...

<Target Name="AfterBuild"> 
    <Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).msi" DestinationFiles=".\bin\$(Configuration)\$(OutputName)_v%(myVersionNumer).msi" /> 
    <Delete Files=".\bin\$(Configuration)\$(OutputName).msi" /> 
    </Target> 
+0

我想PRODUCTVERSION,我發送作爲屬性wix在%(myVersionNumber)。我將如何使用該? – Aramanethota 2013-03-25 03:58:11

+1

我認爲這可能是你之後:http://stackoverflow.com/questions/13233143/anyway-to-create-a-custom-msbuild-property-in-wix-wxs-file – mattyB 2013-03-25 09:08:38

0
def build(self,projpath): 
    PRODUCTVERSION = subprocess.check_output('svnversion c:\my path\to svn\ -n', shell=False) 
    arg1 = '/t:Rebuild' 
    arg2 = '/p:Configuration=Release' 
    arg3 = '/p:Platform=x86' 
    arg4 = '/p:ProductVersion=%s' %(PRODUCTVERSION) 
    proc = subprocess.Popen(([self.msbuild,projpath,arg1,arg2,arg3,arg4]), shell=True, 
        stdout=subprocess.PIPE) 
    while True: 
     line = proc.stdout.readline()       
     wx.Yield() 
     if not line: break 
    proc.wait() 

,並在wixproject通上述參數作爲一個MSBuild屬性和後構建,

<Target Name="AfterBuild"> 
<Copy SourceFiles=".\bin\$(Configuration)\$(OutputName)-$(ProductVersion).msi" DestinationFiles=".\bin\$(Configuration)\$(OutputName)-$(ProductVersion).msi" /> 
<Delete Files=".\bin\$(Configuration)\$(OutputName).msi" /> 
</Target>