简体   繁体   中英

CefSharp Winform deployment via ClickOnce and requirements vc redist in Visual Studio 2019 - Error

When launch clickonce setup of CefSharp Winform Application return an error installing vc++ 2019 redist (vc++ is in deployment requirements). It's generate an empty directory during install.

"C:\Users\xxxxxx\AppData\Local\Temp\VSD66FC.tmp\vcredist_x86\vcredist_x86.exe has changed since it was initially published."

Both on Windows 7 and 10, same error. I need to install manually package.

I've removed Visual C++ "14" from requirements, but I don't know how include c++ library in the Application code.

I found a workaround. I'm using a service, but it should work in a winform:

 private void InstallVCredist()
    {
        string exe = @"path to exe\VC_redist.x86.exe"; //set path
        string stp = @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; //set subkey
        using (RegistryKey reg = Registry.LocalMachine.OpenSubKey(stp)) //recall registry
        {
            if (reg != null)
            {
                foreach (string dname in reg.GetSubKeyNames()) //loop search
                {
                    using (RegistryKey sreg = reg.OpenSubKey(dname))
                    {
                        if (sreg.GetValue("DisplayName").ToString() == "Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.23.27820") //set dispayname of version
                        {
                            vcredist = "1"; //it's mine control variable
                            break;
                        }
                    }
                }
            }
        }
        if (vcredist == "0") //now testing if it was found 
        {
            Process vc = new Process();
            vc.StartInfo.FileName = exe;
            //silent install
            vc.StartInfo.Arguments = "/install /passive /norestart";
            vc.StartInfo.UseShellExecute = false;
            vc.StartInfo.CreateNoWindow = true;
            //silent install
            vc.Start(); 
            vc.WaitForExit(); //as he says ;)
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM