Exemple #1
0
 /// <summary>
 ///     Выполняет компиляцию директории и/или проекта с возвратом XML
 /// </summary>
 /// <param name="dir"></param>
 /// <param name="projectname"></param>
 /// <returns></returns>
 public static XElement ExecuteXml(string dir, string projectname = null) {
     var consoleCall = new ConsoleApplicationHandler {
         ExePath = EnvironmentInfo.GetExecutablePath("bsc"),
         Encoding = Encoding.UTF8,
         WorkingDirectory =
             string.IsNullOrWhiteSpace(dir) ? EnvironmentInfo.RootDirectory : EnvironmentInfo.ResolvePath(dir),
         Arguments = string.Format(" {0} --console-mode", projectname),
         NoWindow = true,
         Timeout = 20000,
         Redirect = true
     };
     var result = consoleCall.RunSync();
     if (result.IsOK) {
         return XElement.Parse(result.Output);
     }
     throw new Exception(result.Error + " " + result.Exception);
 }
	    private BSharpFileBasedClassProvider GetOldStyleClsProvider(string rev) {
	        var clsProvider = new BSharpFileBasedClassProvider();
	        if (rev == "HEAD") {
	            rev = _context.GitBranch;
	        }
	        if (!string.IsNullOrWhiteSpace(rev)) {
	            _context.Log.Trace("reset GIT pre " + rev);
	            _githelper.Reset(true);
	            _githelper.Clean(true);
	            _context.Log.Trace("begin checkout " + rev);
	            _githelper.Checkout(rev);
	            _context.ResolvedUpdateRevision = _githelper.GetCommitId();

	            _context.Log.Trace("end checkout " + rev);
	            var bscStarter = new ConsoleApplicationHandler();
	            bscStarter.ExePath = "bsc";
	            bscStarter.WorkingDirectory = Path.Combine(_context.RootDirectory, _context.ProjectDirectory);
	            if (!string.IsNullOrWhiteSpace(_context.ProjectName)) {
	                bscStarter.Arguments = _context.ProjectName;
	            }
	            _context.Log.Trace("start bsc");
	            var bscResult = bscStarter.RunSync();
	            _context.Log.Trace("finish bsc");

	            if (bscResult.IsOK) {
	                _context.Log.Trace("ok bsc");

	                clsProvider = new BSharpFileBasedClassProvider {
	                    RootDirectory = Path.Combine(_context.RootDirectory, _context.OutputDirectory)
	                };
	            }
	            else {
	                _context.Log.Error("error in bsc " + bscResult.Error, bscResult.Exception);
	                throw new Exception("bsharp compile exception " + bscResult.Error, bscResult.Exception);
	            }
	        }
	        return clsProvider;
	    }