@@ -5,6 +5,8 @@ open SimpleExec
5
5
open NUnit.Framework
6
6
open System.IO
7
7
open System.IO .Compression
8
+ open BlackFox.CommandLine
9
+ open System
8
10
9
11
let private expectToFailWithMessage projectName ( message : string ) =
10
12
task {
@@ -42,6 +44,13 @@ let ``Missing FableTarget property should report an error`` () =
42
44
Workspace.fixtures.invalid.`` MissingFableTarget.fsproj ``
43
45
" You need to set at least one of Fable target via the PackageTags property. Possible values are: fable-dart, fable-dotnet, fable-javascript, fable-python, fable-rust, fable-all."
44
46
47
+ // Test disabled because it freeze on Github
48
+ // [<Test>]
49
+ // let ``Missing FableTarget property should report an error - MultiTFM`` () =
50
+ // expectToFailWithMessage
51
+ // Workspace.fixtures.invalid.``MissingFableTargetMultiTFM.fsproj``
52
+ // "You need to set at least one of Fable target via the PackageTags property. Possible values are: fable-dart, fable-dotnet, fable-javascript, fable-python, fable-rust, fable-all."
53
+
45
54
[<Test>]
46
55
let ``You cannot set both FablePackageType and FableTarget properties`` () =
47
56
task {
@@ -237,20 +246,78 @@ let ``should include the source file and the project file under 'fable' folder``
237
246
$" pack %s {Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``}"
238
247
)
239
248
240
- let archive = ZipFile.OpenRead( VirtualWorkspace.fixtures.valid.`` library-with-files `` .bin.Release.`` MyLibrary.1.0.0.nupkg `` )
249
+ let archive =
250
+ ZipFile.OpenRead(
251
+ VirtualWorkspace.fixtures.valid.`` library-with-files `` .bin.Release.`` MyLibrary.1.0.0.nupkg ``
252
+ )
241
253
242
- let entries =
243
- archive.Entries
244
- |> Seq.map ( fun entry -> entry.FullName)
245
- |> Seq.toList
254
+ let entries = archive.Entries |> Seq.map ( fun entry -> entry.FullName) |> Seq.toList
246
255
247
- Assert.That(
248
- entries,
249
- Contains.Item( " fable/Entry.fs" )
256
+ Assert.That( entries, Contains.Item( " fable/Entry.fs" ))
257
+
258
+ Assert.That( entries, Contains.Item( " fable/MyLibrary.fsproj" ))
259
+ }
260
+
261
+ [<Test>]
262
+ let ``should include the source file and the project file under 'fable' folder - MultiTFM`` () =
263
+ task {
264
+ // Make sure we work with a fresh nupkg file
265
+ let fileInfo =
266
+ VirtualWorkspace.fixtures.valid.`` library-with-files-multi-tfm `` .bin.Release.`` MyLibraryMultiTFM.1.0.0.nupkg ``
267
+ |> FileInfo
268
+
269
+ if fileInfo.Exists then
270
+ fileInfo.Delete()
271
+
272
+ // When testing against multi Target Framework we need to use a "real package"
273
+ // because using the standard "Import" trick is not enough to capture errors
274
+ let tempPackageFolder = VirtualWorkspace.temp.`` . `` |> FileInfo
275
+
276
+ if tempPackageFolder.Exists then
277
+ tempPackageFolder.Delete()
278
+
279
+ let tempVersion = " 9.999.0-local-build-" + DateTime.Now.ToString( " yyyyMMdd-HHmmss" )
280
+
281
+ Command.Run(
282
+ " dotnet" ,
283
+ CmdLine.empty
284
+ |> CmdLine.append " pack"
285
+ |> CmdLine.append Workspace.`` .. `` .src.`` . ``
286
+ |> CmdLine.appendPrefix " -o" tempPackageFolder.FullName
287
+ |> CmdLine.append $" /p:PackageVersion=%s {tempVersion}"
288
+ |> CmdLine.toString
250
289
)
251
290
252
- Assert.That(
253
- entries,
254
- Contains.Item( " fable/MyLibrary.fsproj" )
291
+ Command.Run(
292
+ " dotnet" ,
293
+ CmdLine.empty
294
+ |> CmdLine.append " add"
295
+ |> CmdLine.appendPrefix " package" " Fable.Package.SDK"
296
+ |> CmdLine.appendPrefix " --version" tempVersion
297
+ |> CmdLine.appendPrefix " --source" tempPackageFolder.FullName
298
+ |> CmdLine.toString,
299
+ workingDirectory = Workspace.fixtures.valid.`` library-with-files-multi-tfm `` .`` . ``
300
+ )
301
+
302
+ Command.Run(
303
+ " dotnet" ,
304
+ $" pack %s {Workspace.fixtures.valid.``library-with-files-multi-tfm``.``MyLibraryMultiTFM.fsproj``}"
255
305
)
306
+
307
+ // Restore modified file to avoid polluting the Git history
308
+ Command.Run(
309
+ " git" ,
310
+ $" restore %s {Workspace.fixtures.valid.``library-with-files-multi-tfm``.``MyLibraryMultiTFM.fsproj``}"
311
+ )
312
+
313
+ let archive =
314
+ ZipFile.OpenRead(
315
+ VirtualWorkspace.fixtures.valid.`` library-with-files-multi-tfm `` .bin.Release.`` MyLibraryMultiTFM.1.0.0.nupkg ``
316
+ )
317
+
318
+ let entries = archive.Entries |> Seq.map ( fun entry -> entry.FullName) |> Seq.toList
319
+
320
+ Assert.That( entries, Contains.Item( " fable/Entry.fs" ))
321
+
322
+ Assert.That( entries, Contains.Item( " fable/MyLibraryMultiTFM.fsproj" ))
256
323
}
0 commit comments