Python 2.7 如何在每次msi创建期间在wix中动态更改产品版本
我有一个脚本,其中我将产品的版本号输入变量“PRODUCTVERSION”,即Python 2.7 如何在每次msi创建期间在wix中动态更改产品版本,python-2.7,wix,wix3.7,Python 2.7,Wix,Wix3.7,我有一个脚本,其中我将产品的版本号输入变量“PRODUCTVERSION”,即 PRODUCTVERSION= subprocess.check_output('svnversion c:\sandbox -n', shell=False) 我想将此变量“PRODUCTVERSION”作为msbuild属性传递给wix。下面是我尝试过的代码,但最后出现了一个错误: light.exe : error LGHT0001: Illegal characters in path. 这是我的
PRODUCTVERSION= subprocess.check_output('svnversion c:\sandbox -n', shell=False)
我想将此变量“PRODUCTVERSION”作为msbuild属性传递给wix。下面是我尝试过的代码,但最后出现了一个错误:
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>
调试
x86
$(产品版本)
{d559ac98-4dc7-4078-b054-fe0da8363ad0}
2
myapp.$(产品版本)
包裹
$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\WiX.targets
$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\WiX.targets
版本=$(产品版本)
我想将我的输出名称显示为“myapp-2.0.PRODUCTVERSION”,其中PRODUCTVERSION是我从python脚本中获得的版本号。请帮助我找到解决方案。这表明PRODUCTVERSION Light需要x.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>
在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>
我希望我作为属性发送给wix的PRODUCTVERSION为%(myVersionNumber)。我将如何使用它?我想这可能是您想要的:
<Target Name="AfterBuild">
<Copy SourceFiles=".\bin\$(Configuration)\$(OutputName)-$(ProductVersion).msi" DestinationFiles=".\bin\$(Configuration)\$(OutputName)-$(ProductVersion).msi" />
<Delete Files=".\bin\$(Configuration)\$(OutputName).msi" />
</Target>