diff --git a/.gitignore b/.gitignore
index a26a3df..d073157 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,7 @@ bin/
.DS_Store
node_modules/
demo/dist/
+
+# Don't track this file because we dynamically install packages for it during the build process
+tests/fixtures/valid/library-with-files-multi-tfm/packages.lock.json
+tests/temp/
diff --git a/Directory.Packages.props b/Directory.Packages.props
index c324d60..3163449 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,6 +3,7 @@
true
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Fable.Package.SDK.fsproj b/src/Fable.Package.SDK.fsproj
index d4ec874..aa2e7af 100644
--- a/src/Fable.Package.SDK.fsproj
+++ b/src/Fable.Package.SDK.fsproj
@@ -16,6 +16,11 @@
Include="build\*"
Pack="true"
PackagePath="build\" />
+
+
diff --git a/tests/Fable.Package.SDK.Tests.fsproj b/tests/Fable.Package.SDK.Tests.fsproj
index fecddf2..811dfc6 100644
--- a/tests/Fable.Package.SDK.Tests.fsproj
+++ b/tests/Fable.Package.SDK.Tests.fsproj
@@ -3,12 +3,14 @@
Exe
net8.0
+ true
+
diff --git a/tests/Main.fs b/tests/Main.fs
index 9bbf041..19faa8b 100644
--- a/tests/Main.fs
+++ b/tests/Main.fs
@@ -5,6 +5,8 @@ open SimpleExec
open NUnit.Framework
open System.IO
open System.IO.Compression
+open BlackFox.CommandLine
+open System
let private expectToFailWithMessage projectName (message: string) =
task {
@@ -42,6 +44,13 @@ let ``Missing FableTarget property should report an error`` () =
Workspace.fixtures.invalid.``MissingFableTarget.fsproj``
"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."
+// Test disabled because it freeze on Github
+// []
+// let ``Missing FableTarget property should report an error - MultiTFM`` () =
+// expectToFailWithMessage
+// Workspace.fixtures.invalid.``MissingFableTargetMultiTFM.fsproj``
+// "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."
+
[]
let ``You cannot set both FablePackageType and FableTarget properties`` () =
task {
@@ -237,20 +246,78 @@ let ``should include the source file and the project file under 'fable' folder``
$"pack %s{Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``}"
)
- let archive = ZipFile.OpenRead(VirtualWorkspace.fixtures.valid.``library-with-files``.bin.Release.``MyLibrary.1.0.0.nupkg``)
+ let archive =
+ ZipFile.OpenRead(
+ VirtualWorkspace.fixtures.valid.``library-with-files``.bin.Release.``MyLibrary.1.0.0.nupkg``
+ )
- let entries =
- archive.Entries
- |> Seq.map (fun entry -> entry.FullName)
- |> Seq.toList
+ let entries = archive.Entries |> Seq.map (fun entry -> entry.FullName) |> Seq.toList
- Assert.That(
- entries,
- Contains.Item("fable/Entry.fs")
+ Assert.That(entries, Contains.Item("fable/Entry.fs"))
+
+ Assert.That(entries, Contains.Item("fable/MyLibrary.fsproj"))
+ }
+
+[]
+let ``should include the source file and the project file under 'fable' folder - MultiTFM`` () =
+ task {
+ // Make sure we work with a fresh nupkg file
+ let fileInfo =
+ VirtualWorkspace.fixtures.valid.``library-with-files-multi-tfm``.bin.Release.``MyLibraryMultiTFM.1.0.0.nupkg``
+ |> FileInfo
+
+ if fileInfo.Exists then
+ fileInfo.Delete()
+
+ // When testing against multi Target Framework we need to use a "real package"
+ // because using the standard "Import" trick is not enough to capture errors
+ let tempPackageFolder = VirtualWorkspace.temp.``.`` |> FileInfo
+
+ if tempPackageFolder.Exists then
+ tempPackageFolder.Delete()
+
+ let tempVersion = "9.999.0-local-build-" + DateTime.Now.ToString("yyyyMMdd-HHmmss")
+
+ Command.Run(
+ "dotnet",
+ CmdLine.empty
+ |> CmdLine.append "pack"
+ |> CmdLine.append Workspace.``..``.src.``.``
+ |> CmdLine.appendPrefix "-o" tempPackageFolder.FullName
+ |> CmdLine.append $"/p:PackageVersion=%s{tempVersion}"
+ |> CmdLine.toString
)
- Assert.That(
- entries,
- Contains.Item("fable/MyLibrary.fsproj")
+ Command.Run(
+ "dotnet",
+ CmdLine.empty
+ |> CmdLine.append "add"
+ |> CmdLine.appendPrefix "package" "Fable.Package.SDK"
+ |> CmdLine.appendPrefix "--version" tempVersion
+ |> CmdLine.appendPrefix "--source" tempPackageFolder.FullName
+ |> CmdLine.toString,
+ workingDirectory = Workspace.fixtures.valid.``library-with-files-multi-tfm``.``.``
+ )
+
+ Command.Run(
+ "dotnet",
+ $"pack %s{Workspace.fixtures.valid.``library-with-files-multi-tfm``.``MyLibraryMultiTFM.fsproj``}"
)
+
+ // Restore modified file to avoid polluting the Git history
+ Command.Run(
+ "git",
+ $"restore %s{Workspace.fixtures.valid.``library-with-files-multi-tfm``.``MyLibraryMultiTFM.fsproj``}"
+ )
+
+ let archive =
+ ZipFile.OpenRead(
+ VirtualWorkspace.fixtures.valid.``library-with-files-multi-tfm``.bin.Release.``MyLibraryMultiTFM.1.0.0.nupkg``
+ )
+
+ let entries = archive.Entries |> Seq.map (fun entry -> entry.FullName) |> Seq.toList
+
+ Assert.That(entries, Contains.Item("fable/Entry.fs"))
+
+ Assert.That(entries, Contains.Item("fable/MyLibraryMultiTFM.fsproj"))
}
diff --git a/tests/Workspace.fs b/tests/Workspace.fs
index aec90c9..75c2ccb 100644
--- a/tests/Workspace.fs
+++ b/tests/Workspace.fs
@@ -7,10 +7,15 @@ type Workspace = RelativeFileSystem<".">
type VirtualWorkspace = VirtualFileSystem<".",
"""
+temp/
fixtures/
valid/
library-with-files/
bin/
Release/
MyLibrary.1.0.0.nupkg
+ library-with-files-multi-tfm/
+ bin/
+ Release/
+ MyLibraryMultiTFM.1.0.0.nupkg
""">
diff --git a/tests/fixtures/Directory.Build.props b/tests/fixtures/Directory.Build.props
new file mode 100644
index 0000000..6879125
--- /dev/null
+++ b/tests/fixtures/Directory.Build.props
@@ -0,0 +1,7 @@
+
+
+
+ false
+ false
+
+
diff --git a/tests/fixtures/Directory.Packages.props b/tests/fixtures/Directory.Packages.props
new file mode 100644
index 0000000..c728bea
--- /dev/null
+++ b/tests/fixtures/Directory.Packages.props
@@ -0,0 +1,6 @@
+
+
+
+ false
+
+
diff --git a/tests/fixtures/invalid/MissingFableTargetMultiTFM.fsproj b/tests/fixtures/invalid/MissingFableTargetMultiTFM.fsproj
new file mode 100644
index 0000000..5236c4d
--- /dev/null
+++ b/tests/fixtures/invalid/MissingFableTargetMultiTFM.fsproj
@@ -0,0 +1,8 @@
+
+
+
+ netstandard2.0;net8.0
+ binding
+
+
+
diff --git a/tests/fixtures/invalid/packages.lock.json b/tests/fixtures/invalid/packages.lock.json
deleted file mode 100644
index e1515d4..0000000
--- a/tests/fixtures/invalid/packages.lock.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "version": 2,
- "dependencies": {
- ".NETStandard,Version=v2.0": {
- "FSharp.Core": {
- "type": "Direct",
- "requested": "[8.0.101, )",
- "resolved": "8.0.101",
- "contentHash": "sOLz3O4BOxnTKfd5OChdRmDUy4Id0GfoEClRG4nzIod8LY1LJZcNyygKAV0A78XOLh8yvhA5hsDYKZXGCR9blw=="
- },
- "NETStandard.Library": {
- "type": "Direct",
- "requested": "[2.0.3, )",
- "resolved": "2.0.3",
- "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
- "dependencies": {
- "Microsoft.NETCore.Platforms": "1.1.0"
- }
- },
- "Microsoft.NETCore.Platforms": {
- "type": "Transitive",
- "resolved": "1.1.0",
- "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/fixtures/valid/library-with-files-multi-tfm/Entry.fs b/tests/fixtures/valid/library-with-files-multi-tfm/Entry.fs
new file mode 100644
index 0000000..633676c
--- /dev/null
+++ b/tests/fixtures/valid/library-with-files-multi-tfm/Entry.fs
@@ -0,0 +1,3 @@
+module MyLibrary
+
+let answer = 42
diff --git a/tests/fixtures/valid/library-with-files-multi-tfm/MyLibraryMultiTFM.fsproj b/tests/fixtures/valid/library-with-files-multi-tfm/MyLibraryMultiTFM.fsproj
new file mode 100644
index 0000000..34a6bb7
--- /dev/null
+++ b/tests/fixtures/valid/library-with-files-multi-tfm/MyLibraryMultiTFM.fsproj
@@ -0,0 +1,17 @@
+
+
+
+ netstandard2.0;net8.0
+ library
+ fable-javascript
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
diff --git a/tests/fixtures/valid/library-with-files/packages.lock.json b/tests/fixtures/valid/library-with-files/packages.lock.json
deleted file mode 100644
index e1515d4..0000000
--- a/tests/fixtures/valid/library-with-files/packages.lock.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "version": 2,
- "dependencies": {
- ".NETStandard,Version=v2.0": {
- "FSharp.Core": {
- "type": "Direct",
- "requested": "[8.0.101, )",
- "resolved": "8.0.101",
- "contentHash": "sOLz3O4BOxnTKfd5OChdRmDUy4Id0GfoEClRG4nzIod8LY1LJZcNyygKAV0A78XOLh8yvhA5hsDYKZXGCR9blw=="
- },
- "NETStandard.Library": {
- "type": "Direct",
- "requested": "[2.0.3, )",
- "resolved": "2.0.3",
- "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
- "dependencies": {
- "Microsoft.NETCore.Platforms": "1.1.0"
- }
- },
- "Microsoft.NETCore.Platforms": {
- "type": "Transitive",
- "resolved": "1.1.0",
- "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/packages.lock.json b/tests/packages.lock.json
index afbca36..5cd77ef 100644
--- a/tests/packages.lock.json
+++ b/tests/packages.lock.json
@@ -2,6 +2,15 @@
"version": 2,
"dependencies": {
"net8.0": {
+ "BlackFox.CommandLine": {
+ "type": "Direct",
+ "requested": "[1.0.0, )",
+ "resolved": "1.0.0",
+ "contentHash": "dSW7uLetl021HQXKcZd1xrXPjhsXgaJ5U4tFe64DLja1KZ2Ce6QeugHvZDvLfcPkEc1ZPRF7fWv5/T+X3ThWTA==",
+ "dependencies": {
+ "FSharp.Core": "4.2.3"
+ }
+ },
"EasyBuild.FileSystemProvider": {
"type": "Direct",
"requested": "[0.3.0, )",