Exemple #1
0
 private void AddAdminResources(Project _CurrentProject, string resourcefilename, string content)
 {
     //files for central administration
     if (Helpers2.IsSharePointVSTemplate(_CurrentProject.DTE, _CurrentProject))
     {
         AddResources(_CurrentProject, "Resources\\AppGlobalResources", resourcefilename, content, SPFileType.AppGlobalResource, "");
     }
     else
     {
         ProjectItems whereToAdd = Helpers2.GetDeploymentPath(_CurrentProject.DTE, _CurrentProject, SPFileType.RootFile, "CONFIG\\AdminResources");
         AddResourcesToFolder(whereToAdd.Parent as ProjectItem, resourcefilename, content);
     }
 }
Exemple #2
0
 private void AddApplicationResources(Project _CurrentProject, string resourcefilename, string content)
 {
     if (Helpers2.IsSharePointVSTemplate(_CurrentProject.DTE, _CurrentProject))
     {
         AddResources(_CurrentProject, "Resources\\AppGlobalResources", resourcefilename, content, SPFileType.AppGlobalResource, "");
     }
     else
     {
         //deploy resx file to 14\Config\Resources
         ProjectItems whereToAdd = Helpers2.GetDeploymentPath(_CurrentProject.DTE, _CurrentProject, SPFileType.RootFile, "CONFIG\\Resources");
         AddResourcesToFolder(whereToAdd.Parent as ProjectItem, resourcefilename, content);
     }
 }
Exemple #3
0
 private void AddGlobalResources(Project _CurrentProject, string resourcefilename, string content)
 {
     if (Helpers2.IsSharePointVSTemplate(_CurrentProject.DTE, _CurrentProject))
     {
         AddResources(_CurrentProject, "Resources\\Resources", resourcefilename, content, SPFileType.RootFile, "Resources");
     }
     else
     {
         //get the folder where to place the resx file
         ProjectItems whereToAdd = Helpers2.GetDeploymentPath(_CurrentProject.DTE, _CurrentProject, SPFileType.RootFile, "Resources");
         AddResourcesToFolder(whereToAdd.Parent as ProjectItem, resourcefilename, content);
     }
 }
        private void AddFileInternal(DTE dte, Project project, string evaluatedSourceFileName, string evaluatedTargetFileName, string evaluatedDeploymentPath)
        {
            if (!Path.IsPathRooted(evaluatedSourceFileName))
            {
                evaluatedSourceFileName = Path.Combine(GetTemplateBasePath(), evaluatedSourceFileName);
            }

            //ok, check the parameters
            if (!File.Exists(evaluatedSourceFileName))
            {
                //ignore this action if no source file is found, used e.g. in contenttype when no file is given
                return;
            }
            if (string.IsNullOrEmpty(evaluatedTargetFileName))
            {
                evaluatedTargetFileName = Path.GetFileName(evaluatedSourceFileName);
            }

            //targetfolder specified, find the project item
            if (!string.IsNullOrEmpty(TargetFolder) && (ParentProjectFolder == null))
            {
                //overwrite target folder
                ParentProjectFolder  = Helpers.GetFolder(project, TargetFolder, true);
                CreatedProjectFolder = this.ParentProjectFolder;
            }

            if (Helpers2.IsSharePointVSTemplate(dte, project))
            {
                if (this.ParentProjectItem != null)
                {
                    //used to add code files to a parent file
                    CreatedProjectItem = Helpers.AddFromTemplate(ParentProjectItem.ProjectItems, evaluatedSourceFileName, evaluatedTargetFileName, Overwrite);
                    if (DeploymentTypeIsSet)
                    {
                        SetDeploymentPath(dte, project, CreatedProjectItem, this.DeploymentType, evaluatedDeploymentPath);
                    }
                }
                else if (this.ParentProjectFolder != null)
                {
                    //we place the file directly in the given folder
                    //and mapped the item to the deployment location
                    CreatedProjectItem = Helpers.AddFromTemplate(this.ParentProjectFolder.ProjectItems, evaluatedSourceFileName, evaluatedTargetFileName, Overwrite);
                    if (DeploymentTypeIsSet)
                    {
                        SetDeploymentPath(dte, project, CreatedProjectItem, this.DeploymentType, evaluatedDeploymentPath);
                    }
                }
                else if (DeploymentTypeIsSet)
                {
                    //place the file in a mapped folder
                    ProjectItems whereToAdd = Helpers2.GetDeploymentPath(dte, project, this.DeploymentType, evaluatedDeploymentPath);
                    CreatedProjectItem = Helpers.AddFromTemplate(whereToAdd, evaluatedSourceFileName, evaluatedTargetFileName, Overwrite);
                    //do not set the deploymentpath as we already placed the file in the mapped folder location
                }
                else if (project != null)
                {
                    CreatedProjectItem = Helpers.AddFromTemplate(project.ProjectItems, evaluatedSourceFileName, evaluatedTargetFileName, Overwrite);
                }
                else
                {
                    throw new Exception("Don't know where to place the file");
                }
            }

            if (CreatedProjectItem != null)
            {
                //set the build action
                if (CreatedProjectItem.Name.EndsWith(".resx", StringComparison.InvariantCultureIgnoreCase))
                {
                    CreatedProjectItem.Properties.Item("BuildAction").Value = 2;
                }
            }


            if (this.Open)
            {
                if (this.CreatedProjectItem != null)
                {
                    Window window = this.CreatedProjectItem.Open("{00000000-0000-0000-0000-000000000000}");
                    window.Visible = true;
                    window.Activate();
                }
            }
        }