Exemplo n.º 1
0
        /// <summary>
        /// Start the Build with given filename, version, and build type.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="version"></param>
        /// <param name="build"></param>
        public void Build(string filename, VersionTypes version, BuildTypes build)
        {
            // build the command to call vsvars32.bat
            string initvar;

            switch (version)
            {
            case VersionTypes.VisualStudio2003:
                initvar = config.Get("VSVARS32_2003");
                break;

            case VersionTypes.VisualStudio2005:
                initvar = config.Get("VSVARS32_2005");
                break;

            default:
                throw new ArgumentOutOfRangeException("version=" + version);
            }
            initvar = String.Format("call \"{0}\"", initvar);


            // build the command to build the solution/project
            string buildcmd = new ConfigManager().Get("buildCommand");

            buildcmd = buildcmd.Replace("{FILENAME}", StringUtil.Quote(filename));
            buildcmd = buildcmd.Replace("{BUILDTYPE}", StringUtil.Quote(build.ToString()));

            string command = initvar + Environment.NewLine + buildcmd;

            //// setting up the dos environment
            //Dictionary<string, string> dosEnv = new Dictionary<string, string>();
            //dosEnv.Add("PATH", StringUtil.Merge(MicrosoftDotNetPath, Environment.GetEnvironmentVariable("PATH"), ";"));

            // run the commands.
            ExeRunner r = new ExeRunner();

            try
            {
                r.Run(command);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
                // WARNING: absorb error only!
            }
            finally
            {
                log.AddRange(r.Log);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve items from VSS and return a list of filenames.
        /// </summary>
        /// <param name="outputFolder"></param>
        /// <param name="vssItem"></param>
        /// <returns></returns>
        public string[] GetFiles(string outputFolder, string vssItem)
        {
            try
            {
                #region Sanity Checks
                if (String.IsNullOrEmpty(outputFolder))
                {
                    throw new ArgumentNullException("outputFolder");
                }

                if (File.Exists(outputFolder))
                {
                    throw new ArgumentException("Invalid Folder: file already existed");
                }
                #endregion

                string cmd = VssCommand(outputFolder, vssItem);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                ExeRunner r = new ExeRunner();

                log.Clear();

                try
                {
                    r.Run(cmd, dosEnv);
                }
                finally
                {
                    log.AddRange(r.Log);
                }

                return(Directory.GetFiles(outputFolder, "*.*", SearchOption.AllDirectories));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }