Search code examples
templatesxamarinmonodevelopadd-inxamarin-studio

Simple Xamarin Studio add-in empty project template issues


I'm trying to create simple project template add-in in Xamarin Studio using "Addin Maker" addin (version 1.3.2). Addin project reference Monodevelop.Addins package (version 0.3.9).

I have simple Manifest.addin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ExtensionModel>

    <Runtime>
        <Import file="Templates/EmptyTemplate.xpt.xml"/>
    </Runtime>

    <Extension path="/MonoDevelop/Ide/ProjectTemplates">
        <ProjectTemplate id="EmptyTemplate" file="Templates/EmptyTemplate.xpt.xml"/>
    </Extension>
</ExtensionModel>

EmptyTemplate.xpt.xml:

<?xml version="1.0"?>
<Template>
    <TemplateConfiguration>
        <_Name>Test</_Name>
        <Category>crossplat/app/forms</Category>
    </TemplateConfiguration>
    <Actions>
    </Actions>
    <Combine name="test" directory=".">
        <Options>
            <StartupProject>test</StartupProject>
        </Options>
        <Project name="test" directory=".">
            <References>
            </References>
            <Packages>
            </Packages>
            <Files>
            </Files>
        </Project>
    </Combine>
</Template>

The add-in can be installed, without issues, into XS using launch/debug addin project or by creating mpack file in the terminal. Unfortunately my test project template is not visible under Multiplatform/App/Xamarin.Forms or Other/Miscellaneous/Generis New Project dialog.

When launching New Project dialog following entry can be found in the log:

Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/BackendBindings/MonoDevelop.VBNetBinding.dll [External]
INFO [2017-02-20 13:16:17Z]: Add-in loaded: MonoDevelop.ILAsmBinding
INFO [2017-02-20 13:16:17Z]: Add-in loaded: test.test
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/BackendBindings/ILAsmBinding.dll [External]

Plugin is also visible in XS addin manager under IDE Extensions section.

What is wrong with this simple template add-in?


Solution

  • 1) In your Manifest.addin.xml remove the <Runtime></Runtime> section.

    2) Since you are using "file=" references for your templates make sure that the Build Action of those template files are set to AddinFile

    Example Properties/Manifest.addin.xml

    <?xml version="1.0"?>
    <ExtensionModel>
        <Extension path="/MonoDevelop/Ide/ProjectTemplates">
            <ProjectTemplate id="RealmEmptyProject" file="templates/PsEmptyProject.xpt.xml" />
        </Extension>
    </ExtensionModel>
    

    Example Template:

    <?xml version="1.0" encoding="UTF-8"?>
    <Template Originator="SushiHangover">
        <TemplateConfiguration>
            <Icon>md-project</Icon>
            <LanguageName>C#</LanguageName>
            <_Name>Realm (Viper) Project</_Name>
            <Category>other/net/general</Category>
            <_Description>Creates an empty Realm Database Viper (MVVM-hybrid) project</_Description>
            <DefaultFilename>RealmViperProject</DefaultFilename>
            <GroupId>md-realm-project</GroupId>
        </TemplateConfiguration>
    
        <Combine name="${ProjectName}" directory=".">
            <Project name="${ProjectName}" directory=".">
                <References>
                    <Reference type="Package" refto="System" LocalCopy="false" SpecificVersion="true" />
                </References>
                <Packages>
                    <package id="Realm" />
                </Packages>
            </Project>
        </Combine>
    </Template>
    

    enter image description here