0

I'm writing a C++ Project template in VS 2010 using the Custom Wizard technique.

In the default.js, the file which holds the behind JavaScript code, I want to take the current generated project, and locate it in an existing VS solution, in a specific "apps" subfolder.

I have a C# working code which does the above, but I have to rewrite it in JavaScript.

My C# code is:

Projects ps = solution.Projects;


var item = ps.GetEnumerator();
while (item.MoveNext())
{
      var project = item.Current as Project;
      string name = project.Name;
      if (name == "apps")
      {
         SolutionFolder folder = (SolutionFolder)project.Object;
         p = folder.AddFromFile(newProjDir + "\\" + projName + ".vcxproj");
      }
}

In JavaScript, I wrote:

var ps = Solution.Projects;

But now I don't succeed to iterate over the projects, as I did in c#.

When I'm trying to write in the JS file:

var item = ps.GetEnumerator();

I'm getting the run time error:

Object doesn't support this property or method

Do you know about any way to iterate over the Projects collection? Is there a JS function which behaves like GetEnumerator()?

user1835297
  • 1,059
  • 2
  • 12
  • 24

2 Answers2

0

As you of course know, JS is a client side language.

You cannot get information from the server (like Solution.Projects).

But you can write a web service and use it from the your web page to get the information.

Andrei
  • 3,086
  • 2
  • 19
  • 24
  • 1
    The OP is asking in the context of design time access to the automation model of Visual Studio. No servers, webservices or webpages are involved. You totally missed the point of the question. Please remove it. – rene Apr 27 '14 at 10:22
0

I found my way:

for (var i = 1; i <= solution.Projects.Count; i++) 
        {
            if(Solution.Projects.Item(i).Name == "apps")        
            {
                appsFolder = Solution.Projects.Item(i);
                project = appsFolder.Object.AddFromFile(newProjectPath + "\\" + strProjectName + "\\" + strProjectName + ".vcxproj");
                break;
            }
        }

Thanks you all for trying help :)

user1835297
  • 1,059
  • 2
  • 12
  • 24