【问题标题】:Example WiX configuration to deploy a simple ASP.NET website部署简单 ASP.NET 网站的示例 WiX 配置
【发布时间】:2013-03-10 02:00:31
【问题描述】:

刚开始使用 WiX(3.8 版),我们很惊讶使用 WiX 部署网站似乎并不简单。还不关心任何基础设施方面,如 IIS 或自定义操作来定制设置,甚至我们是否预编译站点,只是很乐意将一个琐碎的网站部署到文件夹中。但唯一被部署的文件是单个 dll(其名称似乎来自于在 csproj 中配置的 AssemblyName 属性)。

经过一番谷歌搜索,我们尝试在项目参考上设置 Harvest=True,并将<EnableProjectHarvesting>True</EnableProjectHarvesting> 添加到 wixproj 文件中。但只有同一个 dll 会被部署。 (Orca 显示它是 MSI 文件表中的唯一文件。)

将以下内容添加到 wixproj 成功让 Heat、Candle 和 Light 处理硬编码文件夹中的一组文件,但没有成功部署其他任何内容:MSI 文件中仍然只包含一个 dll表。

<Target Name="BeforeBuild">
    <!-- try hardcoded path -->
 <HeatDirectory 
  ToolPath="$(WixToolPath)" 
  OutputFile="%(ProjectReference.Filename).wxs" 
  Directory="C:\Dev\2010\HelloWixWebApplication\HelloWixWebApplication" 
  GenerateGuidsNow="true"
  DirectoryRefId="TARGETDIR"
  />
 <!-- some properties that Candle will use, so we should be able to to tell it to look in this folder for the .wks -->
 <PropertyGroup>
  <!--IncludeSearchPaths>.</IncludeSearchPaths -->
  <CompilerAdditionalOptions>%(ProjectReference.Filename).wxs</CompilerAdditionalOptions>
  <!--and one for Light: -->
  <LinkerAdditionalOptions>obj\Debug\%(ProjectReference.Filename).wixobj</LinkerAdditionalOptions>
 </PropertyGroup>
</Target>

回到主要问题,真正有用但我们似乎找不到的东西:使用 WiX 部署简单 asp.net 网站的实际示例。任何人? TIA。


在回答 Rob Mensching 的问题时,从该配置生成的附加 .wxs 文件如下所示。 (忽略拼写错误的 HellowWix .. 我在别处更正了。)
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Directory Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997" Name="HellowWixWebApplication" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir6DED4C9E136E741825339CEA6DE213D8">
            <Component Id="cmp04A9076B920B178A9BB40ABB0D0C5785" Guid="{C6AA8596-0107-4360-85B1-503CC6F319FA}">
                <File Id="fil021D16CABEED58F6659FD4103DD68AC4" KeyPath="yes" Source="SourceDir\bin\HellowWixWebApplication.dll" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmp19A9163AE8A7925CB6C4247D145B22B6" Guid="{D7B85294-12DF-4784-B6DA-BF7AEBA475C9}">
                <File Id="fil24F0BD7A232604DB4D8E369EFDB7AB28" KeyPath="yes" Source="SourceDir\Web.Release.config" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmp22213FE3CD8C99A9A7563D7AFD66052E" Guid="{99E59BF6-640B-4E35-B4D8-671927AF9BD3}">
                <File Id="fil4AA1682891BEFAA2AB3CB1ABCBE9C155" KeyPath="yes" Source="SourceDir\HellowWixWebApplication.csproj" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmp277C2DBCB4DB3C289C46A9784423A2C1" Guid="{7DF707B0-55BF-4899-805C-97A1A2081528}">
                <File Id="filE62AD3DD98C8055C24348922079D0E2E" KeyPath="yes" Source="SourceDir\Default.aspx.designer.cs" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmp2E90B366B07FD51B623E7CF089E2932D" Guid="{17914BB7-5A02-499B-AC0C-F1F9FCB6019F}">
                <File Id="filC05278F3F8EB3611EB1EBB30F6EA4AFB" KeyPath="yes" Source="SourceDir\Web.config" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmp3025675392247E7856146E4D28076668" Guid="{2905F7E7-536B-44E5-8C10-45A954CE9E86}">
                <File Id="fil8EB5092298D94AE4C4677473CAAFC0E0" KeyPath="yes" Source="SourceDir\Web.Debug.config" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir6E0901CF23FF0CE2677DE6B8BBA3B8BD">
            <Component Id="cmp7C99050A7370BF342937DF8E86BA1863" Guid="{5DF80AF2-1459-43CD-A649-90AB1F2C57AE}">
                <File Id="filB73CA61225E396C5CD26B29E8FAA7AFE" KeyPath="yes" Source="SourceDir\obj\Debug\HellowWixWebApplication.pdb" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir4F5CB8DBC18741F08CCFF2B59DDE3481">
            <Component Id="cmp976F1DA49CEA0FDDB2D0EA8C756C7DCF" Guid="{1069A669-F349-427F-B01A-64E942AFED2F}">
                <File Id="fil21676E8D65B4C460832839007C43343E" KeyPath="yes" Source="SourceDir\Properties\AssemblyInfo.cs" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmpA0C26A291B35A1F7C8F75C76C408C355" Guid="{51AE16C4-A743-4EFA-8678-064A6550F228}">
                <File Id="fil9A7337716828B5F0F975E4B424B18285" KeyPath="yes" Source="SourceDir\Default.aspx.cs" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir6E0901CF23FF0CE2677DE6B8BBA3B8BD">
            <Component Id="cmpAA37E12AC25051F1FB98359B5654CBB6" Guid="{4D81902A-9F6C-47D8-95AF-ED1D7062771C}">
                <File Id="fil053D1EA59D1DC9708FA9DF93DCE32BF2" KeyPath="yes" Source="SourceDir\obj\Debug\HellowWixWebApplication.dll" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir6E0901CF23FF0CE2677DE6B8BBA3B8BD">
            <Component Id="cmpAB40655D2EEBFE8E7DA2D5C008705F7A" Guid="{01C5537C-257D-4472-BB27-778DDB5E2CEA}">
                <File Id="fil1B67F0463CE8AA35030E31A3E3BFA82D" KeyPath="yes" Source="SourceDir\obj\Debug\HellowWixWebApplication.csproj.FileListAbsolute.txt" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir6E0901CF23FF0CE2677DE6B8BBA3B8BD">
            <Component Id="cmpD72354FE851F86AF61BFD2B884E05B34" Guid="{230F8CC1-9DF3-4B44-B6C8-617090329C82}">
                <File Id="filBF0022433A84B60F69F4ECF6724E4BA3" KeyPath="yes" Source="SourceDir\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmpEA2E4AE70EBEAF6FCFC294661CE9EF29" Guid="{ADE9B8A8-F4CC-4CE7-845F-5C526A9E6149}">
                <File Id="fil76F4E5B6801E021CFE962F5C33DEA62F" KeyPath="yes" Source="SourceDir\Default.aspx" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Component Id="cmpEC68C3F57C9E201E67744CC0DA54E083" Guid="{42F553F5-90B1-4190-A6BC-1DD41928F151}">
                <File Id="fil4B42859DA454D34945962FBFB3BFB0C1" KeyPath="yes" Source="SourceDir\HellowWixWebApplication.csproj.user" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Directory Id="dir4F5CB8DBC18741F08CCFF2B59DDE3481" Name="Properties" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Directory Id="dir6DED4C9E136E741825339CEA6DE213D8" Name="bin" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirAD6B115F080FDBD956168CB7C622647C">
            <Directory Id="dir6E0901CF23FF0CE2677DE6B8BBA3B8BD" Name="Debug" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dirE7F2BE36CFADC3ED9ACCB1F42198C997">
            <Directory Id="dirAD6B115F080FDBD956168CB7C622647C" Name="obj" />
        </DirectoryRef>
    </Fragment>
</Wix>

【问题讨论】:

  • 您的 .wxs 文件是什么样的?
  • 现在添加到上面。谢谢。

标签: asp.net wix


【解决方案1】:

要包含生成的文件,它们需要包含在组件中,然后包含在功能中。

最简单的方法是修改 HeatDirectory 元素,将其更改为:

<HeatDirectory 
    ToolPath="$(WixToolPath)" 
    OutputFile="%(ProjectReference.Filename).wxs" 
    Directory="C:\Dev\2010\HelloWixWebApplication\HelloWixWebApplication" 
    GenerateGuidsNow="true"
    DirectoryRefId="TARGETDIR"
    ComponentGroupName="ContentFiles"
    SuppressFragments="true" />

添加ComponentGroupNameSupressFragments 参数。然后使用 &lt;ComponentGroupRef Id="ContentFiles" /&gt; 元素将该组件包含在您的功能中。

我通常还会添加SuppressUniqueIds 属性,这样阅读起来会更好一些。

我个人更喜欢将生成的 wxs 直接包含在我的项目中,并在包含新文件时进行更新。这样,这正是我想要的。另一种选择是使用 xslt 转换去除不需要的东西,如 csproj 等,并在 Transform 属性中提供。

【讨论】:

  • 是的,@caveman_dick 说的除了我会留下SuppressFragments(但我喜欢让门敞开着打补丁)。
  • 谢谢,这说明了一些问题,但现在每个文件都有一个构建错误,The system cannot find the file 'SourceDir\Default.aspx'. 显然它正在我的硬编码目录中找到文件,因为文件名显示在这些构建错误中。为什么它说在“SourceDir”中找不到相同的文件?
  • 您需要做的是设置PreprocessorVariable=var.ContentFiles,这将使您能够在wixproj项目的&lt;DefineConstants&gt;ContentFiles=$(ContentFiles)&lt;/DefineConstants&gt;属性中设置ContentFiles。然后可以通过 msbuild 参数设置 $(ContentFiles) 属性。如果不需要切换源目录,直接在&lt;DefineConstants&gt;标签中指定路径即可。
  • 如果在 3.6 中构建的项目能够继续在 3.8 中构建而无需更改任何内容,那就太好了。将内容放在实际的 csproj 文件中,而不是仅添加 Product.Generated 条目是一件非常痛苦的事情。在 VS2013 中恢复收获!
【解决方案2】:

现在有一个 Visual Studio 扩展VDProj to WiX Converter,可以从工具菜单、扩展和更新中下载。那里还有另一个与 WIX 相关的扩展,它是用于创建和操作 Wix 设置项目的设计器:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多