2013-03-20 37 views
1

剛開始使用WiX(版本爲3.8),我們感到驚訝的是,使用WiX部署網站似乎並不簡單。還不擔心任何基礎設施方面的問題,如IIS或自定義操作來調整設置,甚至不關心我們是否預先編譯網站,只是很樂意將一個簡單的網站部署到一個文件夾。但是唯一被部署的文件是單個dll(其名稱看起來是從csproj中配置的AssemblyName屬性派生的)。示例部署簡單ASP.NET網站的WiX配置

經過一些Google搜索之後,我們嘗試在項目參考中設置Harvest = True,並將<EnableProjectHarvesting>True</EnableProjectHarvesting>添加到wixproj文件中。但只有同一個dll纔會被部署。 (Orca顯示它是MSI文件表中唯一的文件)

將以下內容添加到wixproj中可以成功獲取Heat,Candle和Light來處理來自硬編碼文件夾的一組文件,但不會成功部署其他任何東西:仍然只有一個DLL包含在MSI文件表中。

<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> 
+0

什麼是您的.wxs文件是什麼樣子? – 2013-03-20 19:35:43

+0

現在添加上面。謝謝。 – 2013-03-21 09:35:29

回答

1

要包括他們需要,然後將其包含在一個特徵的部件內生成的文件。

爲你做到這一點最簡單的方法是修改HeatDirectory元素將其更改爲:

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

加入ComponentGroupNameSupressFragments參數。然後通過使用<ComponentGroupRef Id="ContentFiles" />元素將該組件包含在您的功能中。

我通常還會添加SuppressUniqueIds屬性,所以閱讀起來會更好一些。

個人而言,我更喜歡將生成的wxs直接包含在我的項目中,並在包含新文件時進行更新。這種方式正是我想要的。另一種選擇是使用xslt變換去除你不需要的東西,如csproj等,並在Transform屬性中提供。

+0

是的,@caveman_dick說了什麼,除了我會離開'SuppressFragments'(但我喜歡打開補丁的門)。 – 2013-03-21 14:07:09

+0

謝謝,這表明了一些亮點,但是現在每個文件都有一個構建錯誤,「系統找不到文件'SourceDir \ Default.aspx'。」顯然它是在我的硬編碼目錄中找到文件,因爲文件名顯示在這些構建錯誤。爲什麼然後它說在「SourceDir」中找不到相同的文件? – 2013-03-24 11:49:50

+0

你需要做的就是設置'PreprocessorVariable = var.ContentFiles',這將使你能夠在wixproj項目的' ContentFiles = $(ContentFiles)'屬性中設置'ContentFiles'。然後可以通過msbuild參數設置'$(ContentFiles)'屬性。如果您不需要切換源目錄,那麼您可以直接在''標記中指定路徑。 – 2013-03-25 09:48:06

0

現在有一個Visual Studio擴展VDProj到WiX轉換器它可以從工具菜單,擴展和更新下載。也有另一種維克斯相關的擴展存在,這是用於創建和操作維克斯安裝項目設計師:

enter image description here