예제 #1
0
 /// <summary>
 /// Logs a message with the given priority.
 /// </summary>
 /// <param name="messageLevel">The message priority at which the specified message is to be logged.</param>
 /// <param name="message">The message to be logged.</param>
 /// <remarks>
 /// The actual logging is delegated to the underlying task.
 /// </remarks>
 protected void Log(Level messageLevel, string message)
 {
     if (SolutionTask != null)
     {
         SolutionTask.Log(messageLevel, message);
     }
 }
예제 #2
0
 /// <summary>
 /// Logs a message with the given priority.
 /// </summary>
 /// <param name="messageLevel">The message priority at which the specified message is to be logged.</param>
 /// <param name="message">The message to log, containing zero or more format items.</param>
 /// <param name="args">An <see cref="object" /> array containing zero or more objects to format.</param>
 /// <remarks>
 /// The actual logging is delegated to the underlying task.
 /// </remarks>
 protected void Log(Level messageLevel, string message, params object[] args)
 {
     if (SolutionTask != null)
     {
         SolutionTask.Log(messageLevel, message, args);
     }
 }
예제 #3
0
        public ConfigurationSettings(ManagedProjectBase project, XmlElement elemConfig, DirectoryInfo outputDir) : base(project)
        {
            _settings = new ArrayList();
            if (outputDir == null)
            {
                _relativeOutputDir = elemConfig.Attributes["OutputPath"].Value;
                if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
                {
                    _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar;
                }
                _outputDir = new DirectoryInfo(FileUtils.CombinePaths(
                                                   project.ProjectDirectory.FullName,
                                                   _relativeOutputDir));
            }
            else
            {
                _relativeOutputDir = outputDir.FullName;
                if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
                {
                    _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar;
                }
                _outputDir = outputDir;
            }

            _name = elemConfig.GetAttribute("Name");

            string documentationFile = elemConfig.GetAttribute("DocumentationFile");

            if (!StringUtils.IsNullOrEmpty(documentationFile))
            {
                // to match VS.NET, the XML Documentation file will be output
                // in the project directory, and only later copied to the output
                // directory
                string xmlDocBuildFile = FileUtils.CombinePaths(project.ProjectDirectory.FullName,
                                                                documentationFile);

                // add compiler option to build XML Documentation file
                _settings.Add(@"/doc:""" + xmlDocBuildFile + @"""");

                // make sure the output directory for the doc file exists
                if (!Directory.Exists(Path.GetDirectoryName(xmlDocBuildFile)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(xmlDocBuildFile));
                }

                // add built documentation file as extra output file
                ExtraOutputFiles[xmlDocBuildFile] = Path.GetFileName(xmlDocBuildFile);
            }

            // determine whether we need to register project output for use with
            // COM components
            _registerForComInterop = string.Compare(elemConfig.GetAttribute("RegisterForComInterop"),
                                                    "true", true, CultureInfo.InvariantCulture) == 0;

            SolutionTask.Log(Level.Debug, "Project: {0} Relative Output Path: {1} Output Path: {2} Documentation Path: {3}",
                             Project.Name, _relativeOutputDir, _outputDir.FullName, documentationFile);

            Hashtable htStringSettings  = new Hashtable();
            Hashtable htBooleanSettings = new Hashtable();

            htStringSettings["BaseAddress"] = "/baseaddress:{0}";

            // is only supported by csc (all versions) and vbc (2.0 or higher)
            htStringSettings["FileAlignment"] = "/filealign:{0}";

            htStringSettings["DefineConstants"] = "/define:{0}";

            switch (project.Type)
            {
            case ProjectType.CSharp:
                htStringSettings["WarningLevel"]               = "/warn:{0}";
                htStringSettings["NoWarn"]                     = "/nowarn:{0}";
                htBooleanSettings["IncrementalBuild"]          = "/incremental";
                htBooleanSettings["AllowUnsafeBlocks"]         = "/unsafe";
                htBooleanSettings["CheckForOverflowUnderflow"] = "/checked";
                break;

            case ProjectType.JSharp:
                htStringSettings["WarningLevel"]      = "/warn:{0}";
                htStringSettings["NoWarn"]            = "/nowarn:{0}";
                htBooleanSettings["IncrementalBuild"] = "/incremental";
                break;

            case ProjectType.VB:
                htStringSettings["DefineDebug"]          = "/d:DEBUG={0}";
                htStringSettings["DefineTrace"]          = "/d:TRACE={0}";
                htBooleanSettings["RemoveIntegerChecks"] = "/removeintchecks";
                break;
            }

            htBooleanSettings["DebugSymbols"]          = "/debug";
            htBooleanSettings["TreatWarningsAsErrors"] = "/warnaserror";
            htBooleanSettings["Optimize"] = "/optimize";

            foreach (DictionaryEntry de in htStringSettings)
            {
                string value = elemConfig.GetAttribute(de.Key.ToString());
                if (!StringUtils.IsNullOrEmpty(value))
                {
                    switch (de.Key.ToString())
                    {
                    case "BaseAddress":
                        // vbc and vjs expect the base address to be specified
                        // as a hexadecimal number, csc supports decimal,
                        // hexadecimal, or octal number
                        //
                        // so use hexadecimal as all compiler support this
                        uint intvalue = Convert.ToUInt32(value, CultureInfo.InvariantCulture);
                        value = "0x" + intvalue.ToString("x", CultureInfo.InvariantCulture);
                        break;

                    case "DefineConstants":
                        // vbc fails when the symbol contains spaces
                        value = value.Replace(" ", string.Empty);
                        break;
                    }
                    _settings.Add(string.Format(CultureInfo.InvariantCulture, de.Value.ToString(), value));
                }
            }

            foreach (DictionaryEntry de in htBooleanSettings)
            {
                string value = elemConfig.GetAttribute(de.Key.ToString());
                if (string.Compare(value, "true", true, CultureInfo.InvariantCulture) == 0)
                {
                    _settings.Add(de.Value.ToString() + "+");
                }
                else if (string.Compare(value, "false", true, CultureInfo.InvariantCulture) == 0)
                {
                    _settings.Add(de.Value.ToString() + "-");
                }
            }

            _settings.Add(string.Format(CultureInfo.InvariantCulture, "/out:\"{0}\"", BuildPath));
        }