Beispiel #1
0
 /// <summary>
 /// Adds the source files.
 /// </summary>
 /// <param name="files">The files.</param>
 public void AddSourceFiles(IEnumerable<string> files)
 {
     foreach (string file in files)
     {
         SourceFile sourceFile = new SourceFile(file);
         SourceFiles.Add(sourceFile);
     }
 }
        private void AddProperties(SourceFile sourceFile, Entry entry)
        {
            sourceFile.Properties["Revision"] = entry.Revision;

            string baseUri = entry.Repository.Root;
            if (!baseUri.EndsWith("/"))
                baseUri += "/";

            sourceFile.Properties["Root"] = baseUri;
            sourceFile.Properties["Url"] = entry.Url;

            Uri root = new Uri(baseUri);
            Uri fullPath = new Uri(entry.Url);
            Uri itemPath = root.MakeRelativeUri(fullPath);

            sourceFile.Properties["ItemPath"] = itemPath.ToString();

            sourceFile.Properties["CommitRevision"] = entry.Commit.Revision;
            sourceFile.Properties["CommitAuthor"] = entry.Commit.Author;

            if (entry.Commit.DateSpecified)
                sourceFile.Properties["CommitDate"] = entry.Commit.Date;

            sourceFile.Properties["Kind"] = entry.Kind;

            if (!string.Equals(entry.WorkingCopy.Schedule, "normal", StringComparison.OrdinalIgnoreCase))
                Log.LogWarning("Source file '{0}' has pending changes. Index may point to incorrect revision.", sourceFile.File.FullName);
            else if (entry.Revision == 0)
                Log.LogWarning("Source file '{0}' has a revision of zero.", sourceFile.File.FullName);

            sourceFile.IsResolved = true;
        }
        /// <summary>
        /// Creates an instance of <see cref="SymbolFile"/> from the symbol file task item and add the source file list to it.
        /// </summary>
        /// <param name="item">The symbol file task item.</param>
        /// <returns>An instance of <see cref="SymbolFile"/> or <c>null</c> if there was an error.</returns>
        protected virtual SymbolFile CreateSymbolFile(ITaskItem item)
        {
            SymbolFile symbolFile = new SymbolFile(item.ItemSpec);

            var srcTool = new SrcTool();
            CopyBuildEngine(srcTool);

            if (!string.IsNullOrEmpty(SourceServerSdkPath))
                srcTool.ToolPath = SourceServerSdkPath;

            srcTool.PdbFile = item;

            // step 1: check if source already indexed
            this.NoSourceInformationInPdb = false;
            srcTool.CountOnly = true;
            srcTool.Execute();
            if (srcTool.SourceCount > 0)
            {
                Log.LogWarning("'{0}' already has source indexing information.", symbolFile.File.Name);
                Skipped++;
                return null;
            }
            srcTool.CountOnly = false; // turn off 

            // step 2: get source file list from pdb
            srcTool.SourceOnly = true;
            if (!srcTool.Execute())
            {
                if (srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 &&
                    srcTool.SourceFiles[0].StartsWith("No source information in pdb for"))
                {
                    this.NoSourceInformationInPdb = true;
                }

                if (this.FailOnNoSourceInformationFound)
                {
                    Log.LogError("Error getting source files from '{0}'.{1}", symbolFile.File.Name, srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 ? srcTool.SourceFiles[0] : string.Empty);                
                    Failed++;
                }
                else
                {
                    Log.LogWarning("'{0}' has no source information inside the pdb. Check your pdb settings or perhaps your assembly doesn't have any real lines of code in it?", symbolFile.File.Name, srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 ? srcTool.SourceFiles[0] : string.Empty);                
                    Skipped++;
                }
                return null;
            }

            foreach (string file in srcTool.SourceFiles)
            {
                // check that we didn't get garbage back from SrcTool.  
                if (!PathUtil.IsPathValid(file))
                {
                    Log.LogMessage(MessageImportance.Low, "  Invalid path for source file '{0}'.", file);
                    continue;
                }

                SourceFile sourceFile = new SourceFile(file);
                symbolFile.SourceFiles.Add(sourceFile);
            }

            return symbolFile;
        }
        /// <summary>
        /// Creates an instance of <see cref="SymbolFile"/> from the symbol file task item and add the source file list to it.
        /// </summary>
        /// <param name="item">The symbol file task item.</param>
        /// <returns>An instance of <see cref="SymbolFile"/> or <c>null</c> if there was an error.</returns>
        protected virtual SymbolFile CreateSymbolFile(ITaskItem item)
        {
            SymbolFile symbolFile = new SymbolFile(item.ItemSpec);

            var srcTool = new SrcTool();
            CopyBuildEngine(srcTool);

            if (!string.IsNullOrEmpty(SourceServerSdkPath))
                srcTool.ToolPath = SourceServerSdkPath;

            srcTool.PdbFile = item;

            // step 1: check if source already indexed
            srcTool.CountOnly = true;
            srcTool.Execute();
            if (srcTool.SourceCount > 0)
            {
                Log.LogWarning("'{0}' already has source indexing information.", symbolFile.File.Name);
                Skipped++;
                return null;
            }
            srcTool.CountOnly = false; // turn off

            // step 2: get source file list from pdb
            srcTool.SourceOnly = true;
            if (!srcTool.Execute())
            {
                Log.LogError("Error getting source files from '{0}'.", symbolFile.File.Name);
                Failed++;
                return null;
            }

            foreach (string file in srcTool.SourceFiles)
            {
                // check that we didn't get garbage back from SrcTool.
                if (!PathUtil.IsPathValid(file))
                {
                    Log.LogMessage(MessageImportance.Low, "  Invalid path for source file '{0}'.", file);
                    continue;
                }

                SourceFile sourceFile = new SourceFile(file);
                symbolFile.SourceFiles.Add(sourceFile);
            }

            return symbolFile;
        }
Beispiel #5
0
        /// <summary>
        /// Creates an instance of <see cref="SymbolFile"/> from the symbol file task item and add the source file list to it.
        /// </summary>
        /// <param name="item">The symbol file task item.</param>
        /// <returns>An instance of <see cref="SymbolFile"/> or <c>null</c> if there was an error.</returns>
        protected virtual SymbolFile CreateSymbolFile(ITaskItem item)
        {
            SymbolFile symbolFile = new SymbolFile(item.ItemSpec);

            var srcTool = new SrcTool();

            CopyBuildEngine(srcTool);

            if (!string.IsNullOrEmpty(SourceServerSdkPath))
            {
                srcTool.ToolPath = SourceServerSdkPath;
            }

            srcTool.PdbFile = item;

            // step 1: check if source already indexed
            this.NoSourceInformationInPdb = false;
            srcTool.CountOnly             = true;
            srcTool.Execute();
            if (srcTool.SourceCount > 0)
            {
                Log.LogWarning("'{0}' already has source indexing information.", symbolFile.File.Name);
                Skipped++;
                return(null);
            }
            srcTool.CountOnly = false; // turn off

            // step 2: get source file list from pdb
            srcTool.SourceOnly = true;
            if (!srcTool.Execute())
            {
                if (srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 &&
                    srcTool.SourceFiles[0].StartsWith("No source information in pdb for"))
                {
                    this.NoSourceInformationInPdb = true;
                }

                if (this.FailOnNoSourceInformationFound)
                {
                    Log.LogError("Error getting source files from '{0}'.{1}", symbolFile.File.Name, srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 ? srcTool.SourceFiles[0] : string.Empty);
                    Failed++;
                }
                else
                {
                    Log.LogWarning("'{0}' has no source information inside the pdb. Check your pdb settings or perhaps your assembly doesn't have any real lines of code in it?", symbolFile.File.Name, srcTool.SourceFiles != null && srcTool.SourceFiles.Length > 0 ? srcTool.SourceFiles[0] : string.Empty);
                    Skipped++;
                }
                return(null);
            }

            foreach (string file in srcTool.SourceFiles)
            {
                // check that we didn't get garbage back from SrcTool.
                if (!PathUtil.IsPathValid(file))
                {
                    Log.LogMessage(MessageImportance.Low, "  Invalid path for source file '{0}'.", file);
                    continue;
                }

                SourceFile sourceFile = new SourceFile(file);
                symbolFile.SourceFiles.Add(sourceFile);
            }

            return(symbolFile);
        }