安装MSBuild扩展

时间:2009-08-31 14:05:22

标签: msbuild installation wix

我为MSBuild创建了一个供开发人员使用的任务,并希望创建一个安装程序来将任务和相关的.targets文件安装到Program Files中的MSBuild extensions文件夹中(通常是C:/ Program Files / MSBuild在32位XP上。)

为了正确执行此操作,我想在安装时向系统询问该文件夹位置 - 是否有提供此信息或其他安装程序属性的注册表项?我打算使用WiX进行安装。

2 个答案:

答案 0 :(得分:2)

Wix本身有一个MSBuild任务,所以我认为最好看看他们是如何做到的,来源是Toolset.wxs(谷歌代码搜索)。

查看他们定义MSBuild文件夹的部分:

<DirectoryRef Id="ProgramFilesFolder">
    <Directory Id="Dir_MSBuild" Name="MSBuild">
        <Directory Id="Dir_MSBuildMS" Name="Microsoft">
            <Directory Id="Dir_MSBuildMSWix" Name="WiX">
                <Directory Id="Dir_MSBuildMSWix35" Name="v3.5">
                    <Component Id="WixMSBuildBinaries35" 
                              Guid="2CB1EA5F-2542-4AFF-A05B-FAF576265F89" 
                              Win64="no">
                        <File Source="WixTasks.dll" Checksum="yes" 
                              KeyPath="yes" Vital="yes" />
                    </Component>
                </Directory>
            </Directory>
        </Directory>
    </Directory>
</DirectoryRef>

这将在\ Program Files \ MSBuild \ Microsoft \ Wix

下安装Wix MsBuild任务(WixTasks.dll)

答案 1 :(得分:1)

我们正是这样做的(以及更多:)

创建一个类似于:

的wxi文件
<!-- Product name as you want it to appear in Add/Remove Programs-->
<?if $(var.Platform) = x64 ?>
  <!-- Product name as you want it to appear in Add/Remove Programs-->
  <?define ProductName = "Custom MSBuild Tasks (64 bit)" ?>
  <?define Win64 = "yes" ?>
  <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
  <?define ProductName = "Custom MSBuild Tasks" ?>
  <?define Win64 = "no" ?>
  <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>

<!-- Directory name used under MSBuild -->
<?define InstallName = "CustomTasks" ?>

然后当您需要定义组件时:

<Fragment Id="ComponentsFragment">
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="$(var.PlatformProgramFilesFolder)">
      <Directory Id="MSBuildFolder" Name="MSBuild">
        <Directory Id="INSTALLLOCATION" Name="$(var.InstallName)">
          ... Your custom .Targets and tasks go here