【发布时间】:2016-05-17 20:31:44
【问题描述】:
我使用 Visual Studio 2012 创建了一个 Windows Servicec 项目,包括 Entity Framework 6 以连接到我的数据库。我添加了一个新的 WIX 项目来创建安装包。
如果我在调试模式下运行项目(在 Visual Studio 的本地),它工作正常。但是安装后服务返回如下错误:
No connection string named 'MyEntities' could be found in the application config file.
我是 Windows 安装 XML (WIX) 的新手,我不知道如何解决这个问题。 我认为 Product.wxs 有问题,或者 WIX 项目中有问题...
这是 Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<!-- The name of the product -->
<?define Name = "MyService" ?>
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "MyCompanyName" ?>
<!-- The version number of this setup package-->
<?define Version = "1.0.1" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "{1240E0CD-B3D2-44A7-B064-11B3C0709D69}" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033">
<!-- Create a folder inside Talk Sharp called Test Service -->
<Package InstallerVersion="300" Compressed="yes"/>
<!-- Create a folder inside Talk Sharp called Test Service -->
<Media Id="1" Cabinet="ParodosService.cab" EmbedCab="yes" />
<!-- Allow upgrades and prevent downgrades -->
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<!-- Define the directory structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<!-- Create a folder inside program files called Talk Sharp -->
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
<!-- Create a folder inside Talk Sharp called Test Service -->
<Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
</Directory>
</Directory>
</Directory>
<!-- The files inside this DirectoryRef are linked to the Test Service directory via INSTALLFOLDER -->
<DirectoryRef Id="INSTALLFOLDER">
<!-- Create a single component which is the MyService.exe file -->
<Component Id="$(var.MyService.TargetFileName)">
<!-- Copies the ParodosService.exe file using the project reference preprocessor variables -->
<File Id="$(var.MyService.TargetFileName)" Source="$(var.MyService.TargetPath)" KeyPath="yes" />
<!-- Remove all files from the INSTALLFOLDER on uninstall -->
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<!-- Tell WiX to install the Service -->
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Name="MyService"
DisplayName="$(var.Name)"
Description="A Test Service that logs dummy text on an interval to a text file."
Start="auto"
ErrorControl="normal" />
<!-- Tell WiX to start the Service -->
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
</Component>
</DirectoryRef>
<!-- Tell WiX to install the files -->
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="$(var.MyService.TargetFileName)" />
</Feature>
</Product>
</Wix>
任何帮助将不胜感激... 提前致谢。
【问题讨论】:
-
您的可执行文件只有一个
,您还需要部署 ParodosServices.exe.settings。你最好(长主题...)把它放在一个单独的组件中。注意这里 没用,卸载程序已经做了,不需要告诉它。 -
并包含您的 exe 可能具有的任何 dll 依赖项。
-
忽略第二部分(我的意思是“每个组件一个文件”)。为设置文件添加另一个
及其 就完成了 -
感谢您的回复。在我的服务项目 (\Visual Studio 2012\Projects\MyProject\MyProject.Setup\bin\Release) 的 bin 中,只有这些文件:MyProject.Setup.msi、MyProjcect.Setup.wixpdb。如果我将这些文件复制到 Program FIles\Manufacturer\Name 文件夹中,则没有任何变化...
-
这是您的 setup 输出文件夹。您只需要 .msi 文件(最终是 Installer.exe/Setup.exe 或其他文件)。您需要从 service 输出文件夹中解聚文件...
标签: c# entity-framework visual-studio-2012 wix