private void AddFiles(string basePath, string source, string destination, string exclude = null) { string fileName = Path.GetFileName(source); // treat empty files specially if (Constants.PackageEmptyFileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)) { string destinationPath = Path.GetDirectoryName(destination); if (String.IsNullOrEmpty(destinationPath)) { destinationPath = Path.GetDirectoryName(source); } Files.Add(new EmptyFolderFile(destinationPath)); } else { List <PackageFileBase> searchFiles = PathResolver.ResolveSearchPattern(basePath, source, destination).ToList(); ExcludeFiles(searchFiles, basePath, exclude); if (!PathResolver.IsWildcardSearch(source) && !PathResolver.IsDirectoryPath(source) && !searchFiles.Any()) { throw new FileNotFoundException(String.Format(CultureInfo.CurrentCulture, NuGetResources.PackageAuthoring_FileNotFound, source)); } Files.AddRange(searchFiles); } }
private void AddFiles(string basePath, string source, string destination, string exclude = null) { List <PhysicalPackageFile> searchFiles = PathResolver.ResolveSearchPattern(basePath, source, destination, _includeEmptyDirectories).ToList(); if (_includeEmptyDirectories) { // we only allow empty directories which are legit framework folders. // Folders for nuget v3 should be included here also since this part of nuget.core is still used // by nuget.exe 3.3.0. searchFiles.RemoveAll(file => file.TargetFramework == null && Path.GetFileName(file.TargetPath) == Constants.PackageEmptyFileName && !IsKnownV3Folder(file.TargetPath)); } ExcludeFiles(searchFiles, basePath, exclude); if (!PathResolver.IsWildcardSearch(source) && !PathResolver.IsDirectoryPath(source) && !searchFiles.Any()) { throw new FileNotFoundException( String.Format(CultureInfo.CurrentCulture, NuGetResources.PackageAuthoring_FileNotFound, source)); } Files.AddRange(searchFiles); }
private void AddFiles(string basePath, string source, string destination, string exclude = null) { List <PhysicalPackageFile> searchFiles = PathResolver.ResolveSearchPattern(basePath, source, destination, _includeEmptyDirectories).ToList(); ExcludeFiles(searchFiles, basePath, exclude); if (!PathResolver.IsWildcardSearch(source) && !PathResolver.IsDirectoryPath(source) && !searchFiles.Any()) { // TODO: Resources throw new FileNotFoundException( String.Format(CultureInfo.CurrentCulture, "NuGetResources.PackageAuthoring_FileNotFound {0}", source)); } Files.AddRange(searchFiles); }
private void AddFiles(string basePath, string source, string destination, string exclude = null) { List <PhysicalPackageFile> searchFiles = PathResolver.ResolveSearchPattern(basePath, source, destination, this._includeEmptyDirectories).ToList <PhysicalPackageFile>(); if (this._includeEmptyDirectories) { searchFiles.RemoveAll(file => (file.TargetFramework == null) && (Path.GetFileName(file.TargetPath) == "_._")); } ExcludeFiles(searchFiles, basePath, exclude); if (PathResolver.IsWildcardSearch(source) || (PathResolver.IsDirectoryPath(source) || searchFiles.Any <PhysicalPackageFile>())) { this.Files.AddRange <IPackageFile>(searchFiles); } else { object[] args = new object[] { source }; throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, NuGetResources.PackageAuthoring_FileNotFound, args)); } }