예제 #1
0
        /// <summary>
        /// Generates the solution file
        /// </summary>
        public void Generate()
        {
            const string testProjectNode   = "{6181E5C5-1B34-46C3-9917-0E6779125067}";
            const string solutionItemsNode = "{9163c076-18a2-46f8-a018-d225f8020b4f}";

            output.WriteLine("Microsoft Visual Studio Solution File, Format Version 12.00");
            output.WriteLine("# Visual Studio 2012");

            var testProjects   = new HashSet <TestProject>(projects.OfType <TestProject>());
            var startupProject = projects.FirstOrDefault(project => project.Type == ProjectType.Executable);

            if (startupProject != null)
            {
                GenerateProjectSection(startupProject);
            }

            if (testProjects.Count > 0)
            {
                output.WriteLine("Project(\"{{2150E333-8FDC-42A3-9474-1A3956D46DE8}}\") = \"Tests\", \"Tests\", \"{0}\"", testProjectNode);
                output.WriteLine("EndProject");
            }

            foreach (var project in projects)
            {
                if (project != startupProject)
                {
                    GenerateProjectSection(project);
                }
            }

            GenerateSolutionItems(solutionItemsNode);

            output.WriteLine("Global");
            output.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
            output.WriteLine("\t\tBari|Bari = Bari|Bari");
            output.WriteLine("\tEndGlobalSection");
            output.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");

            foreach (var project in projects)
            {
                GenerateProjectConfiguration(project);
            }

            output.WriteLine("\tEndGlobalSection");
            output.WriteLine("\tGlobalSection(SolutionProperties) = preSolution");
            output.WriteLine("\t\tHideSolutionNode = FALSE");
            output.WriteLine("\tEndGlobalSection");

            output.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
            foreach (var testProject in testProjects)
            {
                string projectGuid = projectGuidManagement.GetGuid(testProject).ToString("B").ToUpperInvariant();
                output.WriteLine("\t\t{0} = {1}", projectGuid, testProjectNode);
            }
            output.WriteLine("\tEndGlobalSection");

            output.WriteLine("EndGlobal");
        }
예제 #2
0
        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Condition", " '$(Configuration)|$(Platform)' == 'Bari|Bari' ");
            WriteConfigurationSpecificPart(writer, project);
            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");

            // Writing out configuration specific part to the non conditional block as well
            WriteConfigurationSpecificPart(writer, project);

            writer.WriteElementString("OutputType", GetOutputType(project.Type));
            writer.WriteElementString("AssemblyName", project.Name);
            writer.WriteElementString("ProjectGuid", projectGuidManagement.GetGuid(project).ToString("B"));

            CsharpProjectParameters parameters = project.GetInheritableParameters <CsharpProjectParameters, CsharpProjectParametersDef>("csharp");

            parameters.FillProjectSpecificMissingInfo(project);
            parameters.ToCsprojProperties(writer);

            WriteAppConfig(writer, project);
            if (!WriteWin32Resource(writer, project))
            {
                WriteManifest(writer, project);
                WriteApplicationIcon(writer, project, parameters);
            }

            writer.WriteEndElement();
        }
예제 #3
0
        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            writer.WriteStartElement("ItemGroup");

            foreach (var refPath in context.References)
            {
                if (((string)refPath).StartsWith("SLN!"))
                {
                    var moduleAndprojectName = ((string)refPath).Substring(4);
                    var parts       = moduleAndprojectName.Split('#');
                    var moduleName  = parts[0];
                    var projectName = parts[1];

                    var referredProject = Suite.GetModule(moduleName).GetProjectOrTestProject(projectName);

                    if (referredProject.Type == ProjectType.StaticLibrary)
                    {
                        writer.WriteStartElement("ProjectReference");
                        writer.WriteAttributeString("Include",
                                                    ToProjectRelativePath(project, Path.Combine(Suite.SuiteRoot.GetRelativePath(referredProject.RootDirectory), "cpp", projectName + ".vcxproj"), "cpp"));
                        writer.WriteElementString("Project", projectGuidManagement.GetGuid(project).ToString("B"));
                        writer.WriteEndElement();
                    }
                }
            }

            writer.WriteEndElement();
        }
예제 #4
0
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            // TODO: merge common code with C# PropertiesSection

            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Condition", " '$(Configuration)|$(Platform)' == 'Bari|Bari' ");
            WriteConfigurationSpecificPart(writer, project);
            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");
            WriteConfigurationSpecificPart(writer, project);

            writer.WriteElementString("OutputType", GetOutputType(project.Type));
            writer.WriteElementString("AssemblyName", project.Name);
            writer.WriteElementString("ProjectGuid", projectGuidManagement.GetGuid(project).ToString("B"));

            FsharpProjectParameters parameters = project.HasParameters("fsharp")
                                         ? project.GetParameters <FsharpProjectParameters>("fsharp")
                                         : new FsharpProjectParameters(Suite);

            parameters.FillProjectSpecificMissingInfo(project);
            parameters.ToFsprojProperties(writer);

            writer.WriteEndElement();
        }
예제 #5
0
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            var platform = platformManagement.GetDefaultPlatform(project);
            var cliMode  = project.GetCLIMode();

            writer.WriteStartElement("ItemGroup");
            writer.WriteAttributeString("Label", "ProjectConfigurations");
            writer.WriteStartElement("ProjectConfiguration");
            writer.WriteAttributeString("Include", string.Format("Bari|{0}", platform));
            writer.WriteElementString("Configuration", "Bari");
            writer.WriteElementString("Platform", platform);
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Label", "Globals");
            writer.WriteElementString("ProjectGuid", projectGuidManagement.GetGuid(project).ToString("B"));

            if (cliMode == CppCliMode.Disabled)
            {
                writer.WriteElementString("Keyword", "Win32Proj");
            }
            else
            {
                VCppProjectCompilerParameters compilerParameters = project.GetInheritableParameters <VCppProjectCompilerParameters, VCppProjectCompilerParametersDef>("cpp-compiler");
                compilerParameters.WriteGlobalProperties(writer);

                writer.WriteElementString("Keyword", "ManagedCProj");
                writer.WriteElementString("RootNamespace", project.Name);
            }

            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Condition", string.Format("'$(Configuration)|$(Platform)' == 'Bari|{0}' ", platform));
            writer.WriteAttributeString("Label", "Configuration");
            WriteHighLevelConfigurationSpecificPart(writer, project);
            writer.WriteEndElement();

            writer.WriteStartElement("Import");
            writer.WriteAttributeString("Project", @"$(VCTargetsPath)\Microsoft.Cpp.props");
            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Condition", string.Format("'$(Configuration)|$(Platform)' == 'Bari|{0}' ", platform));
            WriteConfigurationSpecificPart(writer, project);
            writer.WriteEndElement();

            writer.WriteStartElement("ItemDefinitionGroup");
            writer.WriteAttributeString("Condition", string.Format(" '$(Configuration)|$(Platform)' == 'Bari|{0}' ", platform));
            WriteMIDLParameters(writer, project);
            WriteCompilerParameters(writer, project);
            WriteLinkerParameters(writer, project);
            WriteManifestParameters(writer, project);
            WriteResourceCompilerParameters(writer, project);
            writer.WriteEndElement();
        }
예제 #6
0
        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            writer.WriteStartElement("ItemGroup");

            foreach (var refPath in context.References.Where(IsValidReference))
            {
                if (IsSolutionReference(refPath))
                {
                    var moduleAndprojectName = ((string)refPath).Substring(4);
                    var parts       = moduleAndprojectName.Split('#');
                    var moduleName  = parts[0];
                    var projectName = parts[1];

                    var referredProject = Suite.GetModule(moduleName).GetProjectOrTestProject(projectName);

                    if (referredProject.Type == ProjectType.Library ||
                        referredProject.Type == ProjectType.Executable)
                    {
                        writer.WriteComment("Project reference " + projectGuidManagement.GetGuid(referredProject));
                        writer.WriteStartElement("Reference");
                        writer.WriteAttributeString("Include", projectName);
                        writer.WriteElementString("HintPath",
                                                  ToProjectRelativePath(project,
                                                                        Path.Combine(Suite.SuiteRoot.GetRelativePath(targetDir), referredProject.Module.Name,
                                                                                     referredProject.Name + ".dll"), sourceSetName));
                        writer.WriteElementString("SpecificVersion", "False");
                        writer.WriteEndElement();
                    }
                }
                else
                {
                    writer.WriteStartElement("Reference");
                    if (IsGACReference(refPath))
                    {
                        var assemblyName = ((string)refPath).Substring(4);
                        writer.WriteAttributeString("Include", assemblyName);
                    }
                    else
                    {
                        string relativePath = ToProjectRelativePath(project, Path.Combine("target", refPath), sourceSetName);

                        writer.WriteAttributeString("Include", Path.GetFileNameWithoutExtension(relativePath));
                        writer.WriteElementString("HintPath", relativePath);
                        writer.WriteElementString("SpecificVersion", "False");
                        writer.WriteElementString("Private", "True");
                    }
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }