Prevent command window showing when NAnt compiling windows forms application
- by HollyStyles
I have been playing with creating little windows forms apps without visual studio.
I create my source in Notepad++ and compile with a NAnt build file.
When I run the application a command window is also displayed as well as the application window. How can I prevent the command window showing up?
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Media;
using System.IO;
namespace mynamespace
{
class MyForm : Form
{
public Button btnPlay;
MyForm()
{
this.SuspendLayout();
this.Text = "My Application";
InitialiseForm();
this.ResumeLayout(false);
}
private void InitialiseForm()
{
btnPlay = new Button();
btnPlay.Location = new System.Drawing.Point(30,40);
btnPlay.Text = "Play";
btnPlay.Click += new System.EventHandler(btnPlay_Click);
this.Controls.Add(btnPlay);
}
protected void btnPlay_Click(object sender, EventArgs e)
{
string wav = "testing123.wav";
Stream resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(wav);
SoundPlayer player = new SoundPlayer(resourceStream);
player.Play();
}
public static void Main()
{
Application.Run(new MyForm());
}
}
}
Build file
<?xml version="1.0"?>
<project name="myform" default="build" basedir=".">
<description>My Form app</description>
<property name="debug" value="true" overwrite="false"/>
<target name="clean" description="Remove all generated files">
<delete dir="build"/>
</target>
<target name="build" description="Compile the source" depends="clean">
<mkdir dir="build"/>
<csc target="exe" output="build\MyForm.exe" debug="${debug}" verbose="true">
<resources>
<include name="app\resources\*.wav" />
</resources>
<sources>
<include name="app\MyForm.cs"/>
</sources>
</csc>
</target>
</project>