Skip to content

Commit 3dfe5f1

Browse files
committed
fix: workaround limitations in VS and Rider
Fix #9
1 parent 8b9dd27 commit 3dfe5f1

File tree

7 files changed

+124
-9
lines changed

7 files changed

+124
-9
lines changed

Directory.Packages.props

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageVersion Include="EasyBuild.FileSystemProvider" Version="0.3.0" />
7+
<PackageVersion Include="EasyBuild.PackageReleaseNotes.Tasks" Version="1.2.0">
8+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9+
<PrivateAssets>all</PrivateAssets>
10+
</PackageVersion>
711
<PackageVersion Include="FSharp.Core" Version="8.0.101" />
12+
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.11.4" />
813
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
914
<PackageVersion Include="NUnit" Version="4.1.0" />
1015
<PackageVersion Include="NUnit.Analyzers" Version="4.2.0">
@@ -13,5 +18,6 @@
1318
</PackageVersion>
1419
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
1520
<PackageVersion Include="SimpleExec" Version="12.0.0" />
21+
<PackageVersion Include="Thoth.Json.Newtonsoft" Version="0.2.0" />
1622
</ItemGroup>
17-
</Project>
23+
</Project>

src/build/Fable.Package.SDK.targets

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
-->
66
<ItemGroup Condition="'$(FablePackageType)' == 'library'">
77
<!-- Include all files that are compiled with this project -->
8-
<Content Include="@(Compile)" Pack="true"
8+
<!--
9+
Rider and VS don't like using 'Content' or 'None' node for the rule below
10+
11+
IHMO, this is a bug on their side, because in previous versions of Rider, 'Node' was working
12+
-->
13+
<!-- <None Include="@(Compile)" Pack="true"
14+
PackagePath="fable/%(RelativeDir)%(Filename)%(Extension)" /> -->
15+
<Compile Update="@(Compile)" Pack="true"
916
PackagePath="fable/%(RelativeDir)%(Filename)%(Extension)" />
1017
<!-- Include the project file itself as well -->
11-
<Content Include="$(MSBuildProjectFullPath)" Pack="true" PackagePath="fable/" />
18+
<None Include="$(MSBuildProjectFullPath)" Pack="true" PackagePath="fable/" Visible="false"/>
1219
</ItemGroup>
1320
<!--
1421
Automatically add Fable tags

tests/Fable.Package.SDK.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
</PackageReference>
1919
<PackageReference Include="NUnit3TestAdapter" />
2020
<PackageReference Include="SimpleExec" />
21+
<PackageReference Include="Thoth.Json.Newtonsoft" />
2122
</ItemGroup>
2223
</Project>

tests/Main.fs

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ module Fable.Package.SDK.Tests
22

33
// open Microsoft.VisualStudio.TestTools.UnitTesting
44
open SimpleExec
5-
open System.IO
6-
open System.Threading.Tasks
7-
open NUnit
85
open NUnit.Framework
6+
open Thoth.Json.Core
7+
open Thoth.Json.Newtonsoft
98

109
let private expectToFailWithMessage projectName (message: string) =
1110
task {
@@ -222,21 +221,62 @@ let ``should support multiple fable targets`` () =
222221
)
223222
}
224223

224+
type MSBuildItem =
225+
{
226+
FullPath: string
227+
Pack: bool
228+
}
229+
230+
static member Decoder =
231+
Decode.object (fun get ->
232+
{
233+
FullPath = get.Required.Field "FullPath" Decode.string
234+
Pack =
235+
get.Required.Field
236+
"Pack"
237+
(Decode.string
238+
|> Decode.andThen (
239+
function
240+
| "true" -> Decode.succeed true
241+
| "false" -> Decode.succeed false
242+
| _ -> Decode.fail "Invalid boolean value"
243+
))
244+
}
245+
)
246+
225247
[<Test>]
226248
let ``should include the source file and the project file under 'fable' folder`` () =
227249
task {
228250
let! stdout, _ =
229251
Command.ReadAsync(
230252
"dotnet",
231-
$"msbuild %s{Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``} --getItem:Content"
253+
$"msbuild %s{Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``} --getItem:None --getItem:Compile"
232254
)
233255

256+
let projectFile =
257+
Decode.unsafeFromString
258+
(Decode.at [ "Items"; "None" ] (Decode.list MSBuildItem.Decoder))
259+
stdout
260+
// We are only interested in the project file
261+
|> List.filter (fun item -> item.FullPath.Contains("MyLibrary.fsproj"))
262+
|> List.head
263+
264+
let compileItem =
265+
Decode.unsafeFromString
266+
(Decode.at [ "Items"; "Compile" ] (Decode.index 0 MSBuildItem.Decoder))
267+
stdout
268+
269+
Assert.That(compileItem.Pack, Is.True)
270+
234271
Assert.That(
235-
stdout.Trim(),
272+
compileItem.FullPath,
236273
Contains.Substring("tests/fixtures/valid/library-with-files/Entry.fs")
237274
)
275+
276+
Assert.That(projectFile.Pack, Is.True)
277+
238278
Assert.That(
239-
stdout.Trim(),
279+
projectFile.FullPath,
240280
Contains.Substring("tests/fixtures/valid/library-with-files/MyLibrary.fsproj")
241281
)
242282
}

tests/fixtures/valid/library-with-files/MyLibrary.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<FablePackageType>library</FablePackageType>
6+
<PackageTags>fable-javascript</PackageTags>
67
</PropertyGroup>
78
<ItemGroup>
89
<Compile Include="Entry.fs" />
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": 2,
3+
"dependencies": {
4+
".NETStandard,Version=v2.0": {
5+
"FSharp.Core": {
6+
"type": "Direct",
7+
"requested": "[8.0.101, )",
8+
"resolved": "8.0.101",
9+
"contentHash": "sOLz3O4BOxnTKfd5OChdRmDUy4Id0GfoEClRG4nzIod8LY1LJZcNyygKAV0A78XOLh8yvhA5hsDYKZXGCR9blw=="
10+
},
11+
"NETStandard.Library": {
12+
"type": "Direct",
13+
"requested": "[2.0.3, )",
14+
"resolved": "2.0.3",
15+
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
16+
"dependencies": {
17+
"Microsoft.NETCore.Platforms": "1.1.0"
18+
}
19+
},
20+
"Microsoft.NETCore.Platforms": {
21+
"type": "Transitive",
22+
"resolved": "1.1.0",
23+
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
24+
}
25+
}
26+
}
27+
}

tests/packages.lock.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@
4848
"resolved": "12.0.0",
4949
"contentHash": "ptxlWtxC8vM6Y6e3h9ZTxBBkOWnWrm/Sa1HT+2i1xcXY3Hx2hmKDZP5RShPf8Xr9D+ivlrXNy57ktzyH8kyt+Q=="
5050
},
51+
"Thoth.Json.Newtonsoft": {
52+
"type": "Direct",
53+
"requested": "[0.2.0, )",
54+
"resolved": "0.2.0",
55+
"contentHash": "dMQOT6TJftO97c8gHWFegfSw/0/E+VdhGaSkf3e1Ba+DjrAESLA9HMlYyE30x7nhn7w5SfH1WO9YyzSRTV4Ysg==",
56+
"dependencies": {
57+
"FSharp.Core": "5.0.0",
58+
"Fable.Core": "4.1.0",
59+
"Fable.Package.SDK": "0.1.0",
60+
"Newtonsoft.Json": "13.0.1",
61+
"Thoth.Json.Core": "0.3.0"
62+
}
63+
},
64+
"Fable.Core": {
65+
"type": "Transitive",
66+
"resolved": "4.1.0",
67+
"contentHash": "NISAbAVGEcvH2s+vHLSOCzh98xMYx4aIadWacQdWPcQLploxpSQXLEe9SeszUBhbHa73KMiKREsH4/W3q4A4iA=="
68+
},
69+
"Fable.Package.SDK": {
70+
"type": "Transitive",
71+
"resolved": "0.1.0",
72+
"contentHash": "wrEcGovUimN0PRGgVHlX/gsqCm5d/p9eOG74iaHoteX2dsFZQ9P7d066LRAl5Gj7GUHy7azLyDE41KFvZx1v9A=="
73+
},
5174
"Microsoft.CodeCoverage": {
5275
"type": "Transitive",
5376
"resolved": "17.10.0",
@@ -79,6 +102,16 @@
79102
"type": "Transitive",
80103
"resolved": "1.6.0",
81104
"contentHash": "COC1aiAJjCoA5GBF+QKL2uLqEBew4JsCkQmoHKbN3TlOZKa2fKLz5CpiRQKDz0RsAOEGsVKqOD5bomsXq/4STQ=="
105+
},
106+
"Thoth.Json.Core": {
107+
"type": "Transitive",
108+
"resolved": "0.3.0",
109+
"contentHash": "6JNLVfP7ne16TvgKXpmhQru1VwXs5QGdQ6YZNdAL84e11MvxJFXKlcbNSNRw3dOI3yruYz0OKvpCRaHpV6JGcA==",
110+
"dependencies": {
111+
"FSharp.Core": "5.0.0",
112+
"Fable.Core": "4.1.0",
113+
"Fable.Package.SDK": "0.1.0"
114+
}
82115
}
83116
}
84117
}

0 commit comments

Comments
 (0)