Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Path 使用WiX根据机器名设置安装路径_Path_Wix_Installation_Custom Action - Fatal编程技术网

Path 使用WiX根据机器名设置安装路径

Path 使用WiX根据机器名设置安装路径,path,wix,installation,custom-action,Path,Wix,Installation,Custom Action,我很惊讶我没能找到一个简单的答案,因为这似乎是一件平常的事 我正试图根据安装它的服务器的机器名设置安装路径,因为它们有不同的文件夹结构 我假设我需要一些定制的动作,但是对于WiX来说是全新的,我很难找到从哪里开始 我想我可以为每台服务器制作单独的安装程序(因为它只有3个),但最好只安装一个可重用的安装程序 如果您能指出正确的方向,我们将不胜感激!谢谢。假设您在WiX创作中有以下目录结构: <Directory Id="TARGETDIR" Name="SourceDir"> &l

我很惊讶我没能找到一个简单的答案,因为这似乎是一件平常的事

我正试图根据安装它的服务器的机器名设置安装路径,因为它们有不同的文件夹结构

我假设我需要一些定制的动作,但是对于WiX来说是全新的,我很难找到从哪里开始

我想我可以为每台服务器制作单独的安装程序(因为它只有3个),但最好只安装一个可重用的安装程序


如果您能指出正确的方向,我们将不胜感激!谢谢。

假设您在WiX创作中有以下目录结构:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLLOCATION" Name="nametochange">
    <!-- some component -->
    <Directory Id="BinDir" Name="bin">
       <!-- another component -->
    </Directory>
  </Directory>
</Directory>
SetDirectory
元素正确地调度底层自定义操作。注意WiX中引用环境变量的方式:
[%COMPUTERNAME]
。如果以Windows Installer 4.0+为目标,则可以使用特殊属性
ComputerName

更新:根据具体要求,您可以进一步试验:

<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderA">ComputerName = Server1</SetDirectory>
<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderB">ComputerName = Server2</SetDirectory>
<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderC">ComputerName = Server3</SetDirectory>
ComputerName=Server1
ComputerName=Server2
ComputerName=Server3

等等。

你能举个例子吗?是否只有根安装目录依赖于机器名?或者是每个服务器的整个文件夹结构都不同?根据您对此问题的回答,解决方案的复杂性可能会有所不同……哎呀,重写此评论,因为我正在考虑备份过程。对于安装,在“中间”有一个文件夹具有不同的名称。所以C:\Inetpub\wwwroot\AQSDir\bin和另外两个是C:\Inetpub\wwwroot\AQSGrabDir\bin,或者类似的东西。@因此在您的示例中,安装它的计算机的名称是
AQS
?不,这不是服务器名称。也许是一个更好的例子:C:\Inetpub\wwwroot\MyFolder\bin与C:\Inetpub\wwwroot\MyFold\bin我已经编写安装程序16年了,我从来没有必要做这样的事情。这毫无意义。虽然这似乎比托管代码自定义操作类型解决方案简单得多,但这似乎取决于文件夹名称与计算机名称是否相同,而事实并非如此。例如,对于名为“Server1”的服务器,它将进入“FolderA”,而“Server2”将进入“FolderB”。我已经用更多的示例数据更新了我的答案。如果你有了这个想法,试着去获得你想要的行为。谢谢你,燕。非常感谢!
<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderA">ComputerName = Server1</SetDirectory>
<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderB">ComputerName = Server2</SetDirectory>
<SetDirectory Id="INSTALLLOCATION" Value="C:\inetpub\wwwroot\FolderC">ComputerName = Server3</SetDirectory>