.net core中引入fastreport.open在linux上发布

在linux端添加xServer应用;
然后,在web下面添加依赖项:runtime.linux-x64.CoreCompat.System.Drawing
在startup.cs中,添加如下命令:

       static Process xvfb;
        const string xvfb_pid = "pid.xvfb.fr";
        public Startup(IConfiguration configuration)
        {
            LinuxStart();
       
        }
       public static void LinuxStart()
        {
            if (File.Exists(xvfb_pid))
            {
                string pid = File.ReadAllText(xvfb_pid);
                try
                {
                    xvfb = Process.GetProcessById(int.Parse(pid));
                    xvfb.Kill();
                    xvfb = null;
                }
                catch { }
                File.Delete(xvfb_pid);
            }
            //string display = Environment.GetEnvironmentVariable("DISPLAY");
            //if (String.IsNullOrEmpty(display))
            //{
            //    Environment.SetEnvironmentVariable("DISPLAY", ":99");
            //    display = ":99";
            //}
            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "/usr/bin/Xvfb";
            info.Arguments = ":99 -ac -screen 0 1024x768x32 +extension RANDR -dpi 96";
            info.CreateNoWindow = true;
            xvfb = new Process();
            xvfb.StartInfo = info;
            xvfb.Start();
            // File.WriteAllText(xvfb_pid, xvfb.Id.ToString());
        }

猜你喜欢

转载自blog.csdn.net/weixin_34025151/article/details/87638119