即使选择了不同的目录,Windows Installer 也会安装到 Defaultlocation

发布于 2024-10-10 16:36:07 字数 397 浏览 3 评论 0原文

我希望这个问题还没有得到解答,但我觉得我已经阅读了整个互联网上的所有相关文章...

我需要将安装程序的 DefaultLocation 属性默认为 C:\ 或 D:\ (理想情况下会有这里是逻辑,但我已经知道这是不可能的,因为自定义操作是在安装文件后执行的)。

我看到的问题是,如果我使用 [TARGETDIR] 或 [ROOTDRIVE] 的属性(通常默认为 C:\ 或 D:\),那么如果用户选择不同的安装位置,安装程序将忽略他们选择的位置。

例如,在我的机器上 [ROOTDRIVE] 解析为 C:。如果我告诉安装程序到 D:\,它无论如何都会安装到 C:\。 [TARGETDIR] 和 [ROOTDRIVE] 属性都会发生这种情况。

有谁见过这个或知道为什么会发生这种情况?

谢谢, 史蒂夫

I hope this hasn't already been answered, but I feel like I have read every related article on the entire internet...

I need to have the DefaultLocation property of the Installer default to C:\ or D:\ (ideally there would be logic here but I have already learned that can't be done because Custom Actions are executed after the files are installed).

The issues I am seeing is that if I use the property for [TARGETDIR] or [ROOTDRIVE] which generally defaults to C:\ or D:\, that if a user selects a different install location, the installer ignores the location they selected.

For example on my machine [ROOTDRIVE] resolves to C:. If I tell the installer to D:\, it installs to C:\ anyway. This happens with both the [TARGETDIR] and the [ROOTDRIVE] property.

Has anyone seen this or know why this is happening?

Thanks,
Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴我老 2024-10-17 16:36:07

您不想设置 TARGETDIR,因为它默认为具有最大可用空间的驱动器,通常您会使用 INSTALLDIRAPPLICATIONFOLDER 之类的内容 并让用户自定义该属性。下面的 WiX 示例默认为 C:\Program Files\ACME Xyz\My Program,但如果用户将 APPLICATIONFOLDER 的位置更改为 D:\blahblahblah< /code> 然后文件将被安装在那里。

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="MyCo" Name="ACME Xyz">
            <Directory Id="APPLICATIONFOLDER" Name="My Program" DiskId="1">
            </Directory>
        </Directory>
    </Directory>
</Directory>

编辑:: 在这种情况下,只需使用立即自定义操作即可。例如

<CustomAction Id="SetInstallFolder" Property="APPLICATIONFOLDER" Value="D:\"  Execute="immediate" />

<InstallExecuteSequence>
    <Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallExecuteSequence>
<InstallUISequence>
    <Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallUISequence>

You don't want to be setting TARGETDIR as this defaults to the drive with the largest amount of free space, generally you'd use something like INSTALLDIR or APPLICATIONFOLDER and have the user customize that property instead. The WiX sample below defaults to C:\Program Files\ACME Xyz\My Program but if the user changes the location of APPLICATIONFOLDER to say D:\blahblahblah then the files will be installed there.

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="MyCo" Name="ACME Xyz">
            <Directory Id="APPLICATIONFOLDER" Name="My Program" DiskId="1">
            </Directory>
        </Directory>
    </Directory>
</Directory>

EDIT:: In that case, just use an immediate custom action. e.g.

<CustomAction Id="SetInstallFolder" Property="APPLICATIONFOLDER" Value="D:\"  Execute="immediate" />

<InstallExecuteSequence>
    <Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallExecuteSequence>
<InstallUISequence>
    <Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallUISequence>
才能让你更想念 2024-10-17 16:36:07

我刚刚弄清楚为什么 Visual Studio 安装程序会发生这种情况,更重要的是如何纠正它。

有一个名为“PackageAs”的属性,可以在 Visual Studio 中对安装文件中使用的每个文件进行访问。默认情况下,此属性设置为“vsdpaDefault”,根据我发现的一点信息,该属性会导致文件被压缩,从而更改文件以及随后的 LastModifiedDate。

可以通过将要维护 LastModifiedDate 的文件更改为 PackageAs“vsdpaLoose”来解决此问题。这会导致文件不被压缩并保持其属性。

希望其他人也会遇到同样的问题并发现这很有用。

I just figured out WHY this was happening with the Visual Studio installer and more importantly how to rectify it.

There is a property called "PackageAs", which can be accessed within Visual Studio on each file that is used in the setup file. By default this property is set to "vsdpaDefault" which based on the little bit of information I was able to uncover causes the file to be compressed, which in turn changes the file and subsequently the LastModifiedDate.

This can be resolved by changing the file you wish to maintain the LastModifiedDate on to PackageAs "vsdpaLoose". This causes the file to NOT be compressed and maintain its properties.

Hopefully someone else will have the same issue and find this useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文