public void AddPackage(IPackage package, IEnumerable <string> files) { lock (thisLock) { var filepath = Path.Combine(rootDirectory.FullName, GetPackagePath(package.Name, package.SemanticVersion())); var packageFolder = Path.Combine(rootDirectory.FullName, GetPackageRoot(package.Name, package.SemanticVersion())); if (Directory.Exists(packageFolder)) { Directory.Delete(packageFolder, true); } if (!Directory.Exists(packageFolder)) { Directory.CreateDirectory(packageFolder); } using (var stream = PackageBuilder.CreatePackage(package, files)) { using (var fileStream = File.Create(filepath)) { stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(fileStream); } } ManifestHelper.Save(package, Path.Combine(packageFolder, Constants.ManifestFileName)); } }
public void TestMethodSaveFile() { var manifest = ManifestHelper.Load("Ressources\\Manifest.xml"); ManifestHelper.Save(manifest, "Manifest.xml"); Assert.IsTrue(File.Exists("Manifest.xml")); }
public void TestMethodSaveStream() { var manifest = ManifestHelper.Load("Ressources\\Manifest.xml"); using (var stream = new FileStream("Manifest.xml", FileMode.Create, FileAccess.Write)) { ManifestHelper.Save(manifest, stream); } Assert.IsTrue(File.Exists("Manifest.xml")); }