Example #1
0
        /// <summary>
        /// Create the targets that copy 'local copy' references to the build dir
        /// </summary>
        /// <param name="solution">the solution being analyzed</param>
        private void WriteCopyRefsTargets(Solution solution)
        {
            // copy the 'copy local' references to the build directory
            ArrayList referenceNames = new ArrayList();

            // get a unique list
            foreach (Project project in solution.GetProjects())
            {
                if (project.CountFiles("Compile") > 0)
                {
                    foreach (Reference reference in project.GetReferences())
                    {
                        if (!referenceNames.Contains(reference.Value))
                        {
                            referenceNames.Add(reference.Value);
                        }
                    }
                }
            }
            // create the copy targets
            foreach (string configurationName in solution.GetConfigurationNames())
            {
                writer.WriteStartElement("target");
                writer.WriteAttributeString("name", string.Concat(Configuration.NantName(configurationName), ".CopyRefs"));
                WriteProperty("build.dir", "${build.basedir}\\" + Configuration.NantName(configurationName));
                foreach (string referenceName in referenceNames)
                {
                    writeCopyRef(referenceName, configurationName);
                }
                writer.WriteEndElement(); // target
            }
        }
Example #2
0
        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();
        }