コード例 #1
0
        //////////////////////////////////////////////////////////////
        /// <summary>
        ///   The constructor reads the properties from the specified
        ///   configuration location.
        /// </summary>
        //////////////////////////////////////////////////////////////

        public PropertiesConfigSupplier(string appname, string path)
        {
            string pname = String.Concat(appname, ".properties");

            if (path != null)
            {
                _propfile = Path.Combine(path, pname);
            }
            else
            {
                _propfile = pname;
            }
            _name  = appname;
            _input = new PropertyFileProcessor(_propfile);
            Load();
        }
コード例 #2
0
ファイル: BuildStamp.cs プロジェクト: samegens/includechecker
        //////////////////////////////////////////////////////////////
        /// <summary>
        ///   Checks to ensure the configuration parameters make
        ///   sense.
        /// </summary>
        /// <param name="taskNode">the node used to initialize the
        /// task</param>
        //////////////////////////////////////////////////////////////

        protected override void InitializeTask(XmlNode taskNode)
        {
            if (!_countfile.Exists)
            {
                throw new BuildException(string.Format("error:  unable to load version information from file '{0}'", _countfile.FullName));
            }

            // figure out what the build count should be
            PropertyFileProcessor pfp = new PropertyFileProcessor(_countfile.FullName);

            pfp.ProcessFile();
            _props = pfp.Properties;

            if (_props.Contains("build.version.project"))
            {
                _name = _props["build.version.project"];
            }
            else
            {
                _name = Project.ProjectName;
            }

            _major    = Int32.Parse(_props["build.version.major"]);
            _minor    = Int32.Parse(_props["build.version.minor"]);
            _release  = _props["build.version.release"];
            _irelease = ParseReleaseNumber(_release);
            _count    = Int32.Parse(_props["build.version.count"]);
            _datestr  = _date.ToString("yyyy-MM-dd hh:mm:ss 'GMT'z");

            if (_countbuild)
            {
                ++_count;
                _bldcount = _count.ToString();
                _props["build.version.count"] = _bldcount;

                if (!_dryrun)
                {
                    StreamWriter sw = new
                                      StreamWriter(_countfile.FullName);
                    sw.Write(_props);
                    sw.Close();
                }
            }
            else if (_import)
            {
                _bldcount = _count.ToString();
            }
            else
            {
                _bldcount = _devname;
            }

            // set the properties in the build
            Properties["build.version.project"]        = _name;
            Properties["build.version.major"]          = _major.ToString();
            Properties["build.version.minor"]          = _minor.ToString();
            Properties["build.version.release"]        = _release;
            Properties["build.version.release-prefix"] = _irelease.ToString();
            Properties["build.version.count"]          = _bldcount;
            Properties["build.version.date"]           = _datestr;

            Log(Level.Verbose, "{0}Major version:    {1}", LogPrefix, _major);
            Log(Level.Verbose, "{0}Minor version:    {1}", LogPrefix, _minor);
            Log(Level.Verbose, "{0}Release version:  {1}", LogPrefix, _release);
            Log(Level.Verbose, "{0}Build number:     {1}", LogPrefix, _bldcount);
            Log(Level.Verbose, "{0}Build date:       {1}", LogPrefix, _datestr);
            Log(Level.Verbose, "");
        }