Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Paket.NupkgWriter.Test

open System.IO
open System.IO.Compression
open Paket
open FsUnit
open NUnit.Framework

[<Test>]
let ``#3906 paket pack escapes square brackets in file names``() =
let workingDir = Path.Combine(Path.GetTempPath(), "paket-nupkgwriter-test-" + System.Guid.NewGuid().ToString("N"))
let outputDir = Path.Combine(workingDir, "out")
let harvestDir = Path.Combine(workingDir, "harvest")
Directory.CreateDirectory harvestDir |> ignore
Directory.CreateDirectory outputDir |> ignore
try
let bracketFile = Path.Combine(harvestDir, "file[0].txt")
File.WriteAllText(bracketFile, "content")

let core : CompleteCoreInfo =
{ Id = "Test.Package"
Version = Some (SemVer.Parse "1.0.0")
Authors = ["Author"]
Description = "Description"
Symbols = false }

let optional =
{ OptionalPackagingInfo.Empty with
Files = ["harvest", "lib/net461"] }

let outputPath = NupkgWriter.Write core optional workingDir outputDir

use archive = ZipFile.OpenRead outputPath
let entryNames = archive.Entries |> Seq.map (fun e -> e.FullName) |> Seq.toList

entryNames |> shouldContain "lib/net461/file%5B0%5D.txt"
entryNames |> List.contains "lib/net461/file[0].txt" |> shouldEqual false
finally
if Directory.Exists workingDir then Directory.Delete(workingDir, true)
1 change: 1 addition & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
<Compile Include="InstallModel\InstallNuGetContentsTests.fs" />
<Compile Include="InstallModel\PaketPropsTests.fs" />
<Compile Include="Packaging\PackageProcessSpecs.fs" />
<Compile Include="Packaging\NupkgWriterSpecs.fs" />
<Compile Include="Packaging\NuspecWriterSpecs.fs" />
<Compile Include="Packaging\TemplateFileParsing.fs" />
<Compile Include="Packaging\RemotePushUrlSpecs.fs" />
Expand Down
Loading