Example #1
0
        public string TestCSBuild(bool assertConfig, string relPath, params string[] args)
        {
            string        fullPath  = Path.Combine(WorkingDirectory, relPath);
            List <String> arguments = new List <string>(args);

            if (assertConfig)
            {
                Assert.IsTrue(Directory.Exists(fullPath), "Directory not found: " + fullPath);
                Assert.IsTrue(File.Exists(Path.Combine(fullPath, "CSBuild.exe.config")), "File not found: CSBuild.exe.config");

                arguments.Add("-config=CSBuild.exe.config");
            }

            _consoleText.GetStringBuilder().Length = 0;
            _errorText.GetStringBuilder().Length   = 0;
            CSBuildRunner runner = new CSBuildRunner(fullPath, arguments.ToArray());

            try
            {
                runner.Wait();
            }
            catch (ApplicationException inner)
            {
                //_error.Write(_errorText.ToString());
                Exception inside = inner;
                if (inside.InnerException != null)
                {
                    inside = inside.InnerException;
                }

                string desc = _errorText.ToString().Trim();
                if (desc.Length == 0)
                {
                    desc = _consoleText.ToString().Trim();
                }

                throw new ApplicationException(desc, inside);
            }

            return(fullPath);
        }
Example #2
0
		public string TestCSBuild(bool assertConfig, string relPath, params string[] args)
		{
			string fullPath = Path.Combine(WorkingDirectory, relPath);
			List<String> arguments = new List<string>(args);

			if (assertConfig)
			{
				Assert.IsTrue(Directory.Exists(fullPath), "Directory not found: " + fullPath);
				Assert.IsTrue(File.Exists(Path.Combine(fullPath, "CSBuild.exe.config")), "File not found: CSBuild.exe.config");

				arguments.Add("-config=CSBuild.exe.config");
			}

			_consoleText.GetStringBuilder().Length = 0;
			_errorText.GetStringBuilder().Length = 0;
			CSBuildRunner runner = new CSBuildRunner(fullPath, arguments.ToArray());

			try
			{
				runner.Wait();
			}
			catch(ApplicationException inner)
			{
				//_error.Write(_errorText.ToString());
				Exception inside = inner;
				if (inside.InnerException != null)
					inside = inside.InnerException;

				string desc = _errorText.ToString().Trim();
				if (desc.Length == 0)
					desc = _consoleText.ToString().Trim();

				throw new ApplicationException(desc, inside);
			}

			return fullPath;
		}