internal static void QuickDeployItem(DTE dte, ProjectItem selectedItem, ref int successes, ref int failures, ref int overwritten) { //is file or folder? if (selectedItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile) { //file try { string sourcefilename = Helpers.GetFullPathOfProjectItem(selectedItem); if (!Helpers2.IsFileDeployableToHive(sourcefilename)) { //ignore CS files return; } string pathToHive = Helpers.GetSharePointHive(); //returns 'web server extensions/14', but we need without 14 string relativetargetFileName = GetDeploymentPathOfItem(dte, selectedItem); //starting with template if (!string.IsNullOrEmpty(relativetargetFileName)) { string fullTargetPath = pathToHive + relativetargetFileName; //replace SharePoint attributes Helpers.LogMessage(dte, dte, "Copying " + sourcefilename); if (File.Exists(fullTargetPath)) { overwritten++; } File.Copy(sourcefilename, fullTargetPath, true); //replace SharePoint Arguments ReplaceTokens(fullTargetPath); successes++; } } catch (Exception ex2) { failures++; Helpers.LogMessage(dte, dte, ex2.Message); } } else { foreach (ProjectItem childItem in selectedItem.ProjectItems) { QuickDeployItem(dte, childItem, ref successes, ref failures, ref overwritten); } } }
private bool ItemIsDeployable(ProjectItem pitem) { string sourcefilename = Helpers.GetFullPathOfProjectItem(pitem); if (!Helpers2.IsFileDeployableToHive(sourcefilename)) { return(false); } try { ISharePointProjectService projectService = Helpers2.GetSharePointProjectService(pitem.DTE); try { ISharePointProjectItemFile selectedSharePointItem = projectService.Convert <EnvDTE.ProjectItem, ISharePointProjectItemFile>(pitem); if (selectedSharePointItem != null && selectedSharePointItem.DeploymentPath != "") { return(true); } } catch { } } catch { } //check if the parent is folder 12 try { string itemPath = Helpers.GetFullPathOfProjectItem(pitem); string projectPath = Helpers.GetProjectFolder(pitem.ContainingProject); itemPath = itemPath.Substring(projectPath.Length + 1); if (itemPath.StartsWith(@"12") || itemPath.StartsWith(@"14") || itemPath.StartsWith(@"15") || itemPath.StartsWith(@"SharePointRoot", StringComparison.InvariantCultureIgnoreCase)) { return(true); } } catch { } return(false); }