Пример #1
0
        /// <summary>
        /// Creates the versionumber.xml file in the repository.
        /// </summary>
        /// <param name="stFolder">StarTeam folder desired to put the versionnumber.xml files into</param>
        /// <returns>StarTeam File handle to the created file.</returns>
        private InterOpStarTeam.StFile createVersionStFile(InterOpStarTeam.StFolder stFolder)
        {
            // instantiated here as they are only necessary when adding
            InterOpStarTeam.StFileFactoryClass starteamFileFactory = new InterOpStarTeam.StFileFactoryClass();
            string versionFilePath = stFolder.getFilePath(_versionFile);

            // create xml and save to local file
            try {
                StreamWriter  s         = new StreamWriter(versionFilePath, false, System.Text.ASCIIEncoding.ASCII);
                XmlTextWriter xmlWriter = new XmlTextWriter(s);
                xmlWriter.WriteStartDocument(false);
                xmlWriter.WriteStartElement("stautolabel");
                xmlWriter.WriteStartElement("version");
                xmlWriter.WriteAttributeString("major", "1");
                xmlWriter.WriteAttributeString("minor", "0");
                xmlWriter.WriteAttributeString("build", "0");
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
                xmlWriter.Close();
            } catch (System.Security.SecurityException ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "You do not have access to '{0}'.", versionFilePath), Location, ex);
            } catch (IOException ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Version filepath '{0}' is invalid.", versionFilePath), Location, ex);
            }

            //add local file to starteam
            InterOpStarTeam.StFile newFile = starteamFileFactory.Create(stFolder);
            string comment = "version number xml created by stautonumber NAnt task";

            newFile.Add(versionFilePath, _versionFile, comment, comment,
                        starTeamLockTypeStatics.UNLOCKED, true, true);

            return(newFile);
        }
Пример #2
0
        /// <summary>
        /// Creates the versionumber.xml file in the repository.
        /// </summary>
        /// <param name="stFolder">StarTeam folder desired to put the versionnumber.xml files into</param>
        /// <returns>StarTeam File handle to the created file.</returns>
        private InterOpStarTeam.StFile createVersionStFile(InterOpStarTeam.StFolder stFolder) {
            // instantiated here as they are only necessary when adding 
            InterOpStarTeam.StFileFactoryClass starteamFileFactory = new InterOpStarTeam.StFileFactoryClass();
            string versionFilePath = stFolder.getFilePath(_versionFile);

            // create xml and save to local file
            try {
                StreamWriter s = new StreamWriter(versionFilePath, false, System.Text.ASCIIEncoding.ASCII);
                XmlTextWriter xmlWriter = new XmlTextWriter(s);
                xmlWriter.WriteStartDocument(false);
                xmlWriter.WriteStartElement("stautolabel");
                xmlWriter.WriteStartElement("version");
                xmlWriter.WriteAttributeString("major","1");
                xmlWriter.WriteAttributeString("minor","0");
                xmlWriter.WriteAttributeString("build","0");
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
                xmlWriter.Close();
            } catch (System.Security.SecurityException ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
                    "You do not have access to '{0}'.", versionFilePath), Location, ex);
            } catch (IOException ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
                    "Version filepath '{0}' is invalid.", versionFilePath), Location, ex);
            }

            //add local file to starteam 
            InterOpStarTeam.StFile newFile = starteamFileFactory.Create(stFolder);
            string comment = "version number xml created by stautonumber NAnt task";
            newFile.Add(versionFilePath, _versionFile, comment, comment, 
                starTeamLockTypeStatics.UNLOCKED, true, true);

            return newFile;
        }