private void SetDeploymentPath(DTE dte, Project project, ProjectItem CreatedProjectItem, SPFileType sPFileType, string evaluatedDeploymentPath) { //set to content if ((sPFileType != SPFileType.CustomCode)) { CreatedProjectItem.Properties.Item("BuildAction").Value = 2; } //ok, file is placed, but we need set the deployment path ISharePointProjectService projectService = Helpers2.GetSharePointProjectService(dte); ISharePointProject sharePointProject = projectService.Convert <EnvDTE.Project, ISharePointProject>(project); sharePointProject.Synchronize(); if (CreatedProjectItem.Collection.Parent is ProjectItem) { ProjectItem parentItem = CreatedProjectItem.Collection.Parent as ProjectItem; string name = parentItem.Name; //is the parent element a feature? try { ISharePointProjectFeature parentIsFeature = projectService.Convert <EnvDTE.ProjectItem, ISharePointProjectFeature>(parentItem); if (parentIsFeature != null) { ISharePointProjectItem addedSharePointItem = projectService.Convert <EnvDTE.ProjectItem, ISharePointProjectItem>(CreatedProjectItem); if (addedSharePointItem != null) { parentIsFeature.ProjectItems.Add(addedSharePointItem); } } } catch { } } try { //sometimes property deploymentpath is readonly //1. new added items need to be validated before ISharePointProjectItemFile newaddedSharePointItem = projectService.Convert <EnvDTE.ProjectItem, ISharePointProjectItemFile>(CreatedProjectItem); newaddedSharePointItem.DeploymentType = Helpers2.GetDeploymentTypeFromFileType(this.DeploymentType); if (!string.IsNullOrEmpty(evaluatedDeploymentPath)) { newaddedSharePointItem.DeploymentPath = evaluatedDeploymentPath; } } catch { } }