public void InstallPackage(IPackage package) { var directoryToExpandTo = Path.Combine(_localRepository.Source, package.Id); foreach (var file in package.GetContentFiles()) { string pathWithoutContextPrefix = file.Path.Substring("content/".Length); var fullPath = Path.Combine(directoryToExpandTo, pathWithoutContextPrefix); Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); using (Stream writeStream = File.OpenWrite(fullPath), readStream = file.GetStream()) { readStream.CopyTo(writeStream); } } // If there is no xdt file, generate a default one string xdtPath = Path.Combine(directoryToExpandTo, "applicationHost.xdt"); if (!File.Exists(xdtPath)) { var xdtTemplate = new XdtTemplate { Path = package.Id }; File.WriteAllText(xdtPath, xdtTemplate.TransformText().Trim()); } var packageFile = Path.Combine( directoryToExpandTo, String.Format("{0}.{1}.nupkg", package.Id, package.Version)); using (Stream readStream = package.GetStream(), writeStream = File.OpenWrite(packageFile)) { readStream.CopyTo(writeStream); } }
public void InstallPackage(IPackage package) { var directoryToExpandTo = Path.Combine(_localRepository.Source, package.Id); foreach (var file in package.GetContentFiles()) { string pathWithoutContextPrefix = file.Path.Substring("content/".Length); var fullPath = Path.Combine(directoryToExpandTo, pathWithoutContextPrefix); Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); using (Stream writeStream = File.OpenWrite(fullPath), readStream = file.GetStream()) { readStream.CopyTo(writeStream); } } // If there is no xdt file, generate a default one string xdtPath = Path.Combine(directoryToExpandTo, "applicationHost.xdt"); if (!File.Exists(xdtPath)) { var xdtTemplate = new XdtTemplate { Path = package.Id }; File.WriteAllText(xdtPath, xdtTemplate.TransformText().Trim()); } var packageFile = Path.Combine( directoryToExpandTo, String.Format("{0}.{1}.nupkg", package.Id, package.Version)); using (Stream readStream = package.GetStream(), writeStream = File.OpenWrite(packageFile)) { readStream.CopyTo(writeStream); } }