如何使用MSBuild对Installshield的支持来验证产品代码和产品版本是否已更新

时间:2014-03-25 04:41:59

标签: msbuild build-automation installshield tfs2013

我正在尝试使用MSBuild和TFS 2013构建InstallShield项目。我按照指示here覆盖产品代码所需的步骤。首先,我创建了一个.isproj文件,并设法成功生成安装程序。但是,产品代码似乎没有改变。我检查文件setup.ini并注意到Product GUID仍然与.ism文件中的Product Code值相同。 有没有办法验证产品代码和产品版本是否已更改?

@Update

最终,我能够使用Orca验证新生成的产品代码。

克里斯的剧本也很完美!

1 个答案:

答案 0 :(得分:1)

我就是这样做的:

在我的ISM版本视图(构建选项卡)中,我将发布位置设置为\ Installer而不是在我的路径变量中我声明了一个ISBUILDDIR路径变量并给它一个默认值ISProjectDataFolder

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Build">
    <PropertyGroup>
    <MSIProductVersion>$([System.Text.RegularExpressions.Regex]::Match($(TF_BUILD_BUILDNUMBER), "\d+.\d+.\d+.\d+"))</MSIProductVersion>
        <Configuration>Debug</Configuration>
        <InstallShieldProductConfiguration>ProductConfigName</InstallShieldProductConfiguration>
        <InstallShieldRelease>ReleaseName</InstallShieldRelease>
        <InstallShieldProductVersion>$(MSIProductVersion)</InstallShieldProductVersion>
    <MSIProductCode>$([System.Guid]::NewGuid().ToString("B").ToUpper())</MSIProductCode>
    <InstallShieldBuildDependsOn>PreBuild</InstallShieldBuildDependsOn>
    </PropertyGroup>
    <ItemGroup>
        <InstallShieldPathVariableOverrides Include="$(OutDir)">
            <PathVariable>ISBUILDDIR</PathVariable>
        </InstallShieldPathVariableOverrides>
    </ItemGroup>
  <ItemGroup>
    <InstallShieldPropertyOverrides Include="$(MSIProductCode)">
      <Property>ProductCode</Property>
    </InstallShieldPropertyOverrides>
  </ItemGroup>
    <ItemGroup>
        <InstallShieldProject Include="$(MSBuildProjectDirectory)\$(MSBuildProjectName).ism"/>
        <InstallShieldMergeModulePath Include="$(MSBuildProjectDirectory)\MSM"/>
    </ItemGroup>
  <Target Name="PreBuild">
    <Exec Command="attrib -s -h -r  /s &quot;$(MSBuildProjectDirectory)\*.*&quot;" IgnoreExitCode="true" ContinueOnError="true"/>
  </Target>
    <Import Project="$(MSBuildExtensionsPath32)\InstallShield\2012\InstallShield.targets"/>
</Project>