使用VS自动化模型代码片段 Private Properties #region Private Properties private DTE VS { get { return (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); } } private string SolutionDirectory { get { EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); string solutionDirectory = Path.GetDirectoryName((string)dte.Solution.Properties.Item("Path").Value); return solutionDirectory; } } /**//// <summary> /// The directory of webservice proxies project /// </summary> private string Destination { get { EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); string solutionDirectory = Path.GetDirectoryName((string)dte.Solution.Properties.Item("Path").Value); string destination = Path.Combine(solutionDirectory, webserviceProxiesProjectName); return destination; } } private IUIService UIService { get { return GetService<IUIService>(true); } } #endregion 转载于:https://www.cnblogs.com/wmz/archive/2008/02/01/1061209.html