如何部署 Visual Studio 应用程序并以静默模式将 Firebird 安装为服务?

问题描述 投票:0回答:1

我应该部署自己的 C# 应用程序,使用 Firebird 作为数据库服务器和远程连接。我应该在安装过程中分发和执行哪些文件,以便最终用户不必干预并注意到任何事情?

我使用了 Microsoft Visual Studio Installer Projects 2022 扩展,我可以附加

database.fdb
FirebirdSql.Data.FirebirdClient.dll
,但显然这还不够,因为我在服务中没有看到活动服务器。

我应该附加哪些 Firebird 文件并运行到发行版?是否可以在不显示任何 Windows 并通过代码设置密码的情况下安装服务器?

c# visual-studio deployment firebird
1个回答
0
投票

我要感谢所有帮助我找到解决方案的人。 最初的问题是将我的 C# 应用程序与 firebirdsql 实例一起部署为服务(并连接到它),通过单个文件和单击安装所有内容。我最终使用了 InnoSetup(我从未使用过)。我当然添加了所有应用程序ddl +我的firebird.FDB数据库和Firebird安装文件Firebird-5.0.1.1469-0-windows-x64.exe。安装程序首先仅安装我的 C# 应用程序,其中安装程序启动 Firebird .exe 文件并连接我在应用程序安装目录中找到的数据库。在安装之前,我检查是否已经安装了 Firebird。

这是检查是否有活动的 firebird 服务的代码

foreach (ServiceController s in ServiceController.GetServices())
    {
        if (UCase(Strings.Mid(s.ServiceName, 1, 8)) == "FIREBIRD") // AndAlso s.Status = ServiceControllerStatus.Running
        {
            switch (s.Status)
            {
                case 4: // ServiceControllerStatus.Running
                    {
                       // to do something
                    }
                case 1: // ServiceControllerStatus.Paused
                    {
                        // to do something
                    }
            }
        }
    }

这是静默安装 Firebird 作为服务的代码:

 string appPath = Path.GetDirectoryName(Application.ExecutablePath);
    string exedinstall = "Firebird-5.0.1.1469-0-windows-x64.exe";
    string installFile = appPath + @"\" + exedinstall;
    string Arguments = @"/SP- /SILENT /SUPPRESSMSGBOXES /NOCANCEL  /NORESTART/MERGETASKS='UseSuperServerTask\CopyFbClientAsGds32Task'/SYSDBAPASSWORD='masterkey'/FORCE";     
    var installerProcess = new Process();
    installerProcess.StartInfo.CreateNoWindow = true;
    installerProcess.StartInfo.RedirectStandardOutput = true;
    installerProcess = Process.Start(installFile, Arguments);

    while (installerProcess.HasExited == false)
    {
        // indicate progress to user 
        Application.DoEvents();
        System.Threading.Thread.Sleep(250);
    }

我不是专业人士,可能存在一些正式错误,但如果这段代码可以帮助别人,我将非常高兴。再次感谢大家

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.