如何在 Wix 重大升级时让 PathwaysMDF 和 LDF 覆盖旧副本?

发布于 2024-08-31 06:44:02 字数 3889 浏览 10 评论 0原文

我需要 PathwaysMDF 和 PathwaysLDF 这两个文件来替换(覆盖)重大升级时的旧副本。

好吧,这个 WiX 让我发疯了。设置文件工作正常,但是数据库文件仍然无法工作!我尝试了几种方法...

这是使用注册表项尝试执行此操作的代码:

<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" >
<RegistryValue Root="HKLM" Key="Software\TDR\Pathways\Database" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" />
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf"/>
</Component>

这会导致旧的 LDF 文件剩余,并且在完成后根本没有 MDF 文件,而不是旧的文件,也不是新的。

以下是日志中关于该尝试的内容: (完整日志位于 http://pastebin.com/a8a7uKfL

MSI(s)(C8:80)[09:01:51:845]:执行操作:SetTargetFolder(文件夹= C:\ Documents and Settings \ All Users \ Application Data \ Pathways) MSI(s)(C8:80)[09:01:51:845]:执行操作:SetSourceFolder(Folder = 1 \ ykpqggg9 \ Pathways \ | CommonAppData \ Pathways) MSI(s)(C8:80)[09:01:51:845]:执行操作:FileCopy(SourceName = x_gekdq7.ldf | Pathways_log.ldf,SourceCabKey = pathsLdf,DestName = Pathways_log.ldf,Attributes = 512,FileSize = 40239104,PerTick=32768,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=-403787921,HashPart2=771061375,HashPart3=-1732951415,HashPart4=-1390528611, ,) MSI (s) (C8:80) [09:01:51:845]:文件:C:\Documents and Settings\All Users\Application Data\Pathways\Pathways_log.ldf;不会覆盖;不会打补丁;现有文件未版本化但已修改 MSI(s)(C8:80)[09:01:51:845]:执行操作:FileCopy(SourceName = Pathways.mdf,SourceCabKey = pathsMdf,DestName = Pathways.mdf,Attributes = 512,FileSize = 156368896,PerTick = 32768,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=570808063,HashPart2=-1571218748,HashPart3=-867678845,HashPart4=601212343,,) MSI (s) (C8:80) [09:01:51:845]:文件:C:\Documents and Settings\All Users\Application Data\Pathways\Pathways.mdf;不会覆盖;不会打补丁;现有文件未版本化但已修改

下面是使用伴随文件(主程序可执行文件,已版本化)尝试执行此操作的代码:

<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" >
<File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" CompanionFile="pathwaysExe" />
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" CompanionFile="pathwaysExe" />
</Component>

结果是 LDF 文件表现完美,用新文件替换旧文件,但是 MDF 文件是走了。旧的和新的都一样,失踪了。

以下是日志中关于该尝试的内容: (完整日志位于 http://pastebin.com/gijLN5QY):

MSI(s)(C8:F8)[09:21:55:206]:执行操作:SetCompanionParent(ParentPath = C:\ Program Files \ Pathways \,ParentName = Pathways.exe,ParentVersion = 1.1.5.0,ParentLanguage = 0 ) MSI(s)(C8:F8)[09:21:55:206]:执行操作:FileCopy(SourceName = Pathways.mdf,SourceCabKey = pathsMdf,DestName = Pathways.mdf,Attributes = 512,FileSize = 156368896,PerTick = 32768,,VerifyMedia=1,,,,,CheckCRC=0,版本=pathwaysExe,,InstallMode=58982400,,,,,,,) MSI (s) (C8:F8) [09:21:55:236]:文件:C:\Documents and Settings\All Users\Application Data\Pathways\Pathways.mdf;覆盖;不会打补丁;现有文件具有相同版本(使用配套版本检查:C:\Program Files\Pathways\Pathways.exe) MSI (s) (C8:F8) [09:21:55:236]:文件“pathwaysMdf”的源已压缩 InstallFiles:文件:Pathways.mdf,目录:C:\ Documents and Settings \ All Users \ Application Data \ Pathways \,大小:156368896 MSI (s) (C8:F8) [09:21:55:246]:从现有文件重新应用安全性。 MSI (s) (C8:F8) [09:21:55:246]:验证文件的可访问性:Pathways.mdf MSI(s)(C8:F8)[09:21:55:266]:注意:1:2318 2:C:\ Documents and Settings \ All Users \ Application Data \ Pathways \ Pathways.mdf MSI (C8:F8) [09:21:55:266]:注:1:2360 MSI (C8:F8) [09:21:55:266]:注:1:2360

我还尝试仅将 MDF 文件设置为 KeyPath="yes",而不使用 CompanionFile 标记。这也行不通。

I need both these files, PathwaysMDF and PathwaysLDF to replace (overwrite) the old copies on a major upgrade.

Okay, this WiX is driving me crazy. The settings file works perfectly, however the database files are still not working! I have tried several approaches...

Here is the code attempting this with the registry key:

<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" >
<RegistryValue Root="HKLM" Key="Software\TDR\Pathways\Database" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" />
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf"/>
</Component>

This results in the old LDF file remaining, and no MDF file there at all, when completed, not the old one, nor the new one.

Here is what the log says about that attempt:
(complete log at http://pastebin.com/a8a7uKfL)


MSI (s) (C8:80) [09:01:51:845]: Executing op: SetTargetFolder(Folder=C:\Documents and Settings\All Users\Application Data\Pathways)
MSI (s) (C8:80) [09:01:51:845]: Executing op: SetSourceFolder(Folder=1\ykpqggg9\Pathways\|CommonAppData\Pathways)
MSI (s) (C8:80) [09:01:51:845]: Executing op: FileCopy(SourceName=x_gekdq7.ldf|Pathways_log.ldf,SourceCabKey=pathwaysLdf,DestName=Pathways_log.ldf,Attributes=512,FileSize=40239104,PerTick=32768,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=-403787921,HashPart2=771061375,HashPart3=-1732951415,HashPart4=-1390528611,,)
MSI (s) (C8:80) [09:01:51:845]: File: C:\Documents and Settings\All Users\Application Data\Pathways\Pathways_log.ldf; Won't Overwrite; Won't patch; Existing file is unversioned but modified
MSI (s) (C8:80) [09:01:51:845]: Executing op: FileCopy(SourceName=Pathways.mdf,SourceCabKey=pathwaysMdf,DestName=Pathways.mdf,Attributes=512,FileSize=156368896,PerTick=32768,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=570808063,HashPart2=-1571218748,HashPart3=-867678845,HashPart4=601212343,,)
MSI (s) (C8:80) [09:01:51:845]: File: C:\Documents and Settings\All Users\Application Data\Pathways\Pathways.mdf; Won't Overwrite; Won't patch; Existing file is unversioned but modified

Here is the code attempting this using a companion file (the main program executable, which is versioned):

<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" >
<File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" CompanionFile="pathwaysExe" />
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" CompanionFile="pathwaysExe" />
</Component>

The result of this is that the LDF file behaves perfectly, replacing the old with the new, however, the MDF file is GONE. Old one and new one alike, missing.

Here is what the log says about that attempt:
(complete log at http://pastebin.com/gijLN5QY):


MSI (s) (C8:F8) [09:21:55:206]: Executing op: SetCompanionParent(ParentPath=C:\Program Files\Pathways\,ParentName=Pathways.exe,ParentVersion=1.1.5.0,ParentLanguage=0)
MSI (s) (C8:F8) [09:21:55:206]: Executing op: FileCopy(SourceName=Pathways.mdf,SourceCabKey=pathwaysMdf,DestName=Pathways.mdf,Attributes=512,FileSize=156368896,PerTick=32768,,VerifyMedia=1,,,,,CheckCRC=0,Version=pathwaysExe,,InstallMode=58982400,,,,,,,)
MSI (s) (C8:F8) [09:21:55:236]: File: C:\Documents and Settings\All Users\Application Data\Pathways\Pathways.mdf; Overwrite; Won't patch; Existing file is of an equal version (Checked using version of companion: C:\Program Files\Pathways\Pathways.exe)
MSI (s) (C8:F8) [09:21:55:236]: Source for file 'pathwaysMdf' is compressed
InstallFiles: File: Pathways.mdf, Directory: C:\Documents and Settings\All Users\Application Data\Pathways\, Size: 156368896
MSI (s) (C8:F8) [09:21:55:246]: Re-applying security from existing file.
MSI (s) (C8:F8) [09:21:55:246]: Verifying accessibility of file: Pathways.mdf
MSI (s) (C8:F8) [09:21:55:266]: Note: 1: 2318 2: C:\Documents and Settings\All Users\Application Data\Pathways\Pathways.mdf
MSI (s) (C8:F8) [09:21:55:266]: Note: 1: 2360
MSI (s) (C8:F8) [09:21:55:266]: Note: 1: 2360

I have also tried setting just the MDF file to KeyPath="yes" without the CompanionFile tag. This also isn't working.

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

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

发布评论

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

评论(2

巷子口的你 2024-09-07 06:44:02

在我看来,WiX 的升级设计确实存在很大缺陷。应该发生的是,默认情况下每个文件都应该“总是替换”任何内容。仅应考虑标记有适当属性的文件进行版本控制和其他注意事项。

WiX 似乎仅用于安装 .exe 和 .dll 或其他明确已知具有版本的文件。这是不幸的,因为如果它实际上被设计为通用安装机制,那么它可以更有效并阻止很多人浪费时间。

It sure seems to me that the upgrade design is highly flawed with WiX. What should be happening, is that each File should, by default "always replace" anything. Only files marked with an appropriate attribute should be considered for versioning and other considerations.

WiX seems to be designed for only installing .exe and .dll or other explicitly known to have a version files. That's unfortunate, because it could much more effective and stop so many people wasting their time, if it was actually designed to be a general purpose install mechanism.

段念尘 2024-09-07 06:44:02

尝试删除数据库组件中的RemoveFile 条目。他们告诉安装程序仅在卸载时删除,升级时,过程是升级产品代码而不是卸载。此外,如果您想删除不是由安装程序创建的文件(或者如果您想控制发生的情况,例如仅在升级时删除等),则只需要删除文件条目,

无论如何尝试此

  <Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D">
       <File KeyPath="yes" Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" />
       <File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" />
   </Component>

编辑1

如果您遇到这些问题时,查看日志总是有用的,要生成日志,请运行以下命令

msiexec /i "\PATHTOSETUP\setup.msi" /l*xv

x 用于额外调试,这可能会产生太多噪音,因此您可能排除该开关,但是表示详细的 v 通常非常有用。

如果上述建议不能解决问题,您可以将日志粘贴到 http://pastebin.com/

等位置编辑2

好的。 Pathwaysmdf 文件未版本化。当涉及到升级时间时,Windows Installer 会比较当前文件和新文件,如果它们都未版本化并且文件已更改,则假定用户已更改它,因此会保留它。此比较是在键路径上完成的,在您的情况下是 pathsmdf 文件。要解决此问题,请创建一个虚拟文件或注册表项作为组件密钥路径。我建议使用诸如注册表项之类的东西

HKLM\Software\YOURCOMPANY\YOURPRODUCT\Database\Isinstalled = 1

Try deleting the RemoveFile entries in the Database component. They are telling the installer to only remove on uninstall, when upgrading, the process is UPGRADINGPRODUCTCODE not UNINSTALL. Besides you only need the removefile entry if you want to remove a file that wasnt created by your installer, (or if you want to control what happens like only remove on upgrade etc)

anyhow try this

  <Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D">
       <File KeyPath="yes" Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" />
       <File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" />
   </Component>

EDIT 1

If you get these problems its always useful to look at the log, to generate a log run the following command

msiexec /i "\PATHTOSETUP\setup.msi" /l*xv

x is for extra debugging which might produce too much noise so you might exclude that switch however the v for verbose is normally quite useful.

If the above suggestion doesnt fix it can you paste your log somewhere like http://pastebin.com/

EDIT 2

Ok. The pathwaysmdf file is unversioned. When it comes to upgrade time Windows Installer compares the current and new file if they are both unversioned and the file has changed it assumes that the user has altered it and thus it leaves it. This comparison is done on the keypath, which in your case is the pathwaysmdf file. To fix this either create a dummy file or registry key as the components keypath. I would suggest something like a registry key

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