在PostBuildEvent之前运行Bootstrapper

时间:2015-04-03 04:51:59

标签: msbuild wix

我有一个WiX安装程序项目,如果需要,可以使用Bootstrapper任务安装.net。但它似乎在PostBuildEvent之后运行,我需要它在它之前运行。

有人可以解释一下。

相关代码是:

  <ItemGroup>
    <BootstrapperFile Include=".NETFramework,Version=v4.0,Profile=Client">
      <ProductName>.NET Framework 4.0 Client</ProductName>
    </BootstrapperFile>
    <BootstrapperFile Include="Microsoft.Windows.Installer.4.5">
      <ProductName>Windows Installer 4.5</ProductName>
    </BootstrapperFile>
  </ItemGroup>
  <Target Name="Bootstrapper" Inputs="$(OutDir)$(TargetFileName)" Outputs="$(OutDir)\Setup.exe" Condition=" '$(OutputType)'=='package' ">
    <GenerateBootstrapper Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper" ApplicationName="EcoButton" ApplicationFile="$(TargetFileName)" BootstrapperItems="@(BootstrapperFile)" ComponentsLocation="HomeSite" OutputPath="$(OutputPath)" />
  </Target>
  <PropertyGroup>
    <BuildDependsOn>$(BuildDependsOn);Bootstrapper</BuildDependsOn>
  </PropertyGroup>
  <PropertyGroup>
    <PostBuildEvent>cscript "$(ProjectDir)..\EditMsi.vbs" "$(Configuration)" "$(TargetPath)"
cscript "$(ProjectDir)..\BuildSetup.vbs" "1" "$(Configuration)" "$(TargetPath)"
cscript "$(ProjectDir)..\BuildSetup.vbs" "2" "$(Configuration)" "$(TargetPath)"</PostBuildEvent>
  </PropertyGroup>

1 个答案:

答案 0 :(得分:0)

这就是诀窍。

  <Target Name="AfterBuild">
    <CallTarget Targets="AfterBuild1" />
    <CallTarget Targets="AfterBuild2" />
    <CallTarget Targets="AfterBuild3" />
    <CallTarget Targets="AfterBuild4" />
  </Target>
  <Target Name="AfterBuild1" Inputs="$(OutDir)$(TargetFileName)" Outputs="$(OutDir)\Setup.exe" Condition=" '$(OutputType)'=='package' ">
    <GenerateBootstrapper Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper" ApplicationName="EcoButton" ApplicationFile="$(TargetFileName)" BootstrapperItems="@(BootstrapperFile)" ComponentsLocation="HomeSite" OutputPath="$(OutputPath)" />
  </Target>
  <Target Name="AfterBuild2">
    <Exec Command="cscript &quot;$(ProjectDir)..\EditMsi.vbs&quot; &quot;$(Configuration)&quot; &quot;$(TargetPath)&quot;" />
  </Target>
  <Target Name="AfterBuild3">
    <Exec Command="cscript &quot;$(ProjectDir)..\BuildSetup.vbs&quot; &quot;1&quot; &quot;$(Configuration)&quot; &quot;$(TargetPath)&quot;" />
  </Target>
  <Target Name="AfterBuild4">
    <Exec Command="cscript &quot;$(ProjectDir)..\BuildSetup.vbs&quot; &quot;2&quot; &quot;$(Configuration)&quot; &quot;$(TargetPath)&quot;" />
  </Target>