title: Passing command line arguments to console application does not work
body: <p>I can't pass arguments to my console app.
  I tried it like this:</p>
  
  <pre><code>App.exe arg1
  App.exe "arg1"
  App.exe
  </code></pre>
  
  <p>When I run the app with arguments, the app quits running without any messages.</p>
  
  <p>When debugging there is nothing in <code>string[] args</code>.</p>
  
  <p>My C# project is a plain .net 4.5.2 command line project.
  My OS is Windows 10 x64.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>using System;
  using System.Collections.ObjectModel;
  using System.Management.Automation;
  
  namespace Setup
  {
      class Program
      {
          static void Main(string[] args)
          {
              if (args.Length == 0)
              {
                  using (PowerShell psInstance = PowerShell.Create())
                  {
                      string cmd = "Set-ExecutionPolicy RemoteSigned -Force; " +
                                   "echo \"Set-ExecutionPolicy RemoteSigned -Force\"; echo \"\"; " +
                                   "Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; ";
  
                      psInstance.AddScript(cmd);
  
                      Collection&lt;PSObject&gt; PSOutput = psInstance.Invoke();
  
                      Console.WriteLine(psInstance.Streams.Error[0].ErrorDetails.Message);
  
                      foreach (var item in PSOutput)
                      {
                          if (item != null)
                          {
                              Console.WriteLine(item.BaseObject.ToString());
                          }
                      }
                      Console.ReadLine();
                  }
              }
              else
              {
                  // Will not work
                  Console.WriteLine(args[0]);
              }
          }
      }
  }
  </code></pre>
  
  <p>Does anyone have an idea?</p>