/// <summary> /// Copies to bin. /// </summary> /// <param name="project">The project.</param> /// <param name="fileName">Name of the file.</param> public static void CopyToBin(ISharePointProject project, string fileName) { try { List <string> appPaths = new List <string>(); appPaths = DeploymentUtilities.GetWebApplicationPhysicalPaths(project.ProjectService, project); if (appPaths.Count() <= 0) { appPaths.Add(DeploymentUtilities.GetWebApplicationDefaultPhysicalPath(project.ProjectService, project.SiteUrl.ToString())); } if (appPaths.Count() <= 0) { throw new Exception(string.Format("Unable to retrieve Web Application bin path for URL: {0}", project.SiteUrl.ToString())); } else { foreach (string destinationPath in appPaths) { string fullSource = DeploymentUtilities.SubstituteRootTokens(project, fileName); string fullDestination = DeploymentUtilities.SubstituteRootTokens(project, Path.Combine(Path.Combine(destinationPath, "bin"), Path.GetFileName(fileName))); project.ProjectService.Logger.ActivateOutputWindow(); project.ProjectService.Logger.WriteLine(fileName + " -> " + fullDestination, LogCategory.Status); // Copy the file, letting exceptions be thrown and caught below (e.g. don't check source path). EnsureFileIsNotReadOnly(fullDestination); File.Copy(fullSource, fullDestination, true); EnsureFileIsNotReadOnly(fullDestination); } } } catch (Exception ex) { project.ProjectService.Logger.ActivateOutputWindow(); project.ProjectService.Logger.WriteLine("EXCEPTION: " + ex.Message, LogCategory.Error); } }
//TODO: is this right? it has the same token twice /// <summary> /// Uns the tokenize. /// </summary> /// <param name="feature">The feature.</param> /// <param name="tokenString">The token string.</param> /// <returns></returns> public static string UnTokenize(this ISharePointProjectFeature feature, string tokenString) { if (feature != null) { tokenString = tokenString.Replace("$SharePoint.Project.FileNameWithoutExtension$", Path.GetFileNameWithoutExtension(feature.Project.FullPath)); tokenString = tokenString.Replace("$SharePoint.Feature.FileNameWithoutExtension$", DeploymentUtilities.GetLastFolderName(feature.FullPath)); } return(tokenString); }