Beispiel #1
0
        public void WriteStartProject(Project project) {
            this.project = project;

            foreach (Configuration configuration in project.GetConfigurations()) {
                writer.WriteStartElement("target");
                writer.WriteAttributeString("name", project.Name + "." + Configuration.NantName( configuration.Name ));
                depends = null;
                foreach (Project dependency in solution.GetDependencies(project)) {
                    if (depends != null) {
                        depends += ",";
                    }
                    depends += dependency.Name + "." + Configuration.NantName( configuration.Name );
                }
                foreach (Project projectReference in project.GetReferencedProjects()) {
                    if (depends != null) {
                        depends += ",";
                    }
                    depends += projectReference.Name + "." + Configuration.NantName( configuration.Name );
                }
                if (depends != null) {
                    writer.WriteAttributeString("depends", depends);
                }

                WriteProperty("project.name", project.Name);
                WriteProperty("build.dir", "${build.basedir}\\" + Configuration.NantName( configuration.Name ));
                WriteProperty( "slingshot.config", configuration.Name );

                //WriteProperty("directory", Path.GetDirectoryName(project.GetRelativeOutputPathForConfiguration(configuration.Name)));
                WriteProperty("output", "${build.dir}\\" + Path.GetFileName(project.GetRelativeOutputPathForConfiguration(configuration.Name)));
                WriteProperty("debug", configuration.DebugSymbols ? "true" : "false");


                WriteProperty("unsafe", configuration.AllowUnsafeBlocks ? "true" : "false");
                WriteProperty("checked", configuration.CheckForOverflowUnderflow ? "true" : "false");

                WriteProperty("define", configuration.DefineConstants);

                string documentationFile = Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name));

                if (documentationFile != null && documentationFile.Length != 0) {
                    WriteProperty("doc", "${build.dir}\\" + Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name)));
                }
                WriteProperty( "warninglevel", configuration.WarningLevel );
                writer.WriteStartElement("call");
                writer.WriteAttributeString("target", project.Name);
                writer.WriteEndElement(); // call

                writer.WriteEndElement(); // target
            }

            writer.WriteStartElement("target");
            writer.WriteAttributeString("name", project.Name);
        }
        public void WriteStartSolution(Solution solution)
        {
            writer.WriteLine("# Generated by SLiNgshoT <http://injektilo.org/>");
            writer.WriteLine();

            writer.WriteLine("!IFNDEF CFG");
            writer.WriteLine();

            writer.WriteLine("CFG = Debug");

            writer.WriteLine();
            writer.WriteLine("!ENDIF");
            writer.WriteLine();

            bool firstConfig = true;

            foreach (string configurationName in solution.GetConfigurationNames())
            {
                if (firstConfig)
                {
                    writer.Write("!IF");
                    firstConfig = false;
                }
                else
                {
                    writer.Write("!ELSE IF");
                }

                writer.WriteLine(" \"$(CFG)\" == \"{0}\"", configurationName);
                writer.WriteLine();

                foreach (Project project in solution.GetProjects())
                {
                    Configuration configuration = project.GetConfiguration(configurationName);

                    writer.WriteLine(
                        GetProjectName(project) +
                        "_DIRECTORY = " +
                        Path.GetDirectoryName(project.GetRelativeOutputPathForConfiguration(configurationName)));

                    writer.WriteLine(
                        GetProjectName(project) +
                        " = $(" + GetProjectName(project) + "_DIRECTORY)\\" +
                        Path.GetFileName(project.GetRelativeOutputPathForConfiguration(configurationName)));

                    writer.WriteLine(
                        GetProjectName(project) +
                        "_DEBUG = /debug" +
                        (configuration.DebugSymbols ? "+" : "-"));

                    writer.WriteLine(
                        GetProjectName(project) +
                        "_UNSAFE = /unsafe" +
                        (configuration.AllowUnsafeBlocks ? "+" : "-"));

                    writer.Write(GetProjectName(project) + "_DEFINES =");

                    string defineConstants = configuration.DefineConstants;

                    if (defineConstants != null && defineConstants.Length > 0)
                    {
                        writer.Write(" /define:" + defineConstants);
                    }

                    writer.WriteLine();

                    string documentationFile = Path.GetFileName(project.GetRelativePathToDocumentationFile(configurationName));

                    if (documentationFile != null && documentationFile.Length > 0)
                    {
                        writer.WriteLine(
                            GetProjectName(project) +
                            "_DOC = /doc:$(" +
                            GetProjectName(project) +
                            "_DIRECTORY)\\" +
                            documentationFile);
                    }
                    else
                    {
                        writer.WriteLine("{0}_DOC =", GetProjectName(project));
                    }

                    writer.WriteLine();
                }
            }

            writer.WriteLine("!ENDIF");
            writer.WriteLine();

            writer.Write("all:");

            foreach (Project project in solution.GetProjects())
            {
                if (project.CountFiles("Compile") > 0)
                {
                    writer.Write(" $(" + GetProjectName(project) + ")");
                }
            }

            writer.WriteLine();
            writer.WriteLine();
        }
Beispiel #3
0
        public void WriteStartProject(Project project)
        {
            this.project = project;

            foreach (Configuration configuration in project.GetConfigurations())
            {
                writer.WriteStartElement("target");
                writer.WriteAttributeString("name", project.Name + "." + Configuration.NantName(configuration.Name));
                depends = null;
                foreach (Project dependency in solution.GetDependencies(project))
                {
                    if (depends != null)
                    {
                        depends += ",";
                    }
                    depends += dependency.Name + "." + Configuration.NantName(configuration.Name);
                }
                foreach (Project projectReference in project.GetReferencedProjects())
                {
                    if (depends != null)
                    {
                        depends += ",";
                    }
                    depends += projectReference.Name + "." + Configuration.NantName(configuration.Name);
                }
                if (depends != null)
                {
                    writer.WriteAttributeString("depends", depends);
                }

                WriteProperty("project.name", project.Name);
                WriteProperty("build.dir", "${build.basedir}\\" + Configuration.NantName(configuration.Name));
                WriteProperty("slingshot.config", configuration.Name);

                //WriteProperty("directory", Path.GetDirectoryName(project.GetRelativeOutputPathForConfiguration(configuration.Name)));
                WriteProperty("output", "${build.dir}\\" + Path.GetFileName(project.GetRelativeOutputPathForConfiguration(configuration.Name)));
                WriteProperty("debug", configuration.DebugSymbols ? "true" : "false");


                WriteProperty("unsafe", configuration.AllowUnsafeBlocks ? "true" : "false");
                WriteProperty("checked", configuration.CheckForOverflowUnderflow ? "true" : "false");

                WriteProperty("define", configuration.DefineConstants);

                string documentationFile = Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name));

                if (documentationFile != null && documentationFile.Length != 0)
                {
                    WriteProperty("doc", "${build.dir}\\" + Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name)));
                }
                WriteProperty("warninglevel", configuration.WarningLevel);
                writer.WriteStartElement("call");
                writer.WriteAttributeString("target", project.Name);
                writer.WriteEndElement(); // call

                writer.WriteEndElement(); // target
            }

            writer.WriteStartElement("target");
            writer.WriteAttributeString("name", project.Name);
        }