复制所有文件之前的WiX启动服务

时间:2017-10-11 16:11:02

标签: wix windows-installer iswix

我有一个合并模块,它定义了所有组件/资源,以及安装和启动服务。

这将构建一个在全新安装期间工作的安装程序。从先前版本升级时,它会尝试在复制所有文件之前启动服务(服务依赖于这些文件)。如何在复制文件后让WiX启动服务?

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define ComponentRules="OneToOne"?>
  <!-- SourceDir instructs IsWiX the location of the directory that contains files for this merge module -->
  <?define SourceDir="..\Deploy"?>
  <Module Id="AgentMM" Language="1033" Version="1.2.1">
    <Package Id="*" Manufacturer="Example Inc" InstallerVersion="500" InstallPrivileges="elevated" InstallScope="perMachine" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="CommonAppDataFolder" Name="CommonAppData">
        <Directory Id="owdF4A3A065B05943EB31D4A22FB4A609B2" Name=" ">
          <Directory Id="owd054D805088608C669D54B91D1372FB13" Name="agent">
            <Component Id="owc054D805088608C669D54B91D1372FB13" Guid="*">
              <CreateFolder />
            </Component>
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="MergeRedirectFolder">
        <Component Id="owcE4483ACA0E06F6931349C52F4DE32B04" Guid="*">
          <File Id="owfE4483ACA0E06F6931349C52F4DE32B04" Source="$(var.SourceDir)\Agent.exe" KeyPath="yes" />
          <ServiceInstall Id="si1F414070C0DF7193A1D990B85A956139" Name="Agent" DisplayName="Agent" Description="Reports on system health" ErrorControl="normal" Start="auto" Type="ownProcess" Interactive="no" />
          <ServiceControl Id="sc1F414070C0DF7193A1D990B85A956139" Name="Agent" Start="install" Stop="both" Remove="both" Wait="yes" />
        </Component>
        <Component Id="owcB927FFAE9DA1BF9B833D1BB6615B7D1F" Guid="*">
          <File Id="owfB927FFAE9DA1BF9B833D1BB6615B7D1F" Source="$(var.SourceDir)\Cassia.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc4068B8346D37AA0AFB49DF9E39B8C148" Guid="*">
          <File Id="owf4068B8346D37AA0AFB49DF9E39B8C148" Source="$(var.SourceDir)\Cassia.xml" KeyPath="yes" />
        </Component>
        <Component Id="owc52F75CE3A69F808CE9B7861F5FF157E7" Guid="*">
          <File Id="owf52F75CE3A69F808CE9B7861F5FF157E7" Source="$(var.SourceDir)\Agent.exe.config" KeyPath="yes" />
        </Component>
        <Component Id="owc983DF61596DB6BCFA851E8953561E349" Guid="*">
          <File Id="owf983DF61596DB6BCFA851E8953561E349" Source="$(var.SourceDir)\Agent.pdb" KeyPath="yes" />
        </Component>
        <Component Id="owc2BF30E4776996DDD68B184F69F7D1E00" Guid="*">
          <File Id="owf2BF30E4776996DDD68B184F69F7D1E00" Source="$(var.SourceDir)\Utilities.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcE10E1E5CADEF47AEB294ED17810D9F5D" Guid="*">
          <File Id="owfE10E1E5CADEF47AEB294ED17810D9F5D" Source="$(var.SourceDir)\Utilities.pdb" KeyPath="yes" />
        </Component>
        <Component Id="owcADE9A457248959D397C6B092C7CCF78B" Guid="*">
          <File Id="owfADE9A457248959D397C6B092C7CCF78B" Source="$(var.SourceDir)\Microsoft.Win32.Primitives.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc3FC8434C1A84605AEEBC6A100CA2F3E1" Guid="*">
          <File Id="owf3FC8434C1A84605AEEBC6A100CA2F3E1" Source="$(var.SourceDir)\Newtonsoft.Json.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcDE8FDCCF922CA433A075036DF5C1BE38" Guid="*">
          <File Id="owfDE8FDCCF922CA433A075036DF5C1BE38" Source="$(var.SourceDir)\Newtonsoft.Json.xml" KeyPath="yes" />
        </Component>
        <Component Id="owcBC6AFA6932E46F7635B750194F2DFE30" Guid="*">
          <File Id="owfBC6AFA6932E46F7635B750194F2DFE30" Source="$(var.SourceDir)\Nito.AsyncEx.Context.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcB0247DD3838FC1DDFA9BBA29DDE5A2DB" Guid="*">
          <File Id="owfB0247DD3838FC1DDFA9BBA29DDE5A2DB" Source="$(var.SourceDir)\Nito.AsyncEx.Context.xml" KeyPath="yes" />
        </Component>
        <Component Id="owc80E1432E52AF192AE3A458644EFA81C1" Guid="*">
          <File Id="owf80E1432E52AF192AE3A458644EFA81C1" Source="$(var.SourceDir)\Nito.AsyncEx.Tasks.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc956AF9D61B4B96E805D3B6990EC17870" Guid="*">
          <File Id="owf956AF9D61B4B96E805D3B6990EC17870" Source="$(var.SourceDir)\Nito.AsyncEx.Tasks.xml" KeyPath="yes" />
        </Component>
        <Component Id="owc9797AB99B9AB073F5FAFAE13A51ECE35" Guid="*">
          <File Id="owf9797AB99B9AB073F5FAFAE13A51ECE35" Source="$(var.SourceDir)\Nito.Disposables.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc33EA8A2869C77F471EBAD2451B964902" Guid="*">
          <File Id="owf33EA8A2869C77F471EBAD2451B964902" Source="$(var.SourceDir)\Nito.Disposables.xml" KeyPath="yes" />
        </Component>
        <Component Id="owc25FBE4153F32A5634B0ADA8A6954CC89" Guid="*">
          <File Id="owf25FBE4153F32A5634B0ADA8A6954CC89" Source="$(var.SourceDir)\System.AppContext.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc2F5D24BF1EA2D036DA793146E86BDF87" Guid="*">
          <File Id="owf2F5D24BF1EA2D036DA793146E86BDF87" Source="$(var.SourceDir)\System.Collections.Immutable.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc2BE2107F9B51B79FDB1B19EA807C9C44" Guid="*">
          <File Id="owf2BE2107F9B51B79FDB1B19EA807C9C44" Source="$(var.SourceDir)\System.Collections.Immutable.xml" KeyPath="yes" />
        </Component>
        <Component Id="owcA90D9D10E6DAB6E67011458672887086" Guid="*">
          <File Id="owfA90D9D10E6DAB6E67011458672887086" Source="$(var.SourceDir)\System.Console.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcBC11F886BA2AB9469783C04435BCA0B9" Guid="*">
          <File Id="owfBC11F886BA2AB9469783C04435BCA0B9" Source="$(var.SourceDir)\System.Diagnostics.DiagnosticSource.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc918BEF5091074ABD7E2C05293EDBFE17" Guid="*">
          <File Id="owf918BEF5091074ABD7E2C05293EDBFE17" Source="$(var.SourceDir)\System.Diagnostics.DiagnosticSource.xml" KeyPath="yes" />
        </Component>
        <Component Id="owc38B2B9FCCE93A2C7D2E931C05D695098" Guid="*">
          <File Id="owf38B2B9FCCE93A2C7D2E931C05D695098" Source="$(var.SourceDir)\System.Diagnostics.Tracing.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcB1B1D5CD5E0525947D05C2530DDA9E96" Guid="*">
          <File Id="owfB1B1D5CD5E0525947D05C2530DDA9E96" Source="$(var.SourceDir)\System.Globalization.Calendars.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc5AC6699E38D4EE124CC260C1E19F025A" Guid="">
          <File Id="owf5AC6699E38D4EE124CC260C1E19F025A" Source="$(var.SourceDir)\System.IO.Compression.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc87D8454A10E8D4063130BA0D60AAE450" Guid="*">
          <File Id="owf87D8454A10E8D4063130BA0D60AAE450" Source="$(var.SourceDir)\System.IO.Compression.ZipFile.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc7600C49A56A3819C607969AD7D76A1D1" Guid="*">
          <File Id="owf7600C49A56A3819C607969AD7D76A1D1" Source="$(var.SourceDir)\System.IO.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc6A348A5B38822B45BE742FD5B11ACF09" Guid="*">
          <File Id="owf6A348A5B38822B45BE742FD5B11ACF09" Source="$(var.SourceDir)\System.IO.FileSystem.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc6AF351692769A11F3108B81F1F6AC695" Guid="*">
          <File Id="owf6AF351692769A11F3108B81F1F6AC695" Source="$(var.SourceDir)\System.IO.FileSystem.Primitives.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc14A5BB088914D21BDD2FBEE1395FD78B" Guid="*">
          <File Id="owf14A5BB088914D21BDD2FBEE1395FD78B" Source="$(var.SourceDir)\System.Linq.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc06E33481927840239152432A87297CC9" Guid="*">
          <File Id="owf06E33481927840239152432A87297CC9" Source="$(var.SourceDir)\System.Linq.Expressions.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcB279CD308898A9D5EFCE20D942FB230A" Guid="*">
          <File Id="owfB279CD308898A9D5EFCE20D942FB230A" Source="$(var.SourceDir)\System.Net.Http.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcE7C4094F57B0A8D61E66E0978388F384" Guid="*">
          <File Id="owfE7C4094F57B0A8D61E66E0978388F384" Source="$(var.SourceDir)\System.Net.Http.Formatting.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcAB556DAB8513CFEB9A95F8187FBB7D96" Guid="*">
          <File Id="owfAB556DAB8513CFEB9A95F8187FBB7D96" Source="$(var.SourceDir)\System.Net.Http.Formatting.xml" KeyPath="yes" />
        </Component>
        <Component Id="owcC356900D1A9E2893A31E87C428F0E41B" Guid="*">
          <File Id="owfC356900D1A9E2893A31E87C428F0E41B" Source="$(var.SourceDir)\System.Net.Sockets.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc7A6EE41CC1504CC124313BD05EDA4F44" Guid="*">
          <File Id="owf7A6EE41CC1504CC124313BD05EDA4F44" Source="$(var.SourceDir)\System.Reflection.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcCD2580ECA1FA1A3513916545D2F2BFA5" Guid="*">
          <File Id="owfCD2580ECA1FA1A3513916545D2F2BFA5" Source="$(var.SourceDir)\System.Runtime.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcB0183318DD63CCAB717750C767DC21D7" Guid="*">
          <File Id="owfB0183318DD63CCAB717750C767DC21D7" Source="$(var.SourceDir)\System.Runtime.Extensions.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc456C772F6BA4F8274FFF4540362C5A62" Guid="*">
          <File Id="owf456C772F6BA4F8274FFF4540362C5A62" Source="$(var.SourceDir)\System.Runtime.InteropServices.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc142B759C8549F55E22EAD18CF214B77E" Guid="*">
          <File Id="owf142B759C8549F55E22EAD18CF214B77E" Source="$(var.SourceDir)\System.Runtime.InteropServices.RuntimeInformation.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcD6CB46E32249D9DFE253203C9E68622F" Guid="*">
          <File Id="owfD6CB46E32249D9DFE253203C9E68622F" Source="$(var.SourceDir)\System.Security.Cryptography.Algorithms.dll" KeyPath="yes" />
        </Component>
        <Component Id="owcF620F5D5E0DED6F51741DE9E09BAA10C" Guid="*">
          <File Id="owfF620F5D5E0DED6F51741DE9E09BAA10C" Source="$(var.SourceDir)\System.Security.Cryptography.Encoding.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc0F0B6DF93E003C893A5E5E253BAF6C85" Guid="*">
          <File Id="owf0F0B6DF93E003C893A5E5E253BAF6C85" Source="$(var.SourceDir)\System.Security.Cryptography.Primitives.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc328828932DA40CAED6EC4EA121F7534D" Guid="*">
          <File Id="owf328828932DA40CAED6EC4EA121F7534D" Source="$(var.SourceDir)\System.Security.Cryptography.X509Certificates.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc50D709F95681A7937E1395ED21E4DE32" Guid="*">
          <File Id="owf50D709F95681A7937E1395ED21E4DE32" Source="$(var.SourceDir)\System.Text.RegularExpressions.dll" KeyPath="yes" />
        </Component>
        <Component Id="owc1EC9EF9564C76F0DA10AA382F306146E" Guid="*">
          <File Id="owf1EC9EF9564C76F0DA10AA382F306146E" Source="$(var.SourceDir)\System.Xml.ReaderWriter.dll" KeyPath="yes" />
        </Component>
      </Directory>
    </Directory>
    <ComponentGroupRef Id="Custom" />
  </Module>
</Wix>

升级日志:https://pastebin.com/cDUFT98Q

2 个答案:

答案 0 :(得分:1)

我正在向它倾斜 - 我现在还没有准备好对此进行测试,但是这里有:

一些问题

  • 日志文件中有多个错误。该日志文件末尾的实际安装状态是什么?在同一应用程序/ MSI安装的添加/删除程序中是否有两个条目?它看起来像是日志文件中失败的主要升级,但有点难以辨别。看起来至少有一个安装回滚,也许两者都回滚。机器上的最终状态是什么?
  • 您的TARGETDIRROOTDRIVE设置为 H:。那是什么?您的H:驱动器上有什么?您的 IIS安装?它看起来像C:\是你的系统文件夹。
  • 为什么要在安装和卸载时将服务设置为卸载ServiceControlServiceInstall表在编译的MSI文件中是什么样的? (使用Orca打开或相当于检查 - 如果您报告值,则很好。特别是ServiceInstall:ServiceTypeServiceControl:Event)。我安装服务已经有一段时间了,但我记得只有几个选项真正有意义。我想我总是使用:安装时创建,安装时停止和启动,卸载时停止和删除。换句话说:在没有安装删除的情况下尝试
  • 由于此日志消息,以下文件永远不会安装: Nito.AsyncEx.Tasks.xml Nito.AsyncEx.Context.dll

MSI (s) (BC:D4) [11:46:53:020]: Disallowing installation of component: {6EA4EDA3-FBF8-8B13-1DAA-342C5D7EDCB5} since the same component with higher versioned keyfile exists MSI (s) (BC:D4) [11:46:53:022]: Disallowing installation of component: {7B9CD5B0-C538-77AE-E4D9-87B4A74C6207} since the same component with higher versioned keyfile exists

  • 您应该修复dll的版本号,以便升级的MSI安装正确的版本。 这些丢失的文件版本会阻止您的服务启动吗?

日志文件检查

我不确定要推荐什么,除了帮助您在实验时正确阅读日志文件。我确实浏览了你的日志,并且有几个奇怪的地方 - 几个失败的行动。每当您创建日志文件时,您应始终first search for "value 3" as explained by Rob Mensching (WiX creator)

所以搜索“价值3”。研究错误,然后检查这些链接以解释返回的错误:

我想这不是一个真正的答案,但有些链接可以让你前进。试一试,让我们知道会发生什么,这样如果有更多的信息,我们可以“发展”答案。

答案 1 :(得分:1)

为什么在安装所有文件之前说“服务已启动”?目前尚不清楚您是否在猜测,或者您还没有发布一些额外信息。问题当然似乎是服务无法启动,但是,为什么你说这是因为文件丢失了?

我将再次注意,您提供的日志不是您发布的源WiX的日志,因为该源没有主要升级功能,并且发布的源也有一个名为“Agent”的服务,该服务不是日志中的服务。由于我们在这里讨论服务,因此当源WiX或服务名称都不匹配日志时它没有用。

话虽如此,并且假设有丢失的文件,最可能的问题是您遇到了Windows Installer错误,它决定不卸载文件,然后发现这是升级但无论如何都将其删除。这篇文章描述了这个问题,您可以尝试在CostInitialize之前对RemoveExistingProducts进行排序,以查看是否更正了它“

WiX MSI upgrade disallows installation of some components

您还应该检查您是否在此处报告了类似的问题:

https://blogs.msdn.microsoft.com/astebner/2015/11/16/why-windows-installer-removes-files-during-a-major-upgrade-if-they-go-backwards-in-version-numbers/

您在升级期间降级文件版本的位置。

相关问题