public static string InstallExecutablePackage(PackageIdentity package, NuGetFramework projectFramework, PackageReaderBase packageReader, string targetPath) { var targetId = Path.GetFileName(targetPath); var targetEntryPoint = targetId + Constants.BonsaiExtension; var targetEntryPointLayout = targetEntryPoint + Constants.LayoutExtension; var packageEntryPoint = package.Id + Constants.BonsaiExtension; var packageEntryPointLayout = packageEntryPoint + Constants.LayoutExtension; var nearestFrameworkGroup = packageReader.GetContentItems().GetNearest(projectFramework); if (nearestFrameworkGroup != null) { foreach (var file in nearestFrameworkGroup.Items) { var effectivePath = PathUtility.GetRelativePath(ContentFolder, file); if (effectivePath == packageEntryPoint) { effectivePath = targetEntryPoint; } else if (effectivePath == packageEntryPointLayout) { effectivePath = targetEntryPointLayout; } effectivePath = Path.Combine(targetPath, effectivePath); PathUtility.EnsureParentDirectory(effectivePath); using (var stream = packageReader.GetStream(file)) using (var targetStream = File.Create(effectivePath)) { stream.CopyTo(targetStream); } } } var effectiveEntryPoint = Path.Combine(targetPath, targetEntryPoint); if (!File.Exists(effectiveEntryPoint)) { var message = string.Format(Resources.MissingWorkflowEntryPoint, targetEntryPoint); throw new InvalidOperationException(message); } var manifestFile = packageReader.GetNuspecFile(); var metadataPath = Path.Combine(targetPath, targetId + NuGetConstants.ManifestExtension); using (var manifestStream = packageReader.GetStream(manifestFile)) using (var manifestTargetStream = File.Create(metadataPath)) { var manifest = Manifest.ReadFrom(manifestStream, validateSchema: true); manifest.Save(manifestTargetStream); } return(effectiveEntryPoint); }
public static IEnumerable <string> FindPivots(PackageReaderBase package, string installPath) { return(from file in package.GetFiles() where Path.GetFileName(file) == PivotListFileName from pivot in ReadAllLines(package.GetStream(file)) select pivot); }
public static NuGetVersion FindOverlayVersion(PackageReaderBase package) { return((from file in package.GetFiles() where Path.GetFileName(file) == NuGetOverlayCommandFileName from line in ReadAllLines(package.GetStream(file)) where line.StartsWith(NuGetOverlayCommand) let version = line.Split(' ') .SkipWhile(xs => xs != NuGetOverlayVersionArgument) .Skip(1) .FirstOrDefault() select NuGetVersion.Parse(version)).FirstOrDefault()); }
public static IReadOnlyDictionary <NuGetFramework, IReadOnlyList <TypeChanges> > ComparePackageTypes(PackageReaderBase package1, PackageReaderBase package2, out NuGetVersion suggestedVersion) { if (package1 == null) { throw new ArgumentNullException(nameof(package1)); } if (package2 == null) { throw new ArgumentNullException(nameof(package2)); } var frameworkChanges = new Dictionary <NuGetFramework, IReadOnlyList <TypeChanges> >(); foreach (var targetFramework in package1.GetSupportedFrameworks()) { var typeChanges = new List <TypeChanges>(); frameworkChanges.Add(targetFramework, typeChanges.AsReadOnly()); var dlls1 = package1.GetAssemblyReferences(targetFramework).ToList(); var dlls2 = package2.GetAssemblyReferences(targetFramework).ToList(); if (dlls1.Count != 0 && dlls2.Count == 0) { typeChanges.Add(new TypeChanges(null, new[] { Change.NonBreaking("Framework support removed: {0}", targetFramework) }.ToList().AsReadOnly())); continue; } var changes = new List <Change>(); foreach (var file1 in dlls1) { if (dlls2.Contains(file1)) { typeChanges.AddRange(FindChanges(package1.GetStream(file1), package2.GetStream(file1))); } else { changes.Add(Change.Breaking("Assembly removed: {0}", file1)); } } if (changes.Count != 0) { typeChanges.Add(new TypeChanges(null, changes.AsReadOnly())); } } suggestedVersion = SuggestVersion(package1.GetIdentity().Version, frameworkChanges.SelectMany(x => x.Value.SelectMany(y => y.Changes)).ToList()); return(frameworkChanges); }
static void UpdateFile(string path, PackageReaderBase packageReader, string file) { using Stream fromStream = packageReader.GetStream(file), toStream = File.Create(path); fromStream.CopyTo(toStream); }