private bool WillRunCustomToolOnBuild(ProjectItem projectItem) { IVsSolution solution = (IVsSolution)GetGlobalService(typeof(SVsSolution)); IVsHierarchy project; solution.GetProjectOfUniqueName(projectItem.ContainingProject.UniqueName, out project); string docFullPath = projectItem.GetPath(); if (docFullPath == null) { return(false); } string customTool = projectItem.GetValue("CustomTool") as string; if (customTool != null && customTool != string.Empty) { IVsBuildPropertyStorage storage = project as IVsBuildPropertyStorage; if (storage == null) { return(false); } uint itemId; if (project.ParseCanonicalName(docFullPath, out itemId) != 0) { return(false); } bool? isRunCustomTool = storage.GetBoolean(itemId, Property_RunCustomToolOnBuild); bool? isAlwaysRun = storage.GetBoolean(itemId, Property_AlwaysRun); List <string> referenceFiles = null; if (Path.GetExtension(docFullPath) == ".tt") //If it's a T4 file we query the reference assemblies. { referenceFiles = ExtensionHelper.GetReferenceAssemblies(docFullPath); } if (isRunCustomTool.HasValue && isRunCustomTool.Value) { if (isAlwaysRun.HasValue && isAlwaysRun.Value) { return(true); } // Get the solution file name string solDir, solFile, solOpts; solution.GetSolutionInfo(out solDir, out solFile, out solOpts); string lastBuiltIn = projectItem.GetLastSolution(); string lastConfigurationBuild = projectItem.GetLastConfiguration(); string activeConfiguration = GetActiveConfiguration(); if (lastBuiltIn == solFile && lastConfigurationBuild == activeConfiguration) //in the same solution { if (projectItem.HasChild()) { string generatedItemFileName = projectItem.GetGeneratedItem().GetPath(); if (!ExtensionHelper.IsFileEmpty(generatedItemFileName) && IsGeneratedFileUpdated(projectItem, referenceFiles, solDir, activeConfiguration)) { return(false); } } } else { projectItem.UpdateLastBuild(solFile, activeConfiguration); } return(true); } } return(false); }