Prevent command window showing when NAnt compiling windows forms application
Posted
by HollyStyles
on Stack Overflow
See other posts from Stack Overflow
or by HollyStyles
Published on 2010-04-01T21:40:59Z
Indexed on
2010/04/01
21:43 UTC
Read the original article
Hit count: 518
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>
© Stack Overflow or respective owner