use assembly="System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" use assembly="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" use namespace="System.IO" use namespace="System.IO.Compression" use namespace="System.Linq" use-standard-lifecycle k-standard-goals #repack-x86 target='compile' if='Directory.Exists("src") && !IsLinux' @{ var buildDir= Path.Combine(Directory.GetCurrentDirectory(), "artifacts", "build"); var projectName = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation"; var projectNupkg = Files .Include(Path.Combine(buildDir, projectName + "*.nupkg")) .Where(path => !path.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase)) .OrderByDescending(f => f) // On local builds multiple nupkgs are generated. .First(); Log.Info("Repacking Nupkg: " + projectNupkg); using (var zipArchive = ZipFile.Open(projectNupkg, ZipArchiveMode.Update)) { MoveEntry(zipArchive, "lib/net451/" + projectName + ".exe", "runtimes/win7-x64/lib/net451/" + projectName + ".exe"); MoveEntry(zipArchive, "lib/net451/" + projectName + "-x86.exe", "runtimes/win7-x86/lib/net451/" + projectName + "-x86.exe"); zipArchive.CreateEntry("lib/net451/_._"); } } functions @{ private static void MoveEntry(ZipArchive archive, string oldPath, string newPath) { var oldEntry = archive.GetEntry(oldPath); if (oldEntry == null) { throw new Exception(oldPath + " was not found in package."); } var newEntry = archive.CreateEntry(newPath); using (var newStream = newEntry.Open()) using (var oldStream = oldEntry.Open()) { oldStream.CopyTo(newStream); } oldEntry.Delete(); } }