是否可以将 NGen 与 ClickOnce 部署结合使用?

发布于 2024-07-12 07:44:35 字数 37 浏览 3 评论 0原文

是否可以将 NGen 与 ClickOnce 部署结合使用?

Is it possible to use NGen with ClickOnce deployment?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸩远一方 2024-07-19 07:44:35

实际上,您可以使用 NGEN 和 clickone,但您需要在 clickonce 安装后运行 NGEN,因为 NGEN 是 .NET 安装的一部分(对于 3.5,您应该参考 2.0 安装)。

这是一个示例,我认为它足够通用,您可以使用它而无需更改或对代码进行很少的更改(除了对表单的调用之外):

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
        {

            string appPath = Application.StartupPath;
            string winPath = Environment.GetEnvironmentVariable("WINDIR");

            Process proc = new Process();
            System.IO.Directory.SetCurrentDirectory(appPath);

            proc.EnableRaisingEvents = false;
            proc.StartInfo.CreateNoWindow = false;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe";
            proc.StartInfo.Arguments = "uninstall " + Application.ProductName + " /nologo /silent";

            proc.Start();
            proc.WaitForExit();

            proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe";
            proc.StartInfo.Arguments = "install " + Application.ProductName + " /nologo /silent";

            proc.Start();
            proc.WaitForExit();

        }

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}

Actually you can use NGEN and clickone, but you are going to need to run the NGEN after the clickonce installation has happened, since NGEN is part of the .NET installation (for 3.5 you should refer to the 2.0 installation).

Here is an example, I think it is generic enough for you to use it without changing or doing very little changes to the code (except for the call to your form):

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
        {

            string appPath = Application.StartupPath;
            string winPath = Environment.GetEnvironmentVariable("WINDIR");

            Process proc = new Process();
            System.IO.Directory.SetCurrentDirectory(appPath);

            proc.EnableRaisingEvents = false;
            proc.StartInfo.CreateNoWindow = false;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe";
            proc.StartInfo.Arguments = "uninstall " + Application.ProductName + " /nologo /silent";

            proc.Start();
            proc.WaitForExit();

            proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe";
            proc.StartInfo.Arguments = "install " + Application.ProductName + " /nologo /silent";

            proc.Start();
            proc.WaitForExit();

        }

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
心作怪 2024-07-19 07:44:35

你不能。 请参阅 http:// Social.msdn.microsoft.com/Forums/en-US/clr/thread/a41b62c5-bdee-4bd5-9811-15a35c4a4add/。 您需要为此创建一个常规安装程序文件。

No, you can not. See http://social.msdn.microsoft.com/Forums/en-US/clr/thread/a41b62c5-bdee-4bd5-9811-15a35c4a4add/. You need to create a regular installer file for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文