//--------------------------------------------------------------------- static DynamicVCConfiguration ComputeConfiguration( ExtendedProject project, SolutionContext context, ref string error) { var configurations = project.Configurations; var configuration = configurations.FirstOrDefault( c => c.ConfigurationName == context.ConfigurationName && c.PlatformName == context.PlatformName); if (configuration == null) { var builder = new StringBuilder(); builder.AppendLine(string.Format("Cannot find a configuration for the project {0}", project.UniqueName)); builder.AppendLine(string.Format(" - Solution: configuration: {0} platform: {1}", context.ConfigurationName, context.PlatformName)); foreach (var config in configurations) { builder.AppendLine(string.Format(" - Project: configuration: {0} platform: {1}", config.ConfigurationName, config.PlatformName)); } error = builder.ToString(); return(null); } return(configuration); }
//--------------------------------------------------------------------- public DynamicVCConfiguration FindConfiguration( SolutionConfiguration2 activeConfiguration, ExtendedProject project) { string error; var configuration = ComputeConfiguration(activeConfiguration, project, out error); return(configuration); }
//--------------------------------------------------------------------- public DynamicVCConfiguration GetConfiguration( SolutionConfiguration2 activeConfiguration, ExtendedProject project) { string error; var configuration = ComputeConfiguration(activeConfiguration, project, out error); if (configuration == null) { throw new VSPackageException(error); } return(configuration); }
//--------------------------------------------------------------------- SolutionContext ComputeContext( SolutionConfiguration2 activeConfiguration, ExtendedProject project, ref string error) { var contexts = activeConfiguration.SolutionContexts.Cast <SolutionContext>(); var context = contexts.FirstOrDefault(c => c.ProjectName == project.UniqueName); if (context == null) { error = string.Format("Cannot find {0} in project contexts. " + "Please check your solution Configuration Manager.", project.UniqueName); return(null); } return(context); }
//--------------------------------------------------------------------- DynamicVCConfiguration ComputeConfiguration( SolutionConfiguration2 activeConfiguration, ExtendedProject project, out string error) { error = null; var context = ComputeContext(activeConfiguration, project, ref error); if (context == null) { return(null); } if (!context.ShouldBuild) { error = string.Format(ProjectNotMarkedAsBuildError, project.UniqueName); return(null); } return(ComputeConfiguration(project, context, ref error)); }