public void WriteTo(Action<SolutionFile> AddFile)
        {
            var guid = Guid.NewGuid();
            var proj_Identifier = "{" + guid.ToString() + "}";

            var proj = new jsc.meta.Library.MVSSolutionFile.ProjectElement
            {
                ProjectFile = SolutionProjectFileNameRelativeToSolution,
                Name = Name,
                Kind = this.Language.Kind,
                Identifier = proj_Identifier
            };

            var projects = new[] { proj };

            AddFile(
                new SolutionFile
                {
                    Name = SolutionFileName,
                    Content = projects.ToSolutionFile().ToString(),
                    Context = this
                }
            );

            #region first project in current solution
            var proj_Content = default(XElement);

            Console.WriteLine("Selecting project template by language");

            if (this.Language is VisualCSharpLanguage)
            {
                Console.WriteLine("Selecting VisualCSharpLanguage");
                proj_Content = VisualStudioTemplates.VisualCSharpProject.Clone();
                //proj_Content = VisualStudioTemplates.VisualCSharpProjectReferences;
            }

            if (this.Language is VisualBasicLanguage)
            {
                Console.WriteLine("Selecting VisualBasicLanguage");
                proj_Content = VisualStudioTemplates.VisualBasicProject.Clone();
            }

            if (this.Language is VisualFSharpLanguage)
            {
                Console.WriteLine("Selecting VisualFSharpLanguage");
                proj_Content = VisualStudioTemplates.VisualFSharpProject.Clone();
            }



            Console.WriteLine(proj_Content.ToString());


            //<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>

            proj_Content.Elements("PropertyGroup").Elements("ProjectGuid").ReplaceContentWith(proj_Identifier);
            proj_Content.Elements("PropertyGroup").Elements("RootNamespace").ReplaceContentWith(Name);
            proj_Content.Elements("PropertyGroup").Elements("AssemblyName").ReplaceContentWith(Name);


            // how many item groups are there that have references?
            Console.WriteLine("Looking for ItemGroup for Referenes...");
            var ItemGroupReferenes = proj_Content.Elements("ItemGroup").Where(k => k.Elements("Reference").Any()).Single();
            Console.WriteLine("ItemGroupReferenes...");
            UpdateReferences(ItemGroupReferenes);

            // 
            var ItemGroupForCompile = proj_Content.Elements("ItemGroup").Where(k => k.Elements("Compile").Any()).Single();
            ItemGroupForCompile.RemoveAll();

            // new operator is the new call opcode? :)
            var builder = new StockUltraApplicationBuilder(AddFile, this, ItemGroupForCompile,
                StartupType =>
                {
                    proj_Content.Elements("PropertyGroup").Elements("StartupObject").ReplaceContentWith(

                        StartupType.FullName
                    );
                }
            );


            // The default XML namespace of the project must be the MSBuild XML namespace. 
            // If the project is authored in the MSBuild 2003 format, 
            // please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 
            // to the <Project> element. 
            // If the project has been authored in the old 1.0 or 1.2 format, 
            // please convert it to MSBuild 2003 format.



            var fproj = new SolutionFile
                {
                    Name = SolutionProjectFileName,
                    Context = this
                };

            fproj.WriteXElement(
                XElement.Parse(
                proj_Content.ToString().Replace(
                // dirty little hack
                // http://stackoverflow.com/questions/461251/add-xml-namespace-attribute-to-3rd-party-xml

                        "<Project ToolsVersion=\"3.5\" DefaultTargets=\"Build\">",
                        "<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" >"
                    )
                    )
            );


            AddFile(fproj);





            #endregion

        }
예제 #2
0
        public void WriteTo(Action <SolutionFile> AddFile)
        {
            var guid            = Guid.NewGuid();
            var proj_Identifier = "{" + guid.ToString() + "}";

            var proj = new jsc.meta.Library.MVSSolutionFile.ProjectElement
            {
                ProjectFile = SolutionProjectFileNameRelativeToSolution,
                Name        = Name,
                Kind        = this.Language.Kind,
                Identifier  = proj_Identifier
            };

            var projects = new[] { proj };

            AddFile(
                new SolutionFile
            {
                Name    = SolutionFileName,
                Content = projects.ToSolutionFile().ToString(),
                Context = this
            }
                );

            #region first project in current solution
            var proj_Content = default(XElement);

            Console.WriteLine("Selecting project template by language");

            if (this.Language is VisualCSharpLanguage)
            {
                Console.WriteLine("Selecting VisualCSharpLanguage");
                proj_Content = VisualStudioTemplates.VisualCSharpProject.Clone();
                //proj_Content = VisualStudioTemplates.VisualCSharpProjectReferences;
            }

            if (this.Language is VisualBasicLanguage)
            {
                Console.WriteLine("Selecting VisualBasicLanguage");
                proj_Content = VisualStudioTemplates.VisualBasicProject.Clone();
            }

            if (this.Language is VisualFSharpLanguage)
            {
                Console.WriteLine("Selecting VisualFSharpLanguage");
                proj_Content = VisualStudioTemplates.VisualFSharpProject.Clone();
            }



            Console.WriteLine(proj_Content.ToString());


            //<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>

            proj_Content.Elements("PropertyGroup").Elements("ProjectGuid").ReplaceContentWith(proj_Identifier);
            proj_Content.Elements("PropertyGroup").Elements("RootNamespace").ReplaceContentWith(Name);
            proj_Content.Elements("PropertyGroup").Elements("AssemblyName").ReplaceContentWith(Name);


            // how many item groups are there that have references?
            Console.WriteLine("Looking for ItemGroup for Referenes...");
            var ItemGroupReferenes = proj_Content.Elements("ItemGroup").Where(k => k.Elements("Reference").Any()).Single();
            Console.WriteLine("ItemGroupReferenes...");
            UpdateReferences(ItemGroupReferenes);

            //
            var ItemGroupForCompile = proj_Content.Elements("ItemGroup").Where(k => k.Elements("Compile").Any()).Single();
            ItemGroupForCompile.RemoveAll();

            // new operator is the new call opcode? :)
            var builder = new StockUltraApplicationBuilder(AddFile, this, ItemGroupForCompile,
                                                           StartupType =>
            {
                proj_Content.Elements("PropertyGroup").Elements("StartupObject").ReplaceContentWith(

                    StartupType.FullName
                    );
            }
                                                           );


            // The default XML namespace of the project must be the MSBuild XML namespace.
            // If the project is authored in the MSBuild 2003 format,
            // please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
            // to the <Project> element.
            // If the project has been authored in the old 1.0 or 1.2 format,
            // please convert it to MSBuild 2003 format.



            var fproj = new SolutionFile
            {
                Name    = SolutionProjectFileName,
                Context = this
            };

            fproj.WriteXElement(
                XElement.Parse(
                    proj_Content.ToString().Replace(
                        // dirty little hack
                        // http://stackoverflow.com/questions/461251/add-xml-namespace-attribute-to-3rd-party-xml

                        "<Project ToolsVersion=\"3.5\" DefaultTargets=\"Build\">",
                        "<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" >"
                        )
                    )
                );


            AddFile(fproj);



            #endregion
        }