我想将我的应用程序安装到以下目录结构中:
MyCompany/
MyApp/
assembly1.dll
assembly2.dll
assembly3.dll
...
plugins/
plugin1.dll
plugin2.dll
为此,我定义了以下文件夹:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CompanyFolder" Name="MyCompanyName">
<Directory Id="INSTALLFOLDER" Name="MyProduct">
<Directory Id="PLUGINS" Name="plugins">
<Directory Id="DATABASE_PLUGINS" Name="db" />
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
现在我已经定义了1个功能,并引用了一个组件组。此组件组具有指向“INSTALLFOLDER”的属性“Directory”。但是当我现在在组件组中声明一个也有“Directory”属性(指向DATABASE_PLUGINS)的组件时,VS将不允许我构建设置。
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="DB.Connector.Extension.Plugins.SqlCe" Directory="DATABASE_PLUGINS" Guid="{ae87be28-b0c9-4b3e-915f-2b4bf9965c99}">
<File Source="$(var.DB.Connector.Extension.Plugins.SqlCe.TargetDir)DB.Connector.Extension.Plugins.SqlCe.dll" KeyPath="yes" />
</Component>
</ComponentGroup>
如何实现设置在主安装目录中创建子目录并将声明的文件放入其中?
答案 0 :(得分:4)
这是我的完整示例,我希望这有助于进一步的开发人员
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="GiladDir" Name="Gilad">
<Directory Id="INSTALLFOLDER" Name="App">
<Directory Id="BIN" Name="bin"></Directory>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="App">
<Component Id="ProgramMenuDir" Guid="*">
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="group_tools">
<ComponentRef Id="comp_tool_dll" />
</ComponentGroup>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="bin" Name="bin">
<Directory Id="Release" Name="Release">
<Directory Id="Plugins" Name="Plugins">
<Component Id="comp_tool_dll" DiskId="1" KeyPath="yes" Guid="*">
<File Id="file_comp_tool_dll" Source="$(var.ReleaseSourcePath)\Plugins\tool.dll" />
</Component>