/// <summary> /// Make the given path relative to the project file. /// </summary> protected internal string MakeProjectRelative(string filename) { string projectPath; ErrorHandler.ThrowOnFailure(ProjectMgr.GetCanonicalName((uint)VSConstants.VSITEMID.Root, out projectPath)); // Try to use common prefix to avoid upper/lower differences. var i = 0; var max = Math.Min(filename.Length, projectPath.Length); while (i < max) { if (char.ToUpper(filename[i]) != char.ToUpper(projectPath[i])) { break; } i++; } if (i > 0) { projectPath = filename.Substring(0, i) + projectPath.Substring(i); } var result = PackageUtilities.MakeRelative(projectPath, filename); return(result); }