0

I'm trying to create a WebApi Project in a powershell script using DTE.

When I try to pass the folder name of the project template, I get the following error.

PS> $projTplPath = $dte.Solution.GetProjectTemplate("WebApiApplicationProjectTemplatev4.0", "CSharp")
Exception calling "GetProjectTemplate" with "2" argument(s): "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"
At line:1 char:1
+ $projTplPath = $dte.Solution.GetProjectTemplate("WebApiApplicationProjectTemplat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

If I try this same method with a different, more simple, project template name it works fine.

For example:

PS> $projTplPath = $dte.Solution.GetProjectTemplate("AjaxServerControl", "CSharp")

works no problem. So does creating a ClassLibrary, or ConsoleApplication.

What is the project template name for the WebApi project template? Better yet, were is the list of project template types? I can't seem to find an enum or other such listing on MSDN.

a_arias
  • 3,036
  • 2
  • 21
  • 20
  • First thing I'd do is grab Process Monitor and see what file is actually being looked for. That would help narrow down the possibilities. –  Mar 07 '13 at 22:01
  • @will, Process Monitor is not very helpful here. That one method call generates a lot of noise. I do see it looking in various directories tho. – a_arias Mar 07 '13 at 22:54
  • That's why we have filters. –  Mar 08 '13 at 15:00

1 Answers1

0

I see "WebApiApplicationProjectTemplatev4.1" in my installation.

Here's where I looked: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033

Mike Shepard
  • 17,466
  • 6
  • 51
  • 69