在不同 OS 上安装同名文件

Install file with the same name on different OS's

我对将资源组织成组件的规则有疑问。

我想做的是以下;有两个文件(均为 64 位)具有相同的文件名但位于不同的源位置且具有不同的组件 GUID;

C:\data\win7\driver.sys C:\data\win10\driver.sys

我希望这两个文件都包含在安装程序中,安装程序何时运行取决于 OS 这两个文件中的哪一个将安装在同一位置:

C:\程序Files\MyProgram\driver.sys

这是否违反了有关组件的规则? (主要申请的是我会说的第一个:)

"Never create two components that install a resource under the same name and target location. If a resource must be duplicated in multiple components, change its name or target location in each component. This rule should be applied across applications, products, product versions, and companies."

https://docs.microsoft.com/en-us/windows/desktop/Msi/organizing-applications-into-components

Actual Answer: Yes, installing different files to the same absolute path is indeed a violation of the MSI component rules - in theory. As you have discovered reading the documentation. However, seeing as only one file will make it onto the box, it is all semantics really, there will never be two files installed. Still, the MSI will probably not validate - you will see validation errors.

I am not sure of the technical implications, but could you make the file name different based on OS? Then you simply put the files in separate components and use different component GUIDs and condition the component for installation or not. Full compliance instantly.

With all that said, it seems driver files are to be installed using INF-files in standalone packages in the future. Please read below.


组件规则,实用:这确实是一个众所周知的问题。我有一个可能有用的旧答案:Change my component GUID in wix? It describes how the component rules work in practice, and how the idea is that you reference count an absolute path, and not a file per-se. Please read it to make it clearer. .

驱动安装:我们应该知道如何做到这一点,但是 (and another answer). Essentially drivers are to be distributed via Windows Update, or at least via a standalone package without the need for an installer in the future (until Microsoft change their mind again?). Windows Hardware Dev Center dashboard. As far as I understand the installation is INF-based(和以前一样)。

问题:您确定安装位置吗?文档怎么说?我认为 sys 文件应该主要放在 Windows 文件夹中?或者 WinSxS 文件夹(并排的 win32 程序集)。如您所知,驱动程序安装让我们所有人都感到困惑。

Windows 10 检测:检测 Windows 10 似乎是一个挑战,因为微软的新 "evergreen versionlessness"。我写了这个旧答案来总结我目前对它的理解:Windows 10 not detecting on installshield. Deployment tools such as Advanced Installer does the job for you and detects Windows 10 with simple measures. Not sure what Installshield 确实如此。链接的答案列出了一些自己检测版本的方法 - 不确定哪种方法更明智。请阅读(当您有一个成功的包时,也请报告任何有趣的发现)。