Frage

Ich habe mit den MS Source Server Sachen in den MS Debugging Tool spielt um zu installieren.

Derzeit Ich bin mit meinem Code / PDBS durch die Subversion Indexierungsbefehl, der nun wie erwartet läuft. Es erzeugt den Strom für eine gegebene PDB-Datei und schreibt sie in die PDB-Datei.

Allerdings, wenn ich die DLL und die damit verbundenen pdb in Visual Studio 2008, heißt es der Quellcode kann nicht abgerufen werden.

Wenn ich die PDB gegen srctool überprüfen ist, sagt keine der Quelldateien enthalten sind indiziert werden, was sehr merkwürdig ist, da der Prozess vor lief gut.

Wenn ich den Strom überprüfen, die von dem svnindex.cmd Laufe für die PDB generiert wurden, srctool sagt, dass alle Quelldateien indiziert werden.

Warum sollte ein Unterschied sein?

Ich habe die PDB-Datei in einem Texteditor geöffnet und ich kann die ursprünglichen Verweise auf die Quelldateien auf meinem Rechner (auch unter dem srcsrv Header-Namen) und die neuen „injiziert“ Quellserver Links zu meiner Subversion-Repository) sehen.

Sollten noch beide Referenzen in der PDB existieren? Ich hätte man erwartet, entfernt werden?

So oder so, Visual Studio 2008 wird meine Source-Referenzen nicht abholen, damit ich ein wenig verloren bin, was als nächstes zu versuchen. Soweit ich sagen kann, ich habe alles getan, was ich haben sollte.

Jedermann haben ähnliche Erfahrungen gemacht?

Vielen Dank.

War es hilfreich?

Lösung

Ich habe mein Problem gelöst - den Quelldateipfad, der während der Build zum HVE geschrieben wurde, um ein etwas andere als Teil der Index Aufgabe Subversion Quelle geschrieben

.

Das muss die Quellensuche in Visual Studio als die beiden Pfade ungültig stimmen nicht überein.

Auch meinen eigenen vereinfachte Quellenindex Strom meiner PDB-Dateien aus einer benutzerdefinierten NAnt Aufgabe zu schreiben, die unser SCM-System Vault hakt nach oben.

Andere Tipps

Es gibt eine Option in den Optionen \ Debugging \ Symbol von Visual Studio Protokolle des Quellservers zu emittieren.
Darüber hinaus müssen Sie die neueste Version von srcsrv.dll, einfach herunterladen die neueste WinDBG kopieren sie die DLL von dort aus und stellen sie sicher, dass Visual Studio verwendet es.

Nicht im Alter hier gewesen, sorry. Es ist ganz spezifisch für unsere Gesellschaft braucht. Sollte genug sein, um zu zeigen, was allerdings vor sich geht.

Code-Schnipsel unter:

PdbFile.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Code.Integration.SourceIndex
{
    public class PdbFile
    {
        private FileInfo _pdbFile;

        public FileInfo Pdb
        {
            get { return _pdbFile; }
        }

        public PdbFile(FileInfo pdbFile)
        {
            if (pdbFile == null)
                throw new ArgumentNullException("pdbFile");

            if (!pdbFile.Exists)
                throw new ArgumentException(string.Format("Pdb file specified \"{0}\" does not exist.", pdbFile.FullName), "pdbFile");

            _pdbFile = pdbFile;
        }

        // Read source files
        // Write source stream
    }
}

PdbUtil.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace Code.Integration.SourceIndex
{
    public static class PdbUtil
    {
        private static readonly string SRCTOOL_PATH_1 = @"C:\Program Files\Debugging Tools for Windows\srcsrv\srctool.exe";
        private static readonly string SRCTOOL_PATH_2 = @"C:\Program Files\Debugging Tools for Windows (x86)\srcsrv\srctool.exe";
        private static readonly string PDBSTR_PATH_1 = @"C:\Program Files\Debugging Tools for Windows\srcsrv\pdbstr.exe";
        private static readonly string PDBSTR_PATH_2 = @"C:\Program Files\Debugging Tools for Windows (x86)\srcsrv\pdbstr.exe";

        private static string SRCTOOL = "";
        private static string PDBSTR = "";

        static PdbUtil()
        {
            if (File.Exists(SRCTOOL_PATH_1))
                SRCTOOL = SRCTOOL_PATH_1;
            else if (File.Exists(SRCTOOL_PATH_2))
                SRCTOOL = SRCTOOL_PATH_2;

            if (File.Exists(PDBSTR_PATH_1))
                PDBSTR = PDBSTR_PATH_1;
            else if (File.Exists(PDBSTR_PATH_2))
                PDBSTR = PDBSTR_PATH_2;
        }

        private static void EnsureToolsExist()
        {
            if (string.IsNullOrEmpty(SRCTOOL))
                throw new ApplicationException(string.Format("SRCTOOL does not exist. Is it installed?", SRCTOOL));

            if (string.IsNullOrEmpty(PDBSTR))
                throw new ApplicationException(string.Format("PDBSTR does not exist. Is it installed?", PDBSTR));
        }

        public static List<string> ReadSourceFiles(PdbFile pdb)
        {
            EnsureToolsExist();

            ProcessStartInfo info = new ProcessStartInfo(SRCTOOL);

            info.UseShellExecute = false;
            info.RedirectStandardError = true;
            info.RedirectStandardOutput = true;
            info.Arguments = string.Format("-r \"{0}\"", pdb.Pdb.FullName);

            string output;
            string errors;

            using (Process p = Process.Start(info))
            {
                output = p.StandardOutput.ReadToEnd();
                errors = p.StandardError.ReadToEnd();

                p.WaitForExit();
            }

            if (!string.IsNullOrEmpty(errors))
                throw new ApplicationException(string.Format("Error reading pdb source files \"{0}\".", errors));

            List<string> result = new List<string>();

            if (!string.IsNullOrEmpty(output))
            {
                foreach (string item in output.Split('\r', '\n'))
                {
                    string sourceFile = item.Trim();

                    if (string.IsNullOrEmpty(sourceFile))
                        continue;

                    result.Add(sourceFile);
                }
            }

            return result;
        }

        public static void WriteSourceFileStream(PdbFile pdb, FileInfo stream)
        {
            EnsureToolsExist();

            ProcessStartInfo info = new ProcessStartInfo(PDBSTR);

            info.UseShellExecute = false;
            info.RedirectStandardError = true;
            info.RedirectStandardOutput = true;
            info.Arguments = string.Format("-w -s:srcsrv -p:\"{0}\" -i:\"{1}\"", pdb.Pdb.FullName, stream.FullName);

            string output;
            string errors;

            using (Process p = Process.Start(info))
            {
                output = p.StandardOutput.ReadToEnd();
                errors = p.StandardError.ReadToEnd();

                p.WaitForExit();
            }

            if (!string.IsNullOrEmpty(errors))
                throw new ApplicationException(string.Format("Error writing to pdb \"{0}\".", errors));
        }
    }
}

SourceIndexTask.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

using NAnt.Core;
using NAnt.Core.Attributes;
using NAnt.Core.Types;

using Code.Integration.SourceIndex;

namespace Code.Integration.NAnt.Tasks.SourceIndex
{
    [TaskName("codesourceindex")]
    public class SourceIndexTask : Task
    {
        private FileSet _pdbs = new FileSet();
        private string _build = "0.0.0.0";
        private string _repositoryName = "";
        private string _repositoryProjectStart = "";
        private string _user = "";
        private string _password = "";
        private string _server = "";

        #region Properties

        /// <summary>
        /// FileSet of pdbs to process.
        /// </summary>
        [BuildElement("pdbs")]
        public FileSet Pdbs
        {
            get { return _pdbs; }
            set { _pdbs = value; }
        }

        /// <summary>
        /// Build label to extract.
        /// Default is "0.0.0.0".
        /// </summary>
        [TaskAttribute("build", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string Build
        {
            get { return _build; }
            set { _build = value; }
        }

        /// <summary>
        /// Name of repository we are working on.
        /// </summary>
        [TaskAttribute("reponame", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string RepositoryName
        {
            get { return _repositoryName; }
            set { _repositoryName = value; }
        }

        /// <summary>
        /// Name of start folder within project we are working on. i.e. if the 
        /// repository was "Code 2-0" then the repository project start could be "/Code/Trunk"
        /// or "/Code/Branches/1.0.0.123/"
        /// </summary>
        [TaskAttribute("repoprojectstart", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string RepositoryProjectStart
        {
            get { return _repositoryProjectStart; }
            set { _repositoryProjectStart = value; }
        }

        /// <summary>
        /// Vault user with repository access.
        /// </summary>
        [TaskAttribute("user", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string User
        {
            get { return _user; }
            set { _user = value; }
        }

        /// <summary>
        /// Vault user password.
        /// </summary>
        [TaskAttribute("password", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string Password
        {
            get { return _password; }
            set { _password = value; }
        }

        /// <summary>
        /// Location of Vault server.
        /// </summary>
        [TaskAttribute("server", Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string Server
        {
            get { return _server; }
            set { _server = value; }
        }

        #endregion

        protected override void ExecuteTask()
        {
            try
            {
                WriteFiles();
            }
            catch (Exception exception)
            {
                throw new BuildException("Source indexing could not be completed.", Location, exception);
            }
        }

        private void WriteFiles()
        {
            foreach (string fileName in Pdbs.FileNames)
            {
                Log(Level.Info, string.Format("Processing '{0}'.", fileName));

                PdbFile pdb = new PdbFile(new FileInfo(fileName));
                List<string> sourceFiles = PdbUtil.ReadSourceFiles(pdb);
                string tmpFile = Path.GetFullPath(Path.GetTempFileName());

                try
                {
                    using (StreamWriter sw = new StreamWriter(tmpFile))
                    {
                        sw.WriteLine("SRCSRV: ini ------------------------------------------------");
                        sw.WriteLine("VERSION=1");
                        sw.WriteLine("VERCTRL=VAULT");
                        sw.WriteLine("DATETIME=" + DateTime.Now.ToUniversalTime().ToString("u"));
                        sw.WriteLine("SRCSRV: variables ------------------------------------------");
                        sw.WriteLine("VAULT_USER=" + User);
                        sw.WriteLine("VAULT_PASS=" + Password);
                        sw.WriteLine("VAULT_SRV=" + Server);
                        sw.WriteLine("VAULT_EXTRACT_TARGET=%targ%%fnbksl%(%var3%)\\%var4%\\%fnfile%(%var1%)");
                        sw.WriteLine("VAULT_EXTRACT_FOLDER=%targ%%fnbksl%(%var3%)\\%var4%");
                        sw.WriteLine("VAULT_EXTRACT_CMD=\"C:\\Program Files\\SourceGear\\Vault Client\\vault.exe\" getlabel -host %vault_srv% -user %vault_user% -password %vault_pass% -repository \"%var2%\" \"$%var3%\" %var4% -nonworkingfolder \"%vault_extract_folder%\" > \"%vault_extract_target%.log\"");
                        sw.WriteLine("SRCSRVTRG=%vault_extract_target%");
                        sw.WriteLine("SRCSRVCMD=%vault_extract_cmd%");
                        sw.WriteLine("SRCSRV: source files ---------------------------------------");

                        foreach (string sourceFile in sourceFiles)
                        {
                            // Will build against something like:
                            // D:\CruiseControl.NET.Working\Solutions 2.0\Code\Code\Trunk\Working\Solution\..
                            // Don't want "Working" folder name in there either.
                            // Need to generate Vault repo path to asset:
                            // /Code/Trunk/Solution/..

                            // 1. Pass in repo start - /Code/Trunk
                            // 2. Redirect slashes and search for \Code\Trunk
                            // 3. Find first index and split at index to get - \Code\Trunk\Working\Solution\..
                            // 4. Remove "Working\"
                            // 5. Flip slashes again to get - /Code/Trunk/Solution/..

                            // Problems:
                            // 1. Passing in "Trunk" - would need to work that out dynamically over time

                            string repositoryPath = sourceFile;

                            int index = sourceFile.IndexOf(RepositoryProjectStart.Replace("/", @"\"));
                            if (index != -1)
                                repositoryPath = sourceFile.Substring(index);

                            repositoryPath = repositoryPath.Replace(@"Working\", "");
                            repositoryPath = repositoryPath.Replace(@"\", "/");

                            sw.Write(sourceFile);
                            sw.Write("*");
                            sw.Write(RepositoryName);
                            sw.Write("*");
                            sw.Write(repositoryPath);
                            sw.Write("*");
                            sw.Write(Build);
                            sw.WriteLine();
                        }

                        sw.WriteLine("SRCSRV: end ------------------------------------------------");
                    }

                    Log(Level.Debug, string.Format("Generated stream '{0}'.", File.ReadAllText(tmpFile)));

                    // Write the stream to the pdb file
                    PdbUtil.WriteSourceFileStream(pdb, new FileInfo(tmpFile));

                    Log(Level.Info, "Written stream to pdb.");
                }
                finally
                {
                    if (File.Exists(tmpFile))
                        File.Delete(tmpFile);
                }
            }
        }
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top