Click here to Skip to main content
12,819,019 members (25,647 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 21 Oct 2010

Monodevelop: Howto add a WinForm project and file template

, 21 Oct 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
MonoDevelop 2.4 adding custom WinForm project and file templates

I am running MonoDevelop 2.4 on my acer aspire one x150 netbook running Ubuntu 9.04 (Jaunty).

From time to time I needed to write and run little test applications in C#. As I am alsos running another PC with Visual Studio 2005 and 2008, I like these for providing me a WinForm template, so I dont have to start from scratch.

Unfortunately MonoDevelop does not come with a WinForm template and I searched the internet on how to extend the templates provided by MonoDevelop to add a WinForm template. Although I found some resources on how to add templates to MonoDevelop, none of them worked as described.

Adding a template by using addins directory

Some sources state you can add templates by creating two files within the MonoDevelop home dir. For example adding HelloTemplate.xpt.xml and MyTemplates.addin.xml to “~/.config/MonoDevelop/addins”. I tried this approach, but it did not work as a WinForm project template.

Adding a template by using a packed template

Similar to the previous attempt but using mdtool to pack the files:
mdtool setup pack addins/addin.xml -d:addins
mdtool setup rep-build addins
where you finally get a mpack file with your xml template files. Unfortunately this did also not work for project templates.

Adding a template to the sources and recompile

As I already had the MonoDevelop sources as I have compiled and installed MonoDevelop 2.4 from sources, I looked for the existing templates and added my WinForm project and file template.

Screenshot Start New WinForm project

Screenshot Add New WinForm file

The source templates for CSharp are located on my netbook at: “/usr/local/src/monodevelop-2.4/src/addins/CSharpBinding/templates”. The Makefile references the template files in this directory. I had to add two template files to the directory and to the Makefile and the file CSharpBinding.add.xml. Then I did a make within the directory /usr/local/src/monodevelop-2.4/src/addins/CSharpBinding and then a “sudo make install” and finally got my WinForm project and file template available in MonoDevelop.


RES = \
    CSharpBinding.addin.xml \
    gtk-gui/gui.stetic \
    gtk-gui/objects.xml \
    icons/C\#.FileIcon \
    icons/csharp-icon-32.png \
    icons/csharp-project-16.png \
    md1format.xml \
    MonoCSharpPolicy.xml \
    MonoDevelop.CSharp.Formatting/CSharpFormattingPolicy.xml \
    templates/AssemblyInfo.xft.xml \
    templates/ConsoleProject.xpt.xml \
    templates/WinFormProject.xpt.xml \
    templates/EmptyCSharpFile.xft.xml \
    templates/EmptyFormCSharpFile.xft.xml \
    templates/EmptyProject.xpt.xml \
    templates/GtkSharp2Project.xpt.xml \
    templates/GtkSharp2ProjectMac.xpt.xml \


<Extension path = "/MonoDevelop/Ide/FileTemplates">
    <FileTemplate id = "CSharpEmptyFile" resource = "EmptyCSharpFile.xft.xml"/>
    <FileTemplate id = "CSharpEmptyFormFile" resource = "EmptyFormCSharpFile.xft.xml"/>
    <FileTemplate id = "CSharpAssemblyInfo" resource = "AssemblyInfo.xft.xml"/>

The new files WinFormProject.xpt.xml and EmptyFormCSharpFile.xft.xml are simply based on the Console project template and the EmptyFile template files. I just added some code.


    <!-- Template Content -->
    <Combine name = "${ProjectName}" directory = ".">


        <_Name>Empty WinForm File</_Name>

These templates just a simple Form constructor and add a button and a click event handler. You may change the code to your need.

Attached are the complete new files and patch files for Makefile and CSharpBinding.addin.xml and the changed compiled files: DOWNLOAD:MonoDevelop 2.4 WinForm Templates - (Hits: 0, size: 255.45 kB)

<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionI think your package is missing the missing file Pin
Wang Chun Hsun15-Nov-15 23:27
memberWang Chun Hsun15-Nov-15 23:27 
GeneralMy vote of 4 Pin
fmaeseele21-Oct-10 5:55
memberfmaeseele21-Oct-10 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 21 Oct 2010
Article Copyright 2010 by hjgode
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid