Wednesday, November 2, 2016

VSIX: Get list of configurations for a project


var solution = VsixHelper.Ide.Solution;
var projects = solution.GetProjects();

foreach (var project in projects)
{
    System.Diagnostics.Debug.WriteLine("*** {0}", project.Name);

    var configurations = project.GetConfigurations();

    foreach (var configuration in configurations)
    {
        System.Diagnostics.Debug.WriteLine("{0}", configuration.ConfigurationName);
    }
}


namespace Vurdalakov
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using EnvDTE80;
    using EnvDTE;
    using Microsoft.VisualStudio.Shell;

    public static class VsixHelper
    {
        public static Configuration[] GetConfigurations(this Project project)
        {
            if ((null == project) || (null == project.ConfigurationManager))
            {
                return new Configuration[0];
            }

            var configurations = new List();

            for (int i = 1; i <= project.ConfigurationManager.Count; i++)
            {
                configurations.Add(project.ConfigurationManager.Item(i));
            }

            return configurations.ToArray();
        }
    }
}

No comments:

Post a Comment