【发布时间】:2020-07-14 11:57:46
【问题描述】:
我创建了一个 Windows 服务项目。在构建后事件中,我将输出与另一个项目一起复制到一个公共目录之外。我正在使用heat 任务生成一个 MSI,以复制 MSI 中的两个目录。我正在尝试安装后启动服务。
两个项目都使用serilog.configuration 加载具有记录器配置的 json 文件。
如果我在installutil 的帮助下安装服务,则服务安装成功,之后完美启动。但是当我尝试使用 MSI 安装时,出现以下错误并且安装永远不会完成。
Service cannot be started. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Hive.WindowsAgent.Service.HiveAgentService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
我检查了 nuget 包,Windows 服务包含 Microsoft.Extensions.Configuration.Abstraction v3.1.5。而且只有 MSI 才会失败。
我的 wix 文件:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.ProductUpgradeId)">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="HarvestSetup" Level="1">
<ComponentGroupRef Id="AutogeneratedComponents" />
<ComponentGroupRef Id="ProductComponents"/>
</Feature>
<UI />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="$(var.ProductManufacturer)" ComponentGuidGenerationSeed="4BDDE809-FF2B-4DF9-B1D6-2DBA45AB122F">
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="HiveServiceDirectory" Name="HiveService" />
</DirectoryRef>
<ComponentGroup Id="ProductComponents" Directory="HiveServiceDirectory">
<Component Id="ProductServiceInstaller" Guid="4F512FED-176D-4FBE-AAC2-8333E4B4231F">
<File Id="$(var.ServiceName)" Name="$(var.ServiceName)" Source="$(var.ProductPath)" KeyPath="yes" />
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Name="$(var.ServiceName)"
DisplayName="$(var.ServiceName)"
Description="Service for Windows agent"
Start="auto"
Account="LocalSystem"
ErrorControl="normal" />
<ServiceControl Id="StartStopService"
Start="install"
Stop="both"
Remove="uninstall"
Name="$(var.ServiceName)"
Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
我错过了什么?
附:如果需要更多信息,请告诉我
【问题讨论】:
标签: c# wix windows-services