Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use NGen with ClickOnce deployment?

Tags:

Is it possible to use NGen with ClickOnce deployment?

like image 283
Branko Avatar asked Jan 14 '09 17:01

Branko


People also ask

How do I add files to ClickOnce deployment?

On the File menu, click Open to open your application manifest. Select the Files tab. In the text box at the top of the tab, enter the directory that contains your application's files, and then click Populate. Your data file will appear in the grid.

How do I deploy one click application?

In the Specific target page, select ClickOnce. Enter a path or select Browse to select the publish location. In the Install location page, select where users will install the application from. In the Settings page, you can provide the settings necessary for ClickOnce.

What is the function of ClickOnce deployment?

ClickOnce is a deployment technology that enables you to create self-updating Windows-based applications that can be installed and run with minimal user interaction.


2 Answers

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());
    }
}
like image 125
Ron Avatar answered Oct 01 '22 21:10

Ron


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.

like image 45
liggett78 Avatar answered Oct 01 '22 20:10

liggett78