private static string GetOriginalFile(string wszInputFilePath) { var dte = Package.GetGlobalService(typeof(SDTE)) as DTE; var project = dte.GetSelectedProject(); var relFile = DteHelper.MakeRelative(wszInputFilePath, project.GetProjectDirectory()); var pi = project.GetProjectItem(relFile); foreach (ProjectItem item in pi.ProjectItems) { // It possible for the project item to be corrupt. (ie project has a reference to a file, but the file is gone). // when this happens the item will have a NULL document. if (item.Document != null) { return(item.Document.FullName); } } return(null); }