Execute() public method

public Execute ( ) : bool
return bool
        public override bool Execute()
        {
            bool success;

            if (!Path.IsPathRooted(AntlrToolPath))
            {
                AntlrToolPath = Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), AntlrToolPath);
            }

            if (!Path.IsPathRooted(BuildTaskPath))
            {
                BuildTaskPath = Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), BuildTaskPath);
            }

            try
            {
                AntlrClassGenerationTaskInternal wrapper = CreateBuildTaskWrapper();

                _lock.Wait();
                try
                {
                    success = wrapper.Execute();
                }
                finally
                {
                    _lock.Release();
                }

                if (success)
                {
                    _generatedCodeFiles.AddRange(wrapper.GeneratedCodeFiles.Select(file => (ITaskItem) new TaskItem(file)));
                }

                foreach (BuildMessage message in wrapper.BuildMessages)
                {
                    ProcessBuildMessage(message);
                }
            }
            catch (Exception exception)
            {
                if (IsFatalException(exception))
                {
                    throw;
                }

                ProcessExceptionAsBuildMessage(exception);
                success = false;
            }

            return(success);
        }
示例#2
0
        public override bool Execute()
        {
            AppDomain domain = null;
            bool      success;

            if (!Path.IsPathRooted(AntlrToolPath))
            {
                AntlrToolPath = Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), AntlrToolPath);
            }

            if (!Path.IsPathRooted(BuildTaskPath))
            {
                BuildTaskPath = Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), BuildTaskPath);
            }

            try
            {
                domain = GetAntlrTaskAppDomain();
                AntlrClassGenerationTaskInternal wrapper = CreateBuildTaskWrapper(domain);
                success = wrapper.Execute();

                if (success)
                {
                    _generatedCodeFiles.AddRange(wrapper.GeneratedCodeFiles.Select(file => (ITaskItem) new TaskItem(file)));
                }

                foreach (BuildMessage message in wrapper.BuildMessages)
                {
                    ProcessBuildMessage(message);
                }
            }
            catch (Exception exception)
            {
                if (IsFatalException(exception))
                {
                    throw;
                }

                ProcessExceptionAsBuildMessage(exception);
                success = false;
            }
            finally
            {
                if (domain != null && domain != _sharedAppDomain)
                {
                    AppDomain.Unload(domain);
                }
            }

            return(success);
        }
        public override bool Execute()
        {
            AppDomain domain = null;
            bool      success;

            try
            {
                AppDomainSetup info = new AppDomainSetup
                {
                    ApplicationBase    = BuildTaskPath,
                    LoaderOptimization = LoaderOptimization.MultiDomainHost,
                    ShadowCopyFiles    = "true"
                };

                string friendlyName = "AntlrClassGenerationDomain_" + Guid.NewGuid();
                domain = AppDomain.CreateDomain(friendlyName, AppDomain.CurrentDomain.Evidence, info, new NamedPermissionSet("FullTrust"), new StrongName[0]);
                AntlrClassGenerationTaskInternal wrapper = CreateBuildTaskWrapper(domain);
                success = wrapper.Execute();

                if (success)
                {
                    _generatedCodeFiles.AddRange(wrapper.GeneratedCodeFiles.Select(file => (ITaskItem) new TaskItem(file)));
                }

                foreach (BuildMessage message in wrapper.BuildMessages)
                {
                    ProcessBuildMessage(message);
                }
            }
            catch (Exception exception)
            {
                if (IsFatalException(exception))
                {
                    throw;
                }

                ProcessExceptionAsBuildMessage(exception);
                success = false;
            }
            finally
            {
                if (domain != null)
                {
                    AppDomain.Unload(domain);
                }
            }

            return(success);
        }
示例#4
0
        public override bool Execute()
        {
            AppDomain domain = null;
            bool      success;

            try
            {
                domain = GetAntlrTaskAppDomain();
                AntlrClassGenerationTaskInternal wrapper = CreateBuildTaskWrapper(domain);
                success = wrapper.Execute();

                if (success)
                {
                    _generatedCodeFiles.AddRange(wrapper.GeneratedCodeFiles.Select(file => (ITaskItem) new TaskItem(file)));
                }

                foreach (BuildMessage message in wrapper.BuildMessages)
                {
                    ProcessBuildMessage(message);
                }
            }
            catch (Exception exception)
            {
                if (IsFatalException(exception))
                {
                    throw;
                }

                ProcessExceptionAsBuildMessage(exception);
                success = false;
            }
            finally
            {
                if (domain != null && domain != _sharedAppDomain)
                {
                    AppDomain.Unload(domain);
                }
            }

            return(success);
        }