Пример #1
0
 /// <summary>
 /// Quick copy this artefact in the context of the specific package, and the specific containing artefact only.
 /// </summary>
 /// <param name="packageProject">The project.</param>
 /// <param name="parentArtefact">The deployable SharePoint artefact.</param>
 /// <param name="requiresQuickPackage">Flag to indicate it requires a quick package.</param>
 public override void QuickCopy(SharePointPackageArtefact packageProject, QuickCopyableSharePointArtefact parentArtefact, bool requiresQuickPackage)
 {
     if (parentArtefact == null)
     {
         throw new NotSupportedException();
     }
     else if (parentArtefact is SharePointProjectFeatureArtefact || parentArtefact is SharePointPackageArtefact)
     {
         SharePointProjectFeatureArtefact feature = parentArtefact as SharePointProjectFeatureArtefact;
         this.QuickCopy(packageProject, feature, requiresQuickPackage);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #2
0
 /// <summary>
 /// Quick copy this artefact in the context of the specific package, but wherever this artefact is contained in that package.
 /// </summary>
 /// <param name="packageProject"></param>
 /// <param name="requiresQuickPackage"></param>
 public override void QuickCopy(SharePointPackageArtefact packageProject, bool requiresQuickPackage)
 {
     // We are directly deploying just this SPI and have not been called by our parent.
     // An SPI may be included in multiple features, or be against the project directly.
     if (item.IsDirectPartOfProjectPackage(packageProject.Project))
     {
         // Pass in the package itself as the parent.
         this.QuickCopy(packageProject, packageProject, requiresQuickPackage);
     }
     else
     {
         // The SPI may be included in multiple features in the project in context.
         foreach (ISharePointProjectFeature feature in item.GetFeaturesWhereInPackage(packageProject.Project))
         {
             QuickCopyableSharePointArtefact parent = new SharePointProjectFeatureArtefact(feature);
             this.QuickCopy(packageProject, parent, requiresQuickPackage);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Quick copy this artefact in the context of the specific package, and the specific containing artefact only.
        /// </summary>
        /// <param name="packageProject">The project.</param>
        /// <param name="parentFeature">The deployable SharePoint artefact.</param>
        /// <param name="requiresQuickPackage">Flag to indicate it requires a quick package.</param>
        public void QuickCopy(SharePointPackageArtefact packageProject, SharePointProjectFeatureArtefact parentFeature, bool requiresQuickPackage)
        {
            if (file.DeploymentType != DeploymentType.NoDeployment)
            {
                // Determine the folder name of the parent feature (if applicable).
                string featureFolderName = parentFeature == null ? "" : parentFeature.FeatureFolderName;

                // The default destination path is given to us by the tooling (though includes tokens).
                string destinationPathHiveRelative = String.Empty;
                if (String.IsNullOrEmpty(file.DeploymentPath))
                {
                    destinationPathHiveRelative = file.DeploymentRoot;
                }
                else
                {
                    destinationPathHiveRelative = Path.Combine(file.DeploymentRoot, file.DeploymentPath);
                }

                // The source path of the packageable file begins with the base package path of the project.
                string sourcePackagePathProjectRelative = packageProject.BasePackagePath;

                // The remainder of the package path depends on the type of file.
                if (file.DeploymentType == DeploymentType.ElementFile || file.DeploymentType == DeploymentType.ElementManifest)
                {
                    // Source path within pkg is {FeatureName} + the item's relative path.
                    sourcePackagePathProjectRelative = Path.Combine(sourcePackagePathProjectRelative, featureFolderName);
                    sourcePackagePathProjectRelative = Path.Combine(sourcePackagePathProjectRelative, Path.GetDirectoryName(file.RelativePath));
                }
                if (file.DeploymentType == DeploymentType.AppGlobalResource || file.DeploymentType == DeploymentType.ApplicationResource)
                {
                    sourcePackagePathProjectRelative = Path.Combine(sourcePackagePathProjectRelative, Path.GetDirectoryName(file.RelativePath));
                }
                else if (file.DeploymentType == DeploymentType.RootFile || file.DeploymentType == DeploymentType.TemplateFile)
                {
                    // For both template and root files, these are stored relative to the pkg folder with a
                    // path matching file.DeploymentPath.
                    sourcePackagePathProjectRelative = Path.Combine(sourcePackagePathProjectRelative, Path.GetDirectoryName(file.DeploymentPath));
                }
                else
                {
                    // Unhandled file type.  Just show a message for now.
                    // TODO: check all the file types we should spuport and test.
                    packageProject.Project.ProjectService.Logger.ActivateOutputWindow();
                    packageProject.Project.ProjectService.Logger.WriteLine(string.Format("Unhandled File Type - {0} at {1} - please notify the CKSDEV team", file.DeploymentType, file.FullPath), LogCategory.Status);
                }

                // Make some final substitutions on the paths as necessary.
                sourcePackagePathProjectRelative = sourcePackagePathProjectRelative.Replace("{FeatureName}", featureFolderName);
                destinationPathHiveRelative      = destinationPathHiveRelative.Replace("{FeatureName}", featureFolderName);

                // First package (if appropriate), then quick copy the file.
                if (requiresQuickPackage)
                {
                    // The actual project file path is also given to us by the tooling.
                    string originalFileProjectRelative = Path.GetDirectoryName(file.FullPath);

                    Dictionary <string, string> allTokens = null;
                    if (DeploymentUtilities.IsTokenReplacementFile(file.Project, file.Name))
                    {
                        // Tokens consist of those from this package, SPI, and (optionally) the feature.
                        allTokens = new Dictionary <string, string>();
                        allTokens.AddRange(packageProject.GetReplacementTokens());
                        allTokens.AddRange(new SharePointProjectItemArtefact(file.ProjectItem).GetReplacementTokens());
                        if (parentFeature != null)
                        {
                            allTokens.AddRange(parentFeature.GetReplacementTokens());
                        }
                    }

                    DeploymentUtilities.CopyFileWithTokenReplacement(packageProject.Project, file.Name, originalFileProjectRelative, sourcePackagePathProjectRelative, allTokens);
                }

                DeploymentUtilities.CopyFile(packageProject.Project, file.Name, sourcePackagePathProjectRelative, destinationPathHiveRelative);
            }
        }