From 0611c82423d1a1ad5283cb9e3341facb62d57001 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 1 Jun 2015 15:22:24 +0200 Subject: [PATCH] Do not duplicate files in the nupkg - fixes #851 --- RELEASE_NOTES.md | 2 +- src/Paket.Core/NupkgWriter.fs | 21 ++++++++++++--------- src/Paket/Paket.fsproj | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 31f67e7154..daf3876405 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -#### 1.9.2 - 01.06.2015 +#### 1.9.3 - 01.06.2015 * Do not duplicate files in the nupkg - https://github.com/fsprojects/Paket/issues/851 #### 1.9.1 - 01.06.2015 diff --git a/src/Paket.Core/NupkgWriter.fs b/src/Paket.Core/NupkgWriter.fs index 64aee01a45..0283db1773 100644 --- a/src/Paket.Core/NupkgWriter.fs +++ b/src/Paket.Core/NupkgWriter.fs @@ -195,15 +195,21 @@ let Write (core : CompleteCoreInfo) optional workingDir outputDir = use zipToCreate = new FileStream(outputPath, FileMode.Create) use zipFile = new ZipArchive(zipToCreate,ZipArchiveMode.Create) - let entries = System.Collections.Generic.List<_>() + let entries = System.Collections.Generic.List<_>() - let addEntry (zipFile : ZipArchive) path writerF = + let addEntry path writerF = + if entries.Contains(path) then () else entries.Add path |> ignore let entry = zipFile.CreateEntry(path) use stream = entry.Open() writerF stream stream.Close() + let addEntryFromFile path source = + if entries.Contains(path) then () else + entries.Add path |> ignore + zipFile.CreateEntryFromFile(source,path) |> ignore + let ensureValidTargetName (target:string) = match target.Replace(" ", "%20").Replace("\\", "/") with | t when t.EndsWith("/") -> t @@ -216,8 +222,7 @@ let Write (core : CompleteCoreInfo) optional workingDir outputDir = for file in Directory.EnumerateFiles(source,"*.*",SearchOption.TopDirectoryOnly) do let fi = FileInfo file let path = Path.Combine(target,fi.Name) - entries.Add path |> ignore - zipFile.CreateEntryFromFile(fi.FullName,path) |> ignore + addEntryFromFile path fi.FullName for dir in Directory.EnumerateDirectories(source,"*",SearchOption.TopDirectoryOnly) do let di = DirectoryInfo dir @@ -233,20 +238,18 @@ let Write (core : CompleteCoreInfo) optional workingDir outputDir = if File.Exists source then let fi = FileInfo(source) let path = Path.Combine(targetFileName,fi.Name) - entries.Add path |> ignore - zipFile.CreateEntryFromFile(source, path) |> ignore + addEntryFromFile path source else failwithf "Could not find source file %s" source // add metadata for path, writer in writeNupkg core optional do - addEntry zipFile path writer + addEntry path writer entries - |> Seq.distinct |> Seq.toList |> contentTypeDoc |> xDocWriter - |> addEntry zipFile contentTypePath + |> addEntry contentTypePath outputPath diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index da6541ab3c..535023c82c 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -32,10 +32,10 @@ paket.exe D:\code\Pakettest D:\code\Paketkopie - install + pack output bin/ version 1.2.4 releaseNotes "Implement Hashcode-based sifting extensions." Project paket.exe - d:\code\pakettest + d:\code\fspickler pdbonly