.NET 솔루션에 대한 업데이트를 수행하는 도구가 있지만 솔루션이있는 디렉터리를 알아야합니다.프로그래밍 방식으로 현재 Visual Studio IDE 솔루션 디렉터리를 추가 기능에서 가져 오기
이러한 도구를 외부 도구로 추가했습니다.이 도구는 IDE 도구 메뉴에 표시되고 $(SolutionDir)
을 인수로 제공합니다. 이것은 잘 작동합니다.
그러나 Visual Studio 통합 패키지 프로젝트를 만든 사용자 지정 최상위 메뉴와 솔루션 노드의 상황에 맞는 메뉴를 통해이 도구를 IDE에서 쉽게 액세스 할 수 있기를 바랍니다. Visual Studio 추가 기능 프로젝트를 만들었습니다.) 이 컨텍스트를 통해 현재 솔루션 디렉토리를 얻는 방법을 찾고 있습니다.
은 내가VisualStudio.DTE
개체에서 솔루션 정보를 가져 오는 시도 :
EnvDTE.DTE dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");
string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);
그러나, 이것은 추가 기능이 아닌 현재의 솔루션을 솔루션 디렉토리를 반환합니다. 이 아니라 현재 솔루션의 IDE에 대한 디렉토리를 반환,
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "echo $(SolutionDir)");
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
을하지만 :
나는$(SolutionDir)
를 반향하고 그것을 다시 읽어했습니다.
솔루션 노드 CommandBar
에서 관련 정보를 찾지 못했습니다.
또는 정의 된 Visual Studio 외부 도구에 프로그래밍 방식으로 액세스하여 이미 정의 된 매크로 인수를 사용하여 시작할 수있는 방법이 있으면 작동합니다.
해결책은 무엇입니까?
분명히 나는이 DTE 광기 롤 – Terrance