wimh / SparkleShare

SparkleShare is a file sharing and collaboration tool inspired by Dropbox.
http://www.sparkleshare.org/
GNU General Public License v3.0
39 stars 6 forks source link

Console open whilst running #30

Closed hbons closed 12 years ago

hbons commented 12 years ago

Let's find a way to hide it :)

wimh commented 12 years ago

Basically it is very simple: change project from "console application" to "gui application".

But without console, you would not be able to see the debug output any more. It is possible to create a console from a gui application, but it is a bit complicated.

A quick and dirty solution would be using System.Diagnostics.Debug.Write() instead of Console.Write() and use DebugView to show the output when not run from the debugger.

The best solution is to use log4net, but I don't know if and how well it runs inside mono.

hbons commented 12 years ago

Ok, this is an easy one then. I've also made SparkleHelpers.DebugInfo write to a log and optionally output to the console if SparkleHelpers.DebugMode is true in my branch, so nothing needs to really change here.

wimh commented 12 years ago

Chancing the project type will change <OutputType>Exe</OutputType> into <OutputType>WinExe</OutputType> in csproj file. But I just took a look, that is not enough, a lot of consoles will pop up running git. So additionally process.StartInfo.CreateNoWindow = true; is required.

 SparkleShare/Windows/SparkleShare.csproj |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/SparkleShare/Windows/SparkleShare.csproj b/SparkleShare/Windows/SparkleShare.csproj
index 04d1290..469eb9a 100644
--- a/SparkleShare/Windows/SparkleShare.csproj
+++ b/SparkleShare/Windows/SparkleShare.csproj
@@ -5,7 +5,7 @@
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProductVersion>9.0.21022</ProductVersion>
     <ProjectGuid>{728483AA-E34B-4441-BF2C-C8BC2901E4E0}</ProjectGuid>
-    <OutputType>Exe</OutputType>
+    <OutputType>WinExe</OutputType>
     <AssemblyName>SparkleShare</AssemblyName>
     <SchemaVersion>2.0</SchemaVersion>
     <RootNamespace>SparkleShare</RootNamespace>
@@ -30,6 +30,8 @@
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
+    <StartupObject>
+    </StartupObject>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>

 SparkleLib/Git/SparkleFetcherGit.cs |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/SparkleLib/Git/SparkleFetcherGit.cs b/SparkleLib/Git/SparkleFetcherGit.cs
index d7086d7..f0a478e 100755
--- a/SparkleLib/Git/SparkleFetcherGit.cs
+++ b/SparkleLib/Git/SparkleFetcherGit.cs
@@ -267,6 +267,7 @@ namespace SparkleLib {
             StartInfo.RedirectStandardOutput = true;
             StartInfo.UseShellExecute        = false;
             StartInfo.WorkingDirectory       = path;
+            StartInfo.CreateNoWindow         = true;
         }

  SparkleShare/SparkleControllerBase.cs |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs
index 4f202b0..c5fa7f2 100644
--- a/SparkleShare/SparkleControllerBase.cs
+++ b/SparkleShare/SparkleControllerBase.cs
@@ -824,6 +824,7 @@ namespace SparkleShare {
             process.StartInfo.UseShellExecute        = false;
             process.StartInfo.FileName               = "ssh-add";
             process.StartInfo.Arguments              = "\"" + Path.Combine (keys_path, key_file_name) + "\"";
+            process.StartInfo.CreateNoWindow         = true;

             process.Start ();
             process.WaitForExit ();
@@ -888,6 +889,7 @@ namespace SparkleShare {
                 process.StartInfo.UseShellExecute = false;
                 process.StartInfo.RedirectStandardOutput = true;
                 process.StartInfo.FileName = "ssh-keygen";
+                process.StartInfo.CreateNoWindow = true;

                 // -t is the crypto type
                 // -P is the password (none)

 SparkleShare/Windows/SparkleController.cs |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/SparkleShare/Windows/SparkleController.cs b/SparkleShare/Windows/SparkleController.cs
index 5d54d86..467102b 100644
--- a/SparkleShare/Windows/SparkleController.cs
+++ b/SparkleShare/Windows/SparkleController.cs
@@ -181,6 +181,7 @@ namespace SparkleShare {
                process.StartInfo.FileName = "ssh-agent";
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.RedirectStandardOutput = true;
+                process.StartInfo.CreateNoWindow = true;

                process.Start ();