开发者

VisualStudio ItemTemplate installation Error: Value does not fall within the expected range

I have written a handful of very simple Visual Studio c# Item Templates. The templates are based on the VisualStudio 2010 SDK SP1. All works fine except one item template;

After some minor changes I've tried to apply the template again to the already existing but again empty Unit-test project and got the following error: "Value does not fall within the expected range." The error also occurred in some of the other projects of the same solution.

A revert of the changes in the item-template result in the same error. Something seems to be broken... After a lot of rebuilds and uninstallAddIn-closeVS-installAddIn-restartVS I removed the exiting Unit-test project and created a new one with exactly the same references as the old not working one and all works fine.

Here's the template.vstemplate file content:

<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Tests</Name>
    <Description>No description available</Description>
    <Icon>TestsItems.ico</Icon>
    <TemplateID>662c9d07-0e83-4d4d-87d7-1fcc13667eb8</TemplateID>
    <ProjectType>CSharp</ProjectType>
    <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
    <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
    <DefaultName>EntityClass.cs</DefaultName>
  </TemplateData>
  <TemplateContent>
        <References>
            <Reference>
                <Assembly>System</Assembly>
            </Reference>
        </References>

    <ProjectItem TargetFileName="Controller/$fileinputname$ControllerTest.cs" ReplaceParameters="true">Controller/ControllerTest.cs</ProjectItem>
    <ProjectItem TargetFileName="Models/$fileinputname$RepositoryTest.cs" ReplaceParameters="true">Models/RepositoryTest.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

Here is the content of one of the class files

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NUnit.Framework;
using $rootnamespace$.Controllers;
using $rootnamespace$.Models;
using Assert = NUnit.Framework.Assert;
using Ign开发者_如何学编程oreAttribute = Microsoft.VisualStudio.TestTools.UnitTesting.IgnoreAttribute;

namespace $rootnamespace$.Tests.Controllers
{
    /// <summary>
    /// Testclass for the $fileinputname$Controller
    /// </summary>
    [TestClass]
    public class $fileinputname$ControllerTest
    {

    }
}

One additional note: The C# Item Template Project is beeing consumed by a VSIX Project.

Does anyone know more about this error and why it occurs?


In my case the answer was quite simple; the error occurred due to bad placeholder names.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜