public IEnumerable<string> GetAppBuildOrder(string sourceDirectory, string startAppPath, string uniqueSourceDirectoryPath, TaskLoggingHelper log)
        {
            _log = log;
            _uniqueSourceDirectoryPath = uniqueSourceDirectoryPath;
            var sourceDirectoryPath = sourceDirectory.Trim('\'', '"');
            var appList = GetAppListWithReferences(sourceDirectoryPath);

            var appPath = startAppPath.Trim('\'', '"');
            var startApps = appPath.Split('|').ToList();
            foreach (var app in startApps)
            {
                if (!string.IsNullOrEmpty(app))
                {
                    _log.LogMessage("Application path: {0}", app);
                    var startApp = appList[Path.GetFullPath(app.ToUpper().Replace(sourceDirectoryPath.ToUpper(), _uniqueSourceDirectoryPath)).ToUpper()];
                    if (startApp == null)
                    {
                        log.LogError("Application {0} could not be found.", app);
                    }
                    else
                    {
                        _orderedAppList.Add(Path.GetFullPath(app.ToUpper().Replace(sourceDirectoryPath.ToUpper(), _uniqueSourceDirectoryPath)).ToUpper());
                        LoopReferences(startApp, appList);
                    }
                }
            }

            _orderedAppList.ForEach(a => _log.LogMessage(a));

            return _orderedAppList;
        }
Exemple #2
0
        /// <summary>
        /// Checks that the file path is sanitized and follows
        /// all the conventions estabilished by the operating system.
        /// </summary>
        /// <param name="fileName">The input file name to validate.</param>
        /// <param name="log">The current log instance.</param>
        /// <returns>A value indicating whether the action was executed succesfuly.</returns>
        internal static bool CheckFilePath(string fileName, TaskLoggingHelper log)
        {
            bool flag = true;
            string directoryName = string.Empty;
            try
            {
                directoryName = Path.GetDirectoryName(fileName);
            }
            catch (ArgumentException exception)
            {
                directoryName = exception.Message;
                flag = false;
            }
            catch (PathTooLongException exception2)
            {
                directoryName = exception2.Message;
                flag = false;
            }

            if (!flag)
            {
                log.LogErrorFromResources("InvalidPathChars", new object[] { directoryName });
            }

            return flag;
        }
Exemple #3
0
        public BlobFeedAction(string expectedFeedUrl, string accountKey, MSBuild.TaskLoggingHelper Log)
        {
            this.Log = Log;
            Match m = Regex.Match(expectedFeedUrl, feedRegex);

            if (m.Success)
            {
                string accountName   = m.Groups["accountname"].Value;
                string containerName = m.Groups["containername"].Value;
                string relativePath  = m.Groups["relativepath"].Value;
                feed     = new BlobFeed(accountName, accountKey, containerName, relativePath, Log);
                feedUrl  = m.Groups["feedurl"].Value;
                hasToken = !string.IsNullOrEmpty(m.Groups["token"].Value);

                source = new SleetSource
                {
                    Name             = feed.ContainerName,
                    Type             = "azure",
                    Path             = feedUrl,
                    Container        = feed.ContainerName,
                    FeedSubPath      = feed.RelativePath,
                    ConnectionString = $"DefaultEndpointsProtocol=https;AccountName={feed.AccountName};AccountKey={feed.AccountKey};EndpointSuffix=core.windows.net"
                };
            }
            else
            {
                throw new Exception("Unable to parse expected feed. Please check ExpectedFeedUrl.");
            }
        }
        public MsBuildTaskLogger(TaskLoggingHelper log)
        {
            if (log == null)
                throw new ArgumentNullException("log");

            _log = log;
        }
		public static void GetPaths (out string monoDroidBinDir, out string monoDroidFrameworkDir,
			out string androidSdkPath, out string javaSdkPath, TaskLoggingHelper log)
		{
			monoDroidBinDir = monoDroidFrameworkDir = androidSdkPath = javaSdkPath = null;
			
			GetMonoDroidSdk (out monoDroidBinDir, out monoDroidFrameworkDir);
			
			GetConfiguredSdkLocations (out androidSdkPath, out javaSdkPath, log);
			
			if (!ValidateAndroidSdkLocation (androidSdkPath))
				androidSdkPath = null;
			if (!ValidateJavaSdkLocation (javaSdkPath))
				javaSdkPath = null;
			if (androidSdkPath != null && javaSdkPath != null)
				return;
			
			var path = Environment.GetEnvironmentVariable ("PATH");
			var pathDirs = path.Split (new char[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
			
			if (androidSdkPath == null)
				androidSdkPath = FindAndroidSdk (pathDirs);

			if (javaSdkPath == null)
				javaSdkPath = FindJavaSdk (pathDirs);
		}
Exemple #6
0
        public BlobFeedAction(string expectedFeedUrl, string accountKey, MSBuild.TaskLoggingHelper Log)
        {
            // This blob feed action regex is custom because of the way that nuget handles query strings (it doesn't)
            // Instead of encoding the query string containing the SAS at the end of the URL we encode it at the beginning.
            // As a result, we can't parse this feed url like a traditional feed url.  When this changes, this code could be simplified and
            // BlobUriParser could be used instead.
            this.Log = Log;
            Match m = Regex.Match(expectedFeedUrl, feedRegex);

            if (m.Success)
            {
                string accountName   = m.Groups["accountname"].Value;
                string containerName = m.Groups["containername"].Value;
                string relativePath  = m.Groups["relativepath"].Value;
                feed     = new BlobFeed(accountName, accountKey, containerName, relativePath, Log);
                feedUrl  = m.Groups["feedurl"].Value;
                hasToken = !string.IsNullOrEmpty(m.Groups["token"].Value);

                source = new SleetSource
                {
                    Name             = feed.ContainerName,
                    Type             = "azure",
                    Path             = feedUrl,
                    Container        = feed.ContainerName,
                    FeedSubPath      = feed.RelativePath,
                    ConnectionString = $"DefaultEndpointsProtocol=https;AccountName={feed.AccountName};AccountKey={feed.AccountKey};EndpointSuffix=core.windows.net"
                };
            }
            else
            {
                throw new Exception("Unable to parse expected feed. Please check ExpectedFeedUrl.");
            }
        }
 internal virtual void SerializeCache(string stateFile, TaskLoggingHelper log)
 {
     try
     {
         if ((stateFile != null) && (stateFile.Length > 0))
         {
             if (File.Exists(stateFile))
             {
                 File.Delete(stateFile);
             }
             using (FileStream stream = new FileStream(stateFile, FileMode.CreateNew))
             {
                 new BinaryFormatter().Serialize(stream, this);
             }
         }
     }
     catch (Exception exception)
     {
         if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
         {
             throw;
         }
         log.LogWarningWithCodeFromResources("General.CouldNotWriteStateFile", new object[] { stateFile, exception.Message });
     }
 }
 internal static StateFileBase DeserializeCache(string stateFile, TaskLoggingHelper log, Type requiredReturnType)
 {
     StateFileBase o = null;
     try
     {
         if (((stateFile == null) || (stateFile.Length <= 0)) || !File.Exists(stateFile))
         {
             return o;
         }
         using (FileStream stream = new FileStream(stateFile, FileMode.Open))
         {
             object obj2 = new BinaryFormatter().Deserialize(stream);
             o = obj2 as StateFileBase;
             if ((o == null) && (obj2 != null))
             {
                 log.LogMessageFromResources("General.CouldNotReadStateFileMessage", new object[] { stateFile, log.FormatResourceString("General.IncompatibleStateFileType", new object[0]) });
             }
             if ((o != null) && !requiredReturnType.IsInstanceOfType(o))
             {
                 log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", new object[] { stateFile, log.FormatResourceString("General.IncompatibleStateFileType", new object[0]) });
                 o = null;
             }
         }
     }
     catch (Exception exception)
     {
         log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", new object[] { stateFile, exception.Message });
     }
     return o;
 }
Exemple #9
0
        /// <summary>
        /// utility function to write the simple setParameter.xml file
        /// </summary>
        /// <param name="loggingHelper"></param>
        /// <param name="parameters"></param>
        /// <param name="outputFileName"></param>
        private static void WriteManifestsToFile(Utilities.TaskLoggingHelper loggingHelper, Framework.ITaskItem[] items, string outputFileName)
        {
            Xml.XmlDocument document        = new System.Xml.XmlDocument();
            Xml.XmlElement  manifestElement = document.CreateElement("sitemanifest");
            document.AppendChild(manifestElement);
            if (items != null)
            {
                foreach (Framework.ITaskItem item in items)
                {
                    string         name            = item.ItemSpec;
                    Xml.XmlElement providerElement = document.CreateElement(name);
                    string         path            = item.GetMetadata("Path");
                    providerElement.SetAttribute("path", path);

                    string additionProviderSetting = item.GetMetadata("AdditionalProviderSettings");
                    if (!string.IsNullOrEmpty(additionProviderSetting))
                    {
                        string[] providerSettings = additionProviderSetting.Split(';');
                        foreach (string ps in providerSettings)
                        {
                            string value = item.GetMetadata(ps);
                            if (!string.IsNullOrEmpty(value))
                            {
                                providerElement.SetAttribute(ps, value);
                            }
                        }
                    }
                    manifestElement.AppendChild(providerElement);
                }
            }

            // Save the UTF8 and Indented
            SaveDocument(document, outputFileName, System.Text.Encoding.UTF8);
        }
Exemple #10
0
 /// <summary>
 /// Internal constructor
 /// </summary>
 /// <param name="taskLoggingHelper">task logger instance used for logging</param>
 /// <param name="silent">true if this task should log only errors, no warnings or messages; false otherwise</param>
 /// <param name="referenceInfo">cached reference information (typelib pointer, original task item, typelib name etc.)</param>
 /// <param name="itemName">reference name (for better logging experience)</param>
 internal ComReference(TaskLoggingHelper taskLoggingHelper, bool silent, ComReferenceInfo referenceInfo, string itemName)
 {
     _referenceInfo = referenceInfo;
     _itemName = itemName;
     _log = taskLoggingHelper;
     _silent = silent;
 }
        public bool Run(Assembly assm, string ResourceName, string OutputPath, TaskLoggingHelper Log)
        {
            // Ensure our output directory exists
            if (!Directory.Exists (Path.GetDirectoryName (OutputPath)))
                Directory.CreateDirectory (Path.GetDirectoryName (OutputPath));

            // Copy out one of our embedded resources to a path
            using (var from = GetManifestResourceStream (ResourceName)) {

                // If the resource already exists, only overwrite if it's changed
                if (File.Exists (OutputPath)) {
                    var hash1 = MonoAndroidHelper.HashFile (OutputPath);
                    var hash2 = MonoAndroidHelper.HashStream (from);

                    if (hash1 == hash2) {
                        Log.LogDebugMessage ("Resource {0} is unchanged. Skipping.", OutputPath);
                        return true;
                    }
                }

                // Hash calculation read to the end, move back to beginning of file
                from.Position = 0;

                // Write out the resource
                using (var to = File.Create (OutputPath))
                    Copy (from, to);

                Log.LogDebugMessage ("Wrote resource {0}.", OutputPath);
            }

            return true;
        }
		/// <summary>
		/// Constructor for the error sink
		/// </summary>
		/// <param name="logger">This parameter should be the logger for the task being executed</param>
		public CompilerErrorSink(TaskLoggingHelper/*!*/ logger)
		{
			if (logger == null)
				throw new ArgumentNullException("logger");

			this.logger = logger;
		}
 public ConnectionContext(NetworkStream clientStream, string connString, TcpTestServer3 server, TaskLoggingHelper log)
 {
     this.clientStream = clientStream;
     this.connString = connString;
     this.tcpServer = server;
     this.log = log;
 }
 internal TlbReference(TaskLoggingHelper taskLoggingHelper, IComReferenceResolver resolverCallback, IEnumerable<string> referenceFiles, ComReferenceInfo referenceInfo, string itemName, string outputDirectory, bool hasTemporaryWrapper, bool delaySign, string keyFile, string keyContainer, bool noClassMembers, string targetProcessorArchitecture, bool includeTypeLibVersionInName, bool executeAsTool, string sdkToolsPath, IBuildEngine buildEngine, string[] environmentVariables) : base(taskLoggingHelper, resolverCallback, referenceInfo, itemName, outputDirectory, delaySign, keyFile, keyContainer, includeTypeLibVersionInName, executeAsTool, sdkToolsPath, buildEngine, environmentVariables)
 {
     this.hasTemporaryWrapper = hasTemporaryWrapper;
     this.noClassMembers = noClassMembers;
     this.targetProcessorArchitecture = targetProcessorArchitecture;
     this.referenceFiles = referenceFiles;
 }
 internal ReferenceTable(bool findDependencies, bool findSatellites, bool findSerializationAssemblies, bool findRelatedFiles, string[] searchPaths, string[] allowedAssemblyExtensions, string[] relatedFileExtensions, string[] candidateAssemblyFiles, string[] frameworkPaths, InstalledAssemblies installedAssemblies, System.Reflection.ProcessorArchitecture targetProcessorArchitecture, Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, OpenBaseKey openBaseKey, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, Version projectTargetFramework, FrameworkName targetFrameworkMoniker, TaskLoggingHelper log, string[] latestTargetFrameworkDirectories, bool copyLocalDependenciesWhenParentReferenceInGac, CheckIfAssemblyInGac checkIfAssemblyIsInGac)
 {
     this.log = log;
     this.findDependencies = findDependencies;
     this.findSatellites = findSatellites;
     this.findSerializationAssemblies = findSerializationAssemblies;
     this.findRelatedFiles = findRelatedFiles;
     this.frameworkPaths = frameworkPaths;
     this.allowedAssemblyExtensions = allowedAssemblyExtensions;
     this.relatedFileExtensions = relatedFileExtensions;
     this.installedAssemblies = installedAssemblies;
     this.targetProcessorArchitecture = targetProcessorArchitecture;
     this.fileExists = fileExists;
     this.directoryExists = directoryExists;
     this.getDirectories = getDirectories;
     this.getAssemblyName = getAssemblyName;
     this.getAssemblyMetadata = getAssemblyMetadata;
     this.getRuntimeVersion = getRuntimeVersion;
     this.projectTargetFramework = projectTargetFramework;
     this.targetedRuntimeVersion = targetedRuntimeVersion;
     this.openBaseKey = openBaseKey;
     this.targetFrameworkMoniker = targetFrameworkMoniker;
     this.latestTargetFrameworkDirectories = latestTargetFrameworkDirectories;
     this.copyLocalDependenciesWhenParentReferenceInGac = copyLocalDependenciesWhenParentReferenceInGac;
     this.checkIfAssemblyIsInGac = checkIfAssemblyIsInGac;
     this.compiledSearchPaths = AssemblyResolution.CompileSearchPaths(searchPaths, candidateAssemblyFiles, targetProcessorArchitecture, frameworkPaths, fileExists, getAssemblyName, getRegistrySubKeyNames, getRegistrySubKeyDefaultValue, openBaseKey, installedAssemblies, getRuntimeVersion, targetedRuntimeVersion);
 }
		public MsBuildRunner(TaskLoggingHelper log, LogTypeEnum logType, string logFile) : base()
		{
			Log = log;
			LogType = logType;
			LogFile = logFile;
			OriginalIgnoreList = IgnoreList = new NotSupportedIgnoreList();
		}
            public ValidationPattern(ITaskItem item, TaskLoggingHelper log)
            {
                string idRegex = item.GetMetadata("IdentityRegex");
                if (string.IsNullOrEmpty(idRegex))
                {
                    // Temporarily support reading the regex from the Include/ItemSpec for backwards compatibility
                    // when the IdentityRegex isn't specified. This can be removed once all consumers are using IdentityRegex.
                    idRegex = item.ItemSpec;
                }

                _idPattern = new Regex(idRegex);
                _expectedVersion = item.GetMetadata("ExpectedVersion");
                _expectedPrerelease = item.GetMetadata("ExpectedPrerelease");
                _log = log;

                if (string.IsNullOrWhiteSpace(_expectedVersion))
                {
                    if (string.IsNullOrWhiteSpace(_expectedPrerelease))
                    {
                        _log.LogError(
                            "Can't find ExpectedVersion or ExpectedPrerelease metadata on item {0}",
                            item.ItemSpec);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(_expectedPrerelease))
                {
                    _log.LogError(
                        "Both ExpectedVersion and ExpectedPrerelease metadata found on item {0}, but only one permitted",
                        item.ItemSpec);
                }
            }
Exemple #18
0
		protected Task(ResourceManager taskResources,
			       string helpKeywordPrefix)
		{
			log = new TaskLoggingHelper (this);
			log.TaskResources = taskResources;
			this.helpKeywordPrefix = helpKeywordPrefix;
		}
 /// <summary>
 /// Default constructor
 /// </summary>
 protected DataDrivenToolTask(ResourceManager taskResources)
     : base(taskResources)
 {
     logPrivate = new TaskLoggingHelper(this);
     logPrivate.TaskResources = AssemblyResources.PrimaryResources;
     logPrivate.HelpKeywordPrefix = "MSBuild.";
 }
Exemple #20
0
        public static async Task<ServiceTable> GetServiceTableAsync(string ConnString, int ServiceTableID, TaskLoggingHelper Log)
        {
            ServiceTable result = new ServiceTable();

            SqlConnection conn = new SqlConnection(ConnString);
            conn.Open();

            SqlCommand cmd = new SqlCommand("select ServiceTableID, DescServiceTable, Value, CreationDate, StringField1, StringField2 " +
                    "from ServiceTable where ServiceTableID = @ServiceTableID", conn);

            using (conn)
            {
                SqlParameter p1 = cmd.Parameters.Add("@ServiceTableID", SqlDbType.Int);
                p1.Value = ServiceTableID;

                SqlDataReader rd = await cmd.ExecuteReaderAsync();
                rd.Read();
                using (rd)
                {
                    result.ServiceTableID = rd.GetInt32(0);
                    result.DescServiceTable = rd.GetString(1);
                    result.Value = (float)rd.GetDouble(2);
                    result.CreationDate = rd.GetDateTime(3);
                    result.StringField1 = rd.GetString(4);
                    result.StringField2 = rd.GetString(5);
                }
            }

            if (Log != null)
                Log.LogMessage("Getting ServiceTableID: " + ServiceTableID.ToString());

            return result;
        }
Exemple #21
0
        public static bool RemoveSelectors(TaskLoggingHelper log, HtmlDocument document, IEnumerable<SelectorInfo> selectors)
        {
            bool updatedItem = false;
            HtmlNodeCollection collection = document.DocumentNode.SelectNodes("//style");
            int nodeNumber = 0;
            foreach (HtmlNode node in collection)
            {
                log.LogMessage(MessageImportance.Normal, "Processing <style/> tag #{0}", nodeNumber++);
                List<SelectorInfo> foundSelectors = selectors.Where(item => item.Expression.IsMatch(node.InnerText)).ToList();
                foreach (SelectorInfo foundSelector in foundSelectors)
                {
                    log.LogMessage(MessageImportance.Normal, "Found '{0}' selector. Removing all occurrences.", foundSelector.Name);
                    node.InnerHtml = foundSelector.Expression.Replace(node.InnerHtml, string.Empty);
                    updatedItem = true;
                }

                if (string.IsNullOrWhiteSpace(node.InnerHtml))
                {
                    log.LogMessage(MessageImportance.Normal, "No CSS Styles remain. Removing <style/>");
                    node.Remove();
                    updatedItem = true;
                }
            }
            return updatedItem;
        }
 internal static bool GetTable(TaskLoggingHelper log, string parameterName, string[] propertyList, out Hashtable propertiesTable)
 {
     propertiesTable = null;
     if (propertyList != null)
     {
         propertiesTable = new Hashtable(StringComparer.OrdinalIgnoreCase);
         foreach (string str in propertyList)
         {
             string str2 = string.Empty;
             string str3 = string.Empty;
             int index = str.IndexOf('=');
             if (index != -1)
             {
                 str2 = str.Substring(0, index).Trim();
                 str3 = str.Substring(index + 1).Trim();
             }
             if (str2.Length == 0)
             {
                 if (log != null)
                 {
                     log.LogErrorWithCodeFromResources("General.InvalidPropertyError", new object[] { parameterName, str });
                 }
                 return false;
             }
             propertiesTable[str2] = str3;
         }
     }
     return true;
 }
Exemple #23
0
        /// <summary>
        /// Writes the contents of this object out to the specified file.
        /// </summary>
        /// <param name="stateFile"></param>
        virtual internal void SerializeCache(string stateFile, TaskLoggingHelper log)
        {
            try
            {
                if (!string.IsNullOrEmpty(stateFile))
                {
                    if (File.Exists(stateFile))
                    {
                        File.Delete(stateFile);
                    }

                    using (FileStream s = new FileStream(stateFile, FileMode.CreateNew))
                    {
                        BinaryFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(s, this);
                    }
                }
            }
            catch (Exception e)
            {
                // If there was a problem writing the file (like it's read-only or locked on disk, for
                // example), then eat the exception and log a warning.  Otherwise, rethrow.
                if (ExceptionHandling.NotExpectedSerializationException(e))
                    throw;

                // Not being able to serialize the cache is not an error, but we let the user know anyway.
                // Don't want to hold up processing just because we couldn't read the file.
                log.LogWarningWithCodeFromResources("General.CouldNotWriteStateFile", stateFile, e.Message);
            }
        }
        public void Run(string site, TaskLoggingHelper log, int maxPages, bool strict)
        {
            this.MaxPages = maxPages;
            this.Strict = strict;
            this.log = log;

            log.LogMessage("Starting site at " + site);
            using (var iis = new IisConfiguration(site, log))
            {
                var tokill = iis.StartWebsites();

                foreach (var process in tokill)
                    PipeProcessToLog(process);

                // Create a URI class
                var startUrl = new Uri("http://localhost:" + iis.Port);

                log.LogMessage("##teamcity[testSuiteStarted name='SiteVerification']");
                var report = RunAnalysis(startUrl);
                // Run a few queries...
                LogSeoViolations(report);

                LogBrokenLinks(report);

                LogResponseTimes(report);

                log.LogMessage("##teamcity[testSuiteFinished name='SiteVerification']");

                foreach (var process in tokill)
                {
                    SendStopMessageToProcess(process.Id);
                }
            }
        }
Exemple #25
0
        /// <summary>
        /// utility function to write the simple setParameter.xml file
        /// </summary>
        /// <param name="loggingHelper"></param>
        /// <param name="parameters"></param>
        /// <param name="outputFileName"></param>
        private static void WriteSetParametersToFile(Utilities.TaskLoggingHelper loggingHelper, Framework.ITaskItem[] parameters, string outputFileName, bool foptimisticParameterDefaultValue)
        {
            Xml.XmlDocument document          = new System.Xml.XmlDocument();
            Xml.XmlElement  parametersElement = document.CreateElement("parameters");
            document.AppendChild(parametersElement);
            if (parameters != null)
            {
                System.Collections.Generic.IList <Framework.ITaskItem> items
                    = Utility.SortParametersTaskItems(parameters, foptimisticParameterDefaultValue, SimpleSyncParameterMetadata.Value.ToString());

                // only the first value win
                System.Collections.Generic.Dictionary <string, Xml.XmlElement> dictionaryLookup
                    = new System.Collections.Generic.Dictionary <string, Xml.XmlElement>(parameters.GetLength(0));

                foreach (Framework.ITaskItem item in items)
                {
                    string name = item.ItemSpec;
                    if (!dictionaryLookup.ContainsKey(name))
                    {
                        Xml.XmlElement parameterElement = document.CreateElement("setParameter");
                        parameterElement.SetAttribute("name", name);
                        string value = item.GetMetadata("value");
                        parameterElement.SetAttribute("value", value);
                        dictionaryLookup.Add(name, parameterElement);
                        parametersElement.AppendChild(parameterElement);
                    }
                }
            }

            // Save the UTF8 and Indented
            Utility.SaveDocument(document, outputFileName, System.Text.Encoding.UTF8);
        }
Exemple #26
0
        public TaskLogger(TaskLoggingHelper taskLoggingHelper)
        {
            if (taskLoggingHelper == null)
                throw new ArgumentNullException("taskLoggingHelper");

            this.taskLoggingHelper = taskLoggingHelper;
        }
 private string GetTypeLibId(TaskLoggingHelper log)
 {
     if (this.taskItem != null)
     {
         return this.taskItem.ItemSpec;
     }
     return log.FormatResourceString("ResolveComReference.TypeLibAttrId", new object[] { this.attr.guid, this.attr.wMajorVerNum, this.attr.wMinorVerNum });
 }
 public MSBuildLogger(TaskLoggingHelper log, string scriptFile)
     : this(log)
 {
     if (! String.IsNullOrEmpty(scriptFile))
     {
         writer = new StreamWriter(scriptFile, true);
     }
 }
 public AutoExpressionField(AssemblyDefinition assembly, PreloadingAssemblyResolver resolver, TaskLoggingHelper log)
 {
     this.Assembly = assembly;
     this.Resolver = resolver;
     this.Log = log;
     this.SignumUtilities = assembly.Name.Name == "Signum.Utilities" ? assembly : resolver.SignumUtilities;
     this.ExpressionField = SignumUtilities.MainModule.GetType("Signum.Utilities", "ExpressionFieldAttribute");
 }
Exemple #30
0
 public BlobFeed(string accountName, string accountKey, string containerName, string indexDirectory, MSBuild.TaskLoggingHelper loggingHelper)
 {
     AccountName    = accountName;
     AccountKey     = accountKey;
     ContainerName  = containerName;
     IndexDirectory = indexDirectory;
     Log            = loggingHelper;
 }
 public CreateBundlesCommand(string source, string bin, string output, bool includeRawFiles, TaskLoggingHelper taskLoggingHelper)
 {
     this.source = source;
     this.bin = bin;
     this.output = output;
     this.includeRawFiles = includeRawFiles;
     this.taskLoggingHelper = taskLoggingHelper;
 }
 public MSBuildLoggerAdapter(TaskLoggingHelper msBuildLogger)
 {
     if (msBuildLogger == null)
     {
         throw new ArgumentNullException("msBuildLogger");
     }
     this.msBuildLogger = msBuildLogger;
 }
Exemple #33
0
 public BlobFeed(string accountName, string accountKey, string containerName, string relativePath, MSBuild.TaskLoggingHelper loggingHelper)
 {
     AccountName   = accountName;
     AccountKey    = accountKey;
     ContainerName = containerName;
     Log           = loggingHelper;
     RelativePath  = relativePath;
 }
Exemple #34
0
        public bool Parse(string antBuildPath, string antBuildType, TaskLoggingHelper log, bool outputInQuotes)
        {
            // Ant build directory check
            if (Directory.Exists(antBuildPath) == false)
            {
                log.LogError("Ant Build Path '" + antBuildPath + "' does not exist");
                return false;
            }

            // Check that the build.xml exists
            string buildXml = Path.GetFullPath(antBuildPath + "\\build.xml");
            if (File.Exists(buildXml) == false)
            {
                log.LogError("build.xml '" + buildXml + "' does not exist");
                return false;
            }

            // Check that the AndroidManifest.xml exists
            string manifestXml = Path.GetFullPath(antBuildPath + "\\AndroidManifest.xml");
            if (File.Exists(manifestXml) == false)
            {
                log.LogError("AndroidManifest.xml '" + manifestXml + "' does not exist");
                return false;
            }

            // Parse the xml to grab the finished apk path
            if (ParseBuildXml(buildXml))
            {
                if (antBuildType.ToLower() == "debug")
                {
                    OutputFile = Path.GetFullPath(antBuildPath + "\\" + BUILD_BIN_PATH + "\\" + ApkName + "-debug.apk");
                }
                else
                {
                    OutputFile = Path.GetFullPath(antBuildPath + "\\" + BUILD_BIN_PATH + "\\" + ApkName + "-release.apk");
                }

                if ( outputInQuotes )
                {
                    OutputFile = "\"" + OutputFile + "\"";
                }
            }
            else
            {
                // Parse failed, oh dear.
                log.LogError("Failed parsing '" + buildXml + "'");
                return false;
            }

            if (ParseAndroidManifestXml(manifestXml) == false)
            {
                // Parse failed, oh dear.
                log.LogError("Failed parsing '" + manifestXml + "'");
                return false;
            }

            return true;
        }
Exemple #35
0
        /// <summary>
        /// Reads the specified file from disk into a StateFileBase derived object.
        /// </summary>
        /// <param name="stateFile"></param>
        /// <returns></returns>
        static internal StateFileBase DeserializeCache(string stateFile, TaskLoggingHelper log, Type requiredReturnType)
        {
            StateFileBase retVal = null;

            // First, we read the cache from disk if one exists, or if one does not exist
            // then we create one.  
            try
            {
                if (!string.IsNullOrEmpty(stateFile) && File.Exists(stateFile))
                {
                    using (FileStream s = new FileStream(stateFile, FileMode.Open))
                    {
                        BinaryFormatter formatter = new BinaryFormatter();
                        object deserializedObject = formatter.Deserialize(s);
                        retVal = deserializedObject as StateFileBase;

                        // If the deserialized object is null then there would be no cast error but retVal would still be null
                        // only log the message if there would have been a cast error
                        if (retVal == null && deserializedObject != null)
                        {
                            // When upgrading to Visual Studio 2008 and running the build for the first time the resource cache files are replaced which causes a cast error due
                            // to a new version number on the tasks class. "Unable to cast object of type 'Microsoft.Build.Tasks.SystemState' to type 'Microsoft.Build.Tasks.StateFileBase”.
                            // If there is an invalid cast, a message rather than a warning should be emitted.
                            log.LogMessageFromResources("General.CouldNotReadStateFileMessage", stateFile, log.FormatResourceString("General.IncompatibleStateFileType"));
                        }

                        if ((retVal != null) && (!requiredReturnType.IsInstanceOfType(retVal)))
                        {
                            log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", stateFile,
                                log.FormatResourceString("General.IncompatibleStateFileType"));
                            retVal = null;
                        }

                        // If we get back a valid object and internals were changed, things are likely to be null. Check the version before we use it.
                        if (retVal != null && retVal._serializedVersion != CurrentSerializationVersion)
                        {
                            log.LogMessageFromResources("General.CouldNotReadStateFileMessage", stateFile, log.FormatResourceString("General.IncompatibleStateFileType"));
                            retVal = null;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ExceptionHandling.IsCriticalException(e))
                {
                    throw;
                }

                // The deserialization process seems like it can throw just about 
                // any exception imaginable.  Catch them all here.
                // Not being able to deserialize the cache is not an error, but we let the user know anyway.
                // Don't want to hold up processing just because we couldn't read the file.
                log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", stateFile, e.Message);
            }

            return retVal;
        }
Exemple #36
0
        public SymbolFixer(AssemblyDefinition assembly, PreloadingAssemblyResolver resolver, TaskLoggingHelper log)
        {
            this.Assembly = assembly;
            this.Resolver = resolver;
            this.Log = log;

            this.SigumEntities = assembly.Name.Name == "Signum.Entities" ? assembly : resolver.Resolve("Signum.Entities");
            this.SemiSymbolEntity = SigumEntities.MainModule.GetType("Signum.Entities", "Symbol");
        }
Exemple #37
0
 public BlobFeedAction(SleetSource sleetSource, string accountKey, MSBuild.TaskLoggingHelper log)
 {
     ContainerName = sleetSource.Container;
     RelativePath  = sleetSource.FeedSubPath;
     AccountName   = sleetSource.AccountName;
     AccountKey    = accountKey;
     hasToken      = true;
     Log           = log;
     source        = sleetSource;
 }
Exemple #38
0
 public BlobFeed(string accountName, string accountKey, string containerName, string relativePath, string indexDirectory, MSBuild.TaskLoggingHelper loggingHelper, bool isPublic)
 {
     AccountName    = accountName;
     AccountKey     = accountKey;
     ContainerName  = containerName;
     IndexDirectory = indexDirectory;
     RelativePath   = relativePath;
     IsPublic       = isPublic;
     Log            = loggingHelper;
 }
Exemple #39
0
        public BlobFeedAction(string expectedFeedUrl, string accountKey, string indexDirectory, MSBuild.TaskLoggingHelper Log)
        {
            this.Log = Log;
            Match m = Regex.Match(expectedFeedUrl, feedRegex);

            if (m.Success)
            {
                string accountName   = m.Groups["accountname"].Value;
                string containerName = m.Groups["containername"].Value;
                string relativePath  = m.Groups["relativepath"].Value;
                string feedUrl       = m.Groups["feedurl"].Value;

                bool isPublic = string.IsNullOrWhiteSpace(m.Groups["token"].Value);
                this.feed = new BlobFeed(accountName, accountKey, containerName, feedUrl, string.IsNullOrWhiteSpace(indexDirectory) ? Path.GetTempPath() : indexDirectory, Log, isPublic);
            }
            else
            {
                throw new Exception("Unable to parse expected feed. Please check ExpectedFeedUrl.");
            }
        }
Exemple #40
0
 /// <summary>
 /// Default (family) constructor.
 /// </summary>
 protected AppDomainIsolatedTask()
 {
     Log = new TaskLoggingHelper(this);
 }
 /// <summary>
 /// This method checks that the specified files exist. During the scan the
 /// least recent file write time of all the outputs is remembered. It will be
 /// the basis for up to date comparisons.
 /// </summary>
 /// <param name="files">The files being checked for existence.</param>
 /// <param name="log">The TaskLoggingHelper used to log the nonexistent files.</param>
 /// <param name="outputOldestFilename">Name of the least recently modified file.</param>
 /// <param name="outputOldestTime">Timestamp of the least recently modified file.</param>
 /// <returns>True if all members of 'files' exist, false otherwise</returns>
 internal static bool FilesExistAndRecordOldestWriteTime(ICollection <ITaskItem> files, TaskLoggingHelper log, out DateTime outputOldestTime, out string outputOldestFilename)
 => FilesExistAndRecordRequestedWriteTime(files, log, false /* return information about the oldest file */, out outputOldestTime, out outputOldestFilename);
        private static bool FilesExistAndRecordRequestedWriteTime(ICollection <ITaskItem> files, TaskLoggingHelper log, bool getNewest, out DateTime requestedTime, out string requestedFilename)
        {
            bool allExist = true;

            requestedTime     = getNewest ? DateTime.MinValue : DateTime.MaxValue;
            requestedFilename = string.Empty;

            // No output files for the source were tracked
            // safely assume that this is because we didn't track them because they weren't compiled
            if (files == null || files.Count == 0)
            {
                allExist = false;
            }
            else
            {
                foreach (ITaskItem item in files)
                {
                    DateTime lastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(item.ItemSpec);
                    // If the file does not exist
                    if (lastWriteTime == DateTime.MinValue)
                    {
                        Extension.FileTracker.LogMessageFromResources(log, MessageImportance.Low, "Tracking_OutputDoesNotExist", item.ItemSpec);
                        allExist = false;
                        break;
                    }

                    if (getNewest && lastWriteTime > requestedTime || !getNewest && lastWriteTime < requestedTime)
                    {
                        requestedTime     = lastWriteTime;
                        requestedFilename = item.ItemSpec;
                    }
                }
            }
            return(allExist);
        }
Exemple #43
0
        private static void WriteDeclareParametersToFile(Utilities.TaskLoggingHelper loggingHelper,
                                                         Framework.ITaskItem[] parameters,
                                                         string[] parameterAttributes,
                                                         string outputFileName,
                                                         bool foptimisticParameterDefaultValue,
                                                         string optimisticParameterMetadata)
        {
            Xml.XmlDocument document          = new System.Xml.XmlDocument();
            Xml.XmlElement  parametersElement = document.CreateElement("parameters");
            document.AppendChild(parametersElement);

            if (parameters != null)
            {
                System.Collections.Generic.Dictionary <string, Xml.XmlElement> dictionaryLookup
                    = new System.Collections.Generic.Dictionary <string, Xml.XmlElement>(parameters.GetLength(0), System.StringComparer.OrdinalIgnoreCase);

                // we are on purpose to keep the order without optimistic change the Value/Default base on the non-null optimistic
                System.Collections.Generic.IList <Framework.ITaskItem> items
                    = Utility.SortParametersTaskItems(parameters, foptimisticParameterDefaultValue, optimisticParameterMetadata);

                foreach (Framework.ITaskItem item in items)
                {
                    string         name             = item.ItemSpec;
                    Xml.XmlElement parameterElement = null;
                    bool           fCreateNew       = false;
                    if (!dictionaryLookup.TryGetValue(name, out parameterElement))
                    {
                        fCreateNew       = true;
                        parameterElement = document.CreateElement("parameter");
                        parameterElement.SetAttribute("name", name);
                        foreach (string attributeName in parameterAttributes)
                        {
                            string value = item.GetMetadata(attributeName);
                            parameterElement.SetAttribute(attributeName, value);
                        }
                        dictionaryLookup.Add(name, parameterElement);
                        parametersElement.AppendChild(parameterElement);
                    }
                    if (parameterElement != null)
                    {
                        string elementValue = item.GetMetadata(ExistingParameterValiationMetadata.Element.ToString());
                        if (string.IsNullOrEmpty(elementValue))
                        {
                            elementValue = "parameterEntry";
                        }

                        string[] parameterIdentities = s_parameterEntryIdentities;

                        if (string.Compare(elementValue, "parameterEntry", System.StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            parameterIdentities = s_parameterEntryIdentities;
                        }
                        else if (string.Compare(elementValue, "parameterValidation", System.StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            parameterIdentities = s_parameterValidationIdentities;
                        }

                        // from all existing node, if the parameter Entry is identical, we should not create a new one
                        int      parameterIdentitiesCount = parameterIdentities.GetLength(0);
                        string[] identityValues           = new string[parameterIdentitiesCount];
                        identityValues[0] = elementValue;

                        for (int i = 1; i < parameterIdentitiesCount; i++)
                        {
                            identityValues[i] = item.GetMetadata(parameterIdentities[i]);
                            if (string.Equals(parameterIdentities[i], ExistingDeclareParameterMetadata.Match.ToString().ToLowerInvariant()))
                            {
                                string metadataValue = item.GetMetadata(parameterIdentities[i]);

                                if (!string.IsNullOrEmpty(metadataValue) &&
                                    (Directory.Exists(metadataValue) ||
                                     File.Exists(metadataValue)))
                                {
                                    metadataValue = $"^{Regex.Escape(metadataValue)}$";
                                }

                                identityValues[i] = metadataValue;
                            }
                        }

                        if (!fCreateNew)
                        {
                            bool fIdentical = false;
                            foreach (Xml.XmlNode childNode in parameterElement.ChildNodes)
                            {
                                Xml.XmlElement childElement = childNode as Xml.XmlElement;
                                if (childElement != null)
                                {
                                    if (string.Compare(childElement.Name, identityValues[0], System.StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        fIdentical = true;
                                        for (int i = 1; i < parameterIdentitiesCount; i++)
                                        {
                                            // case sensitive comparesion  should be O.K.
                                            if (string.CompareOrdinal(identityValues[i], childElement.GetAttribute(parameterIdentities[i])) != 0)
                                            {
                                                fIdentical = false;
                                                break;
                                            }
                                        }
                                        if (fIdentical)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if (fIdentical)
                            {
                                // same ParameterEntry, skip this item
                                continue;
                            }
                        }

                        bool fAddEntry = false;
                        for (int i = 1; i < parameterIdentitiesCount; i++)
                        {
                            fAddEntry |= !string.IsNullOrEmpty(identityValues[i]);
                        }
                        if (fAddEntry)
                        {
                            Xml.XmlElement parameterEntry = document.CreateElement(identityValues[0]);
                            for (int i = 1; i < parameterIdentitiesCount; i++)
                            {
                                string attributeName = parameterIdentities[i];
                                string value         = identityValues[i];
                                if (!string.IsNullOrEmpty(value))
                                {
                                    parameterEntry.SetAttribute(attributeName, value);
                                }
                            }
                            parameterElement.AppendChild(parameterEntry);
                        }
                    }
                }
            }

            // Save the UTF8 and Indented
            Utility.SaveDocument(document, outputFileName, System.Text.Encoding.UTF8);
        }
Exemple #44
0
 public SleetLogger(MSBuild.TaskLoggingHelper log, LogLevel logLevel = default(LogLevel))
 {
     _log      = log;
     _logLevel = logLevel;
 }
Exemple #45
0
        /// <summary>
        /// Internal constructor
        /// </summary>
        /// <param name="ownerTask">The task that is using file tracker</param>
        /// <param name="tlogFilesLocal">The local .tlog files.</param>
        /// <param name="tlogFilesToIgnore">The .tlog files to ignore</param>
        /// <param name="skipMissingFiles">Ignore files that do not exist on disk</param>
        /// <param name="missingFileTimeUtc">The DateTime that should be recorded for missing file.</param>
        /// <param name="excludedInputPaths">The set of paths that contain files that are to be ignored during up to date check</param>
        private void InternalConstruct(ITask ownerTask, ITaskItem[] tlogFilesLocal, ITaskItem[] tlogFilesToIgnore, bool skipMissingFiles, DateTime missingFileTimeUtc, string[] excludedInputPaths)
        {
            if (ownerTask != null)
            {
                _log = new TaskLoggingHelper(ownerTask);
                _log.TaskResources     = AssemblyResources.PrimaryResources;
                _log.HelpKeywordPrefix = "MSBuild.";
            }

            ITaskItem[] expandedTlogFiles = TrackedDependencies.ExpandWildcards(tlogFilesLocal);

            if (tlogFilesToIgnore != null)
            {
                ITaskItem[] expandedTlogFilesToIgnore = TrackedDependencies.ExpandWildcards(tlogFilesToIgnore);

                if (expandedTlogFilesToIgnore.Length > 0)
                {
                    HashSet <string> ignore             = new HashSet <string>();
                    List <ITaskItem> remainingTlogFiles = new List <ITaskItem>();

                    foreach (ITaskItem tlogFileToIgnore in expandedTlogFilesToIgnore)
                    {
                        ignore.Add(tlogFileToIgnore.ItemSpec);
                    }

                    foreach (ITaskItem tlogFile in expandedTlogFiles)
                    {
                        if (!ignore.Contains(tlogFile.ItemSpec))
                        {
                            remainingTlogFiles.Add(tlogFile);
                        }
                    }

                    _tlogFiles = remainingTlogFiles.ToArray();
                }
                else
                {
                    _tlogFiles = expandedTlogFiles;
                }
            }
            else
            {
                _tlogFiles = expandedTlogFiles;
            }

            // We have no TLog files on disk, create a TLog marker from the
            // TLogFiles ItemSpec so we can fabricate one if we need to
            // This becomes our "first" tlog, since on the very first run, no tlogs
            // will exist, and if a compaction has been run (as part of the initial up-to-date check) then this
            // marker tlog will be created as empty.
            if (_tlogFiles == null || _tlogFiles.Length == 0)
            {
                _tlogMarker = tlogFilesLocal[0].ItemSpec.Replace("*", "1");
                _tlogMarker = _tlogMarker.Replace("?", "2");
            }

            if (excludedInputPaths != null)
            {
                // Assign our exclude paths to our lookup - and make sure that all recorded paths end in a slash so that
                // our "starts with" comparison doesn't pick up incomplete matches, such as C:\Foo matching C:\FooFile.txt
                foreach (string excludePath in excludedInputPaths)
                {
                    string fullexcludePath = FileUtilities.EnsureTrailingSlash(FileUtilities.NormalizePath(excludePath)).ToUpperInvariant();
                    _excludedInputPaths.Add(fullexcludePath);
                }
            }

            _tlogsAvailable     = TrackedDependencies.ItemsExist(_tlogFiles);
            _skipMissingFiles   = skipMissingFiles;
            _missingFileTimeUtc = missingFileTimeUtc.ToUniversalTime();
            if (_tlogFiles != null)
            {
                // Read the TLogs into our internal structures
                ConstructFileTable();
            }
        }
Exemple #46
0
 /// <summary>
 /// Logs a message of the given importance using the specified string.
 /// </summary>
 /// <remarks>This method is not thread-safe.</remarks>
 /// <param name="Log">The Log to log to.</param>
 /// <param name="importance">The importance level of the message.</param>
 /// <param name="message">The message string.</param>
 /// <param name="messageArgs">Optional arguments for formatting the message string.</param>
 /// <exception cref="ArgumentNullException">Thrown when <c>message</c> is null.</exception>
 internal static void LogMessage(TaskLoggingHelper Log, MessageImportance importance, string message, params object[] messageArgs)
 {
     // Only log when we have been passed a TaskLoggingHelper
     Log?.LogMessage(importance, message, messageArgs);
 }
Exemple #47
0
 /// <summary>
 /// Logs a warning using the specified resource string.
 /// </summary>
 /// <param name="Log">The Log to log to.</param>
 /// <param name="messageResourceName">The name of the string resource to load.</param>
 /// <param name="messageArgs">Optional arguments for formatting the loaded string.</param>
 /// <exception cref="ArgumentNullException">Thrown when <c>messageResourceName</c> is null.</exception>
 internal static void LogWarningWithCodeFromResources(TaskLoggingHelper Log, string messageResourceName, params object[] messageArgs)
 {
     // Only log when we have been passed a TaskLoggingHelper
     Log?.LogWarningWithCodeFromResources(messageResourceName, messageArgs);
 }
Exemple #48
0
 public MSBuildLogger(Utils.TaskLoggingHelper log)
 {
     this.log = log;
 }
 internal static bool FilesExistAndRecordOldestWriteTime(ITaskItem[] files, TaskLoggingHelper log, out DateTime outputOldestTime, out string outputOldestFilename)
 {
     return(FilesExistAndRecordRequestedWriteTime(files, log, false, out outputOldestTime, out outputOldestFilename));
 }
Exemple #50
0
        public static bool IsUpToDate(TaskLoggingHelper Log, UpToDateCheckType upToDateCheckType, FlatTrackingData inputs, FlatTrackingData outputs)
        {
            bool isUpToDate = false;
            // Keep a record of the task resources that was in use before
            ResourceManager taskResources = Log.TaskResources;

            Log.TaskResources = AssemblyResources.PrimaryResources;

            inputs.UpdateFileEntryDetails();
            outputs.UpdateFileEntryDetails();

            if (!inputs.TlogsAvailable || !outputs.TlogsAvailable || inputs.DependencyTable.Count == 0)
            {
                // 1) The TLogs are somehow missing, which means we need to build
                // 2) Because we are flat tracking, there are no roots which means that all the input file information
                //    comes from the input Tlogs, if they are empty then we must build.
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_LogFilesNotAvailable");
            }
            else if (inputs.MissingFiles.Count > 0 || outputs.MissingFiles.Count > 0)
            {
                // Files are missing from either inputs or outputs, that means we need to build

                // Files are missing from inputs, that means we need to build
                if (inputs.MissingFiles.Count > 0)
                {
                    Log.LogMessageFromResources(MessageImportance.Low, "Tracking_MissingInputs");
                }
                // Too much logging leads to poor performance
                if (inputs.MissingFiles.Count > MaxLogCount)
                {
                    FileTracker.LogMessageFromResources(Log, MessageImportance.Low, "Tracking_InputsNotShown", inputs.MissingFiles.Count);
                }
                else
                {
                    // We have our set of inputs, log the details
                    foreach (string input in inputs.MissingFiles)
                    {
                        FileTracker.LogMessage(Log, MessageImportance.Low, "\t" + input);
                    }
                }

                // Files are missing from outputs, that means we need to build
                if (outputs.MissingFiles.Count > 0)
                {
                    Log.LogMessageFromResources(MessageImportance.Low, "Tracking_MissingOutputs");
                }
                // Too much logging leads to poor performance
                if (outputs.MissingFiles.Count > MaxLogCount)
                {
                    FileTracker.LogMessageFromResources(Log, MessageImportance.Low, "Tracking_OutputsNotShown", outputs.MissingFiles.Count);
                }
                else
                {
                    // We have our set of inputs, log the details
                    foreach (string output in outputs.MissingFiles)
                    {
                        FileTracker.LogMessage(Log, MessageImportance.Low, "\t" + output);
                    }
                }
            }
            else if (upToDateCheckType == UpToDateCheckType.InputOrOutputNewerThanTracking &&
                     (inputs.NewestFileTimeUtc > inputs.NewestTLogTimeUtc))
            {
                // One of the inputs is newer than the input tlog
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_DependencyWasModifiedAt", inputs.NewestFileName, inputs.NewestFileTimeUtc, inputs.NewestTLogFileName, inputs.NewestTLogTimeUtc);
            }
            else if (upToDateCheckType == UpToDateCheckType.InputOrOutputNewerThanTracking &&
                     (outputs.NewestFileTimeUtc > outputs.NewestTLogTimeUtc))
            {
                // one of the outputs is newer than the output tlog
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_DependencyWasModifiedAt", outputs.NewestFileName, outputs.NewestFileTimeUtc, outputs.NewestTLogFileName, outputs.NewestTLogTimeUtc);
            }
            else if (upToDateCheckType == UpToDateCheckType.InputNewerThanOutput &&
                     (inputs.NewestFileTimeUtc > outputs.NewestFileTimeUtc))
            {
                // One of the inputs is newer than the outputs
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_DependencyWasModifiedAt", inputs.NewestFileName, inputs.NewestFileTimeUtc, outputs.NewestFileName, outputs.NewestFileTimeUtc);
            }
            else if (upToDateCheckType == UpToDateCheckType.InputNewerThanTracking &&
                     (inputs.NewestFileTimeUtc > inputs.NewestTLogTimeUtc))
            {
                // One of the inputs is newer than the one of the TLogs
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_DependencyWasModifiedAt", inputs.NewestFileName, inputs.NewestFileTimeUtc, inputs.NewestTLogFileName, inputs.NewestTLogTimeUtc);
            }
            else if (upToDateCheckType == UpToDateCheckType.InputNewerThanTracking &&
                     (inputs.NewestFileTimeUtc > outputs.NewestTLogTimeUtc))
            {
                // One of the inputs is newer than the one of the TLogs
                Log.LogMessageFromResources(MessageImportance.Low, "Tracking_DependencyWasModifiedAt", inputs.NewestFileName, inputs.NewestFileTimeUtc, outputs.NewestTLogFileName, outputs.NewestTLogTimeUtc);
            }
            else
            {
                // Nothing appears to have changed..
                isUpToDate = true;
                Log.LogMessageFromResources(MessageImportance.Normal, "Tracking_UpToDate");
            }

            // Set the task resources back now that we're done with it
            Log.TaskResources = taskResources;

            return(isUpToDate);
        }
 public BlobFeedAction(string accountName, string accountKey, string containerName, string indexDirectory, MSBuild.TaskLoggingHelper Log)
 {
     this.feed = new BlobFeed(accountName, accountKey, containerName, string.IsNullOrWhiteSpace(indexDirectory) ? Path.GetTempPath() : indexDirectory, Log);
     this.Log  = Log;
 }
Exemple #52
0
 /// <summary>
 /// This method checks that the specified files exist. During the scan the
 /// most recent file write time of all the outputs is remembered. It will be
 /// the basis for up to date comparisons.
 /// </summary>
 /// <param name="files">The files being checked for existence.</param>
 /// <param name="log">The TaskLoggingHelper used to log the nonexistent files.</param>
 /// <param name="outputNewestFilename">Name of the most recently modified file.</param>
 /// <param name="outputNewestTime">Timestamp of the most recently modified file.</param>
 /// <returns>True if all members of 'files' exist, false otherwise</returns>
 internal static bool FilesExistAndRecordNewestWriteTime(ITaskItem[] files, TaskLoggingHelper log, out DateTime outputNewestTime, out string outputNewestFilename)
 {
     return(FilesExistAndRecordRequestedWriteTime(files, log, true /* return information about the newest file */, out outputNewestTime, out outputNewestFilename));
 }
Exemple #53
0
 /// <summary>
 /// Default (family) constructor.
 /// </summary>
 protected Task()
 {
     Log = new TaskLoggingHelper(this);
 }
Exemple #54
0
 private static void WriteDeclareSetParametersToFile(Utilities.TaskLoggingHelper loggingHelper, Framework.ITaskItem[] parameters, string outputFileName, bool foptimisticParameterDefaultValue)
 {
     WriteDeclareParametersToFile(loggingHelper, parameters, s_setParameterAttributes, outputFileName, foptimisticParameterDefaultValue, SyncParameterMetadata.Value.ToString());
 }
Exemple #55
0
 public SleetLogger(MSBuild.TaskLoggingHelper log)
 {
     _log = log;
 }