Skip to content

Commit a7a41a1

Browse files
committed
Migration to FAKE v5
- Changed Fake build system from fsx script to fsproj. - see: https://fake.build/guide/getting-started.html#Different-ways-to-run-FAKE - this resolved compatibility issues that [Could not find a suitable .NET 6 runtime version matching SDK version: 7](fsprojects/FAKE#2719).
1 parent f04fb49 commit a7a41a1

File tree

12 files changed

+695
-392
lines changed

12 files changed

+695
-392
lines changed

Avalonia.FuncUI.LiveView.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{77D972B7
2424
EndProject
2525
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Avalonia.FuncUI.LiveView.Core.Tests", "tests\Avalonia.FuncUI.LiveView.Core.Tests\Avalonia.FuncUI.LiveView.Core.Tests.fsproj", "{20DD3B4D-46C8-4F78-B114-6ED2CCAA1433}"
2626
EndProject
27+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "build", "build\build.fsproj", "{58DC7613-7B55-4C0C-929A-ACFD312E894B}"
28+
EndProject
2729
Global
2830
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2931
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
5759
{20DD3B4D-46C8-4F78-B114-6ED2CCAA1433}.Debug|Any CPU.Build.0 = Debug|Any CPU
5860
{20DD3B4D-46C8-4F78-B114-6ED2CCAA1433}.Release|Any CPU.ActiveCfg = Release|Any CPU
5961
{20DD3B4D-46C8-4F78-B114-6ED2CCAA1433}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{58DC7613-7B55-4C0C-929A-ACFD312E894B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{58DC7613-7B55-4C0C-929A-ACFD312E894B}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{58DC7613-7B55-4C0C-929A-ACFD312E894B}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{58DC7613-7B55-4C0C-929A-ACFD312E894B}.Release|Any CPU.Build.0 = Release|Any CPU
6066
EndGlobalSection
6167
GlobalSection(NestedProjects) = preSolution
6268
{AA59F86F-40EC-4935-928E-ACE854A73DE4} = {DB8DF710-E6E6-4722-99D4-514834AEEB16}
Lines changed: 189 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,189 @@
1-
#if FAKE
2-
#r "paket:
3-
nuget Fake.Core.ReleaseNotes
4-
nuget Fake.DotNet.Cli
5-
nuget Fake.DotNet.Paket
6-
nuget Fake.IO.FileSystem
7-
nuget Fake.IO.Zip
8-
nuget Fake.Core.Target //"
9-
#endif
10-
#r "System.Xml.XDocument.dll"
11-
#r "System.IO.Compression.ZipFile.dll"
12-
#load ".fake/build.fsx/intellisense.fsx"
13-
14-
open Fake.Core
15-
open Fake.DotNet
16-
open Fake.IO
17-
open Fake.IO.FileSystemOperators
18-
open Fake.IO.Globbing.Operators
19-
open Fake.Core.TargetOperators
20-
21-
// ****************************************************************************************************
22-
// ------------------------------------------- Definitions -------------------------------------------
23-
// ****************************************************************************************************
24-
25-
let srcPath = "./src"
26-
let outputPath = "./dist"
27-
let slnPath = "./Avalonia.FuncUI.LiveView.sln"
28-
let localanalyzerPath = "./localanalyzers"
29-
30-
// properties
31-
let projectDescription = [ "Live fs/fsx previewer for Avalonia.FuncUI." ]
32-
let gitUserName = "SilkyFowl"
33-
let authors = [ gitUserName ]
34-
let projectUrl = $"https://github.com/{gitUserName}/Avalonia.FuncUI.LiveView"
35-
36-
let release = ReleaseNotes.load "RELEASE_NOTES.md"
37-
38-
type ProjSetting =
39-
{ Name: string }
40-
member this.Path = srcPath @@ this.Name
41-
member this.PackageId = $"{gitUserName}.{this.Name}"
42-
43-
let analyzerProjSetting = { Name = "Avalonia.FuncUI.LiveView.Analyzer" }
44-
let liveViewProjSetting = { Name = "Avalonia.FuncUI.LiveView" }
45-
46-
module Paket =
47-
open PaketTemplate
48-
49-
let private baseParams =
50-
{ DefaultPaketTemplateParams with
51-
TemplateType = Project
52-
Version = Some release.NugetVersion
53-
ReleaseNotes = release.Notes
54-
Description = projectDescription
55-
Authors = authors
56-
ProjectUrl = Some projectUrl
57-
Files = [ Include(".." </> ".." </> "LICENSE.md", "") ] }
58-
59-
let settings =
60-
let toTemplateFilePath projectPath = Some(projectPath @@ "paket.template")
61-
62-
[ {| projSetting = analyzerProjSetting
63-
templateParams =
64-
{ baseParams with
65-
TemplateFilePath = toTemplateFilePath analyzerProjSetting.Path
66-
Id = Some analyzerProjSetting.PackageId
67-
Files =
68-
baseParams.Files
69-
@ [ Include("bin" </> "Release" </> "net6.0" </> "publish", "lib" </> "net6.0") ] } |}
70-
{| projSetting = liveViewProjSetting
71-
templateParams =
72-
{ baseParams with
73-
TemplateFilePath = toTemplateFilePath liveViewProjSetting.Path
74-
Id = Some liveViewProjSetting.PackageId } |} ]
75-
76-
module Nuspec =
77-
open System.Xml.Linq
78-
open System.IO.Compression
79-
80-
let addLicense (proj: ProjSetting) =
81-
let xn = XName.Get
82-
83-
let ns localName =
84-
XName.Get(localName, "http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd")
85-
86-
let unzipedPath =
87-
outputPath
88-
</> $"{proj.PackageId}.{release.NugetVersion}"
89-
90-
let nupkgPath = $"{unzipedPath}.nupkg"
91-
92-
let nuspecPath = unzipedPath </> $"{proj.PackageId}.nuspec"
93-
94-
Zip.unzip unzipedPath nupkgPath
95-
96-
let nupkgDoc = XDocument.Load nuspecPath
97-
98-
nupkgDoc.Descendants(ns "authors")
99-
|> Seq.iter (fun metadata ->
100-
metadata.AddAfterSelf(
101-
XElement(ns "requireLicenseAcceptance", "false"),
102-
XElement(ns "license", XAttribute(xn "type", "file"), "LICENSE.md"),
103-
XElement(ns "licenseUrl", "https://aka.ms/deprecateLicenseUrl")
104-
))
105-
106-
if proj = analyzerProjSetting then
107-
nupkgDoc.Descendants(ns "dependency")
108-
|> Seq.filter (fun dependency -> dependency.Attribute(xn "id").Value <> "FSharp.Analyzers.SDK")
109-
|> Seq.toList
110-
|> List.iter (fun dependency -> dependency.Remove())
111-
112-
nupkgDoc.Save nuspecPath
113-
Shell.rm nupkgPath
114-
115-
ZipFile.CreateFromDirectory(unzipedPath, nupkgPath)
116-
Shell.deleteDir unzipedPath
117-
118-
Target.initEnvironment ()
119-
120-
// ****************************************************************************************************
121-
// --------------------------------------------- Targets ---------------------------------------------
122-
// ****************************************************************************************************
123-
124-
Target.create "CleanDebug" (fun _ -> !! "src/**/Debug" ++ outputPath |> Shell.cleanDirs)
125-
126-
Target.create "CleanRelease" (fun _ ->
127-
!! "src/**/Release" ++ outputPath
128-
|> Shell.cleanDirs)
129-
130-
131-
Target.create "BuildDebug" (fun _ ->
132-
slnPath
133-
|> DotNet.build (fun setParams -> { setParams with Configuration = DotNet.Debug }))
134-
135-
Target.create "BuildRelease" (fun _ ->
136-
slnPath
137-
|> DotNet.build (fun setParams -> { setParams with Configuration = DotNet.Release }))
138-
139-
Target.create "Pack" (fun _ ->
140-
for setting in Paket.settings do
141-
142-
PaketTemplate.create (fun _ -> setting.templateParams)
143-
144-
setting.projSetting.Path
145-
|> DotNet.publish (fun opts ->
146-
{ opts with
147-
Configuration = DotNet.Release
148-
SelfContained = Some false
149-
Framework = Some "net6.0" })
150-
151-
Paket.pack (fun p ->
152-
{ p with
153-
ToolType = ToolType.CreateLocalTool()
154-
TemplateFile = Option.toObj setting.templateParams.TemplateFilePath
155-
OutputPath = outputPath
156-
MinimumFromLockFile = true
157-
IncludeReferencedProjects = true })
158-
159-
Nuspec.addLicense setting.projSetting)
160-
161-
Target.create "ClearLocalAnalyzer" (fun _ ->
162-
!!outputPath ++ localanalyzerPath
163-
|> Shell.cleanDirs)
164-
165-
Target.create "SetLocalAnalyzer" (fun _ ->
166-
let analyzerId = analyzerProjSetting.PackageId
167-
168-
outputPath
169-
|> Directory.findFirstMatchingFile $"{analyzerId}.*"
170-
|> Zip.unzip (localanalyzerPath </> analyzerId))
171-
172-
Target.create "Default" ignore
173-
174-
// ****************************************************************************************************
175-
// --------------------------------------- Targets Dependencies ---------------------------------------
176-
// ****************************************************************************************************
177-
178-
"CleanDebug" ==> "BuildDebug" ==> "Default"
179-
180-
"CleanRelease"
181-
==> "ClearLocalAnalyzer"
182-
==> "BuildRelease"
183-
==> "Pack"
184-
==> "SetLocalAnalyzer"
185-
186-
Target.runOrDefault "Default"
1+
open Fake.Core
2+
open Fake.DotNet
3+
open Fake.IO
4+
open Fake.IO.FileSystemOperators
5+
open Fake.IO.Globbing.Operators
6+
open Fake.Core.TargetOperators
7+
8+
// ****************************************************************************************************
9+
// ------------------------------------------- Definitions -------------------------------------------
10+
// ****************************************************************************************************
11+
12+
let srcPath = "./src"
13+
let outputPath = "./dist"
14+
let slnPath = "./Avalonia.FuncUI.LiveView.sln"
15+
let localanalyzerPath = "./localanalyzers"
16+
17+
// properties
18+
let projectDescription = [ "Live fs/fsx previewer for Avalonia.FuncUI." ]
19+
let gitUserName = "SilkyFowl"
20+
let authors = [ gitUserName ]
21+
let projectUrl = $"https://github.com/{gitUserName}/Avalonia.FuncUI.LiveView"
22+
23+
let release = ReleaseNotes.load "RELEASE_NOTES.md"
24+
25+
type ProjSetting =
26+
{ Name: string }
27+
member this.Path = srcPath @@ this.Name
28+
member this.PackageId = $"{gitUserName}.{this.Name}"
29+
30+
let analyzerProjSetting = { Name = "Avalonia.FuncUI.LiveView.Analyzer" }
31+
let liveViewProjSetting = { Name = "Avalonia.FuncUI.LiveView" }
32+
33+
module Paket =
34+
open PaketTemplate
35+
36+
let private baseParams =
37+
{ DefaultPaketTemplateParams with
38+
TemplateType = Project
39+
Version = Some release.NugetVersion
40+
ReleaseNotes = release.Notes
41+
Description = projectDescription
42+
Authors = authors
43+
ProjectUrl = Some projectUrl
44+
Files = [ Include(".." </> ".." </> "LICENSE.md", "") ] }
45+
46+
let settings =
47+
let toTemplateFilePath projectPath = Some(projectPath @@ "paket.template")
48+
49+
[ {| projSetting = analyzerProjSetting
50+
templateParams =
51+
{ baseParams with
52+
TemplateFilePath = toTemplateFilePath analyzerProjSetting.Path
53+
Id = Some analyzerProjSetting.PackageId
54+
Files =
55+
baseParams.Files
56+
@ [ Include("bin" </> "Release" </> "net6.0" </> "publish", "lib" </> "net6.0") ] } |}
57+
{| projSetting = liveViewProjSetting
58+
templateParams =
59+
{ baseParams with
60+
TemplateFilePath = toTemplateFilePath liveViewProjSetting.Path
61+
Id = Some liveViewProjSetting.PackageId } |} ]
62+
63+
module Nuspec =
64+
open System.Xml.Linq
65+
open System.IO.Compression
66+
67+
let addLicense (proj: ProjSetting) =
68+
let xn = XName.Get
69+
70+
let ns localName =
71+
XName.Get(localName, "http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd")
72+
73+
let unzipedPath =
74+
outputPath
75+
</> $"{proj.PackageId}.{release.NugetVersion}"
76+
77+
let nupkgPath = $"{unzipedPath}.nupkg"
78+
79+
let nuspecPath = unzipedPath </> $"{proj.PackageId}.nuspec"
80+
81+
Zip.unzip unzipedPath nupkgPath
82+
83+
let nupkgDoc = XDocument.Load nuspecPath
84+
85+
nupkgDoc.Descendants(ns "authors")
86+
|> Seq.iter (fun metadata ->
87+
metadata.AddAfterSelf(
88+
XElement(ns "requireLicenseAcceptance", "false"),
89+
XElement(ns "license", XAttribute(xn "type", "file"), "LICENSE.md"),
90+
XElement(ns "licenseUrl", "https://aka.ms/deprecateLicenseUrl")
91+
))
92+
93+
if proj = analyzerProjSetting then
94+
nupkgDoc.Descendants(ns "dependency")
95+
|> Seq.filter (fun dependency -> dependency.Attribute(xn "id").Value <> "FSharp.Analyzers.SDK")
96+
|> Seq.toList
97+
|> List.iter (fun dependency -> dependency.Remove())
98+
99+
nupkgDoc.Save nuspecPath
100+
Shell.rm nupkgPath
101+
102+
ZipFile.CreateFromDirectory(unzipedPath, nupkgPath)
103+
Shell.deleteDir unzipedPath
104+
105+
#nowarn "20"
106+
let initTargets () =
107+
Target.initEnvironment ()
108+
109+
// ****************************************************************************************************
110+
// --------------------------------------------- Targets ---------------------------------------------
111+
// ****************************************************************************************************
112+
113+
Target.create "CleanDebug" (fun _ -> !! "src/**/Debug" ++ outputPath |> Shell.cleanDirs)
114+
115+
Target.create "CleanRelease" (fun _ ->
116+
!! "src/**/Release" ++ outputPath
117+
|> Shell.cleanDirs)
118+
119+
120+
Target.create "BuildDebug" (fun _ ->
121+
slnPath
122+
|> DotNet.build (fun setParams -> { setParams with Configuration = DotNet.Debug }))
123+
124+
Target.create "BuildRelease" (fun _ ->
125+
slnPath
126+
|> DotNet.build (fun setParams -> { setParams with Configuration = DotNet.Release }))
127+
128+
Target.create "Pack" (fun _ ->
129+
for setting in Paket.settings do
130+
131+
PaketTemplate.create (fun _ -> setting.templateParams)
132+
133+
setting.projSetting.Path
134+
|> DotNet.publish (fun opts ->
135+
{ opts with
136+
Configuration = DotNet.Release
137+
SelfContained = Some false
138+
Framework = Some "net6.0" })
139+
140+
Paket.pack (fun p ->
141+
{ p with
142+
ToolType = ToolType.CreateLocalTool()
143+
TemplateFile = Option.toObj setting.templateParams.TemplateFilePath
144+
OutputPath = outputPath
145+
MinimumFromLockFile = true
146+
IncludeReferencedProjects = true })
147+
148+
Nuspec.addLicense setting.projSetting)
149+
150+
Target.create "ClearLocalAnalyzer" (fun _ ->
151+
!!outputPath ++ localanalyzerPath
152+
|> Shell.cleanDirs)
153+
154+
Target.create "SetLocalAnalyzer" (fun _ ->
155+
let analyzerId = analyzerProjSetting.PackageId
156+
157+
outputPath
158+
|> Directory.findFirstMatchingFile $"{analyzerId}.*"
159+
|> Zip.unzip (localanalyzerPath </> analyzerId))
160+
161+
Target.create "Default" ignore
162+
163+
// ****************************************************************************************************
164+
// --------------------------------------- Targets Dependencies ---------------------------------------
165+
// ****************************************************************************************************
166+
167+
"CleanDebug" ==> "BuildDebug" ==> "Default"
168+
169+
"CleanRelease"
170+
==> "ClearLocalAnalyzer"
171+
==> "BuildRelease"
172+
==> "Pack"
173+
==> "SetLocalAnalyzer"
174+
175+
//-----------------------------------------------------------------------------
176+
// Target Start
177+
//-----------------------------------------------------------------------------
178+
179+
[<EntryPoint>]
180+
let main argv =
181+
argv
182+
|> Array.toList
183+
|> Context.FakeExecutionContext.Create false "build.fsx"
184+
|> Context.RuntimeContext.Fake
185+
|> Context.setExecutionContext
186+
initTargets ()
187+
Target.runOrDefaultWithArguments "Default"
188+
189+
0 // return an integer exit code

0 commit comments

Comments
 (0)