Esempio n. 1
0
        protected string GetConfigurationFileContents()
        {
            if (!string.IsNullOrEmpty(this.ConfigurationFileContents))
            {
                return(this.ConfigurationFileContents);
            }

            if (!string.IsNullOrEmpty(this.ConfigurationFilePath))
            {
                var configFileDir = this.ResolveDirectory(this.ConfigurationFilePath);
                var configFile    = Util.Path2.Combine(configFileDir, this.ConfigurationFileName);

                var fileOps = this.Context.Agent.GetService <IFileOperationsExecuter>();

                if (!fileOps.FileExists(configFile))
                {
                    this.LogError("Configuration file {0} does not exist.", configFile);
                    return(null);
                }

                if (this.TestConfigurer != null)
                {
                    return(fileOps.ReadAllText(configFile));
                }

                var tree            = VariableExpressionTree.Parse(configFile, Domains.VariableSupportCodes.All);
                var variableContext = (IVariableEvaluationContext)Activator.CreateInstance(Type.GetType("Inedo.BuildMaster.Variables.StandardVariableEvaluationContext,BuildMaster"), (IGenericBuildMasterContext)this.Context, this.Context.Variables);
                return(tree.Evaluate(variableContext));
            }

            return(this.GetConfigText(this.ConfigurationFileId, this.InstanceName));
        }
Esempio n. 2
0
        protected string GetConfigurationFileContents()
        {
            if (!string.IsNullOrEmpty(this.ConfigurationFileContents))
            {
                return(this.ConfigurationFileContents);
            }

            if (!string.IsNullOrEmpty(this.ConfigurationFilePath))
            {
                var configFileDir = this.ResolveLegacyPath(this.ConfigurationFilePath);
                var configFile    = PathEx.Combine(configFileDir, this.ConfigurationFileName);

                var fileOps = this.Context.Agent.GetService <IFileOperationsExecuter>();

                if (!fileOps.FileExists(configFile))
                {
                    this.LogError("Configuration file {0} does not exist.", configFile);
                    return(null);
                }

                if (this.TestConfigurer != null)
                {
                    return(fileOps.ReadAllText(configFile));
                }

                var tree            = VariableExpressionTree.Parse(fileOps.ReadAllText(configFile), Domains.VariableSupportCodes.All);
                var variableContext = FindVariableEvaluationContext(this.Context);
                return(tree.Evaluate(variableContext));
            }

            return(this.GetConfigText(this.ConfigurationFileId, this.InstanceName));
        }