Example #1
0
        private SolutionProject GetSolutionProjectEntryFrom(Project project, SolutionFileInfo solutionFileInfo)
        {
            SolutionProject toReturn = new SolutionProject(project.Guid, project.TypeGuid, project.Name, project.RelativePath, project.Sections, project.Dependencies);

            SetAdditionalProjectProperties(toReturn, project.Guid, solutionFileInfo, config =>
            {
                if (!toReturn.ConfigurationPlatformMapping.TryGetValue(config.SolutionConfig, out ProjectConfigurationPlatformMapping mapping))
                {
                    toReturn.ConfigurationPlatformMapping.Add(config.SolutionConfig, mapping = new ProjectConfigurationPlatformMapping());
                }
                mapping.ConfigurationPlatform = config.ProjectConfig;

                switch (config.Property)
                {
                case "ActiveCfg":
                    break;

                case "Build.0":
                    mapping.EnabledForBuild = true;
                    break;
                }
            });

            return(toReturn);
        }
Example #2
0
        private void WriteProject(TemplatedWriter solutionWriter, Guid projectGuid, SolutionProject project)
        {
            TemplatedWriter projectWriter = solutionWriter.CreateWriterFor(ProjectTemplate)
                                            .Write(ProjectTemplate_ProjectTypeGuidToken, project.TypeGuid)
                                            .Write(ProjectTemplate_NameToken, project.Name)
                                            .Write(ProjectTemplate_RelativePathToken, project.RelativePath.IsAbsoluteUri ? project.RelativePath.LocalPath : project.RelativePath.AsRelativePath())
                                            .Write(ProjectTemplate_GuidToken, projectGuid);

            if (project.Dependencies.Count > 0)
            {
                TemplatedWriter dependencyWriter = projectWriter.CreateWriterFor(ProjectTemplate_ProjectSection);

                foreach (Guid dependency in project.Dependencies)
                {
                    dependencyWriter
                    .CreateWriterFor(ProjectTemplate_ProjectSection_DependencyTemplate)
                    .Write(ProjectTemplate_ProjectSection_DependencyTemplate_DependencyGuidToken, dependency);
                }
            }

            foreach (ConfigurationPlatformPair configPlatform in ConfigurationPlatforms)
            {
                ProjectConfigurationPlatformMapping mapping = project.ConfigurationPlatformMapping[configPlatform];

                WriteConfigurationProperty(solutionWriter, projectGuid, configPlatform, "ActiveCfg", mapping.ConfigurationPlatform);
                if (mapping.EnabledForBuild)
                {
                    WriteConfigurationProperty(solutionWriter, projectGuid, configPlatform, "Build.0", mapping.ConfigurationPlatform);
                }

                if (mapping.AdditionalPropertyMappings != null)
                {
                    foreach (KeyValuePair <string, ConfigurationPlatformPair> propertyPair in mapping.AdditionalPropertyMappings)
                    {
                        if (KnownConfiguationPlatformProperties.Contains(propertyPair.Key))
                        {
                            logger?.LogError(nameof(TemplatedSolutionExporter), $"Can't export '{propertyPair.Key}' as a property for project '{project.Name}' {configPlatform.Configuration}|{configPlatform.Platform}, as it's a known property.");
                        }
                        else
                        {
                            WriteConfigurationProperty(solutionWriter, projectGuid, configPlatform, propertyPair.Key, propertyPair.Value);
                        }
                    }
                }
            }

            WriteExtraSections(projectWriter, project.AdditionalSections, KnownProjectSectionNames, ExtraProjectSectionTemplate, t => t == SectionType.PreSection ? "preProject" : "postProject");
        }