Skip to content
Merged
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
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:
run: dotnet fake build
- name: Pack
run: |
dotnet fake build -t Pack
dotnet fake build -t PackTemplates
dotnet fake build -t PackAll
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-windows
name: interstellar-windows
path: artifacts
- name: Test
run: |
Expand All @@ -48,11 +47,11 @@ jobs:
- name: Build
run: dotnet fake build
- name: Pack
run: dotnet fake build -t pack
run: dotnet fake build -t PackAll
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-macos
name: interstellar-macos
path: artifacts/
- name: Test
run: |
Expand Down
42 changes: 24 additions & 18 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let changelog = scrapeChangelog () |> Seq.toList
let currentVersionInfo = changelog.[0]
/// Indicates the extra version number that's added to the template package. When releasing a new version of Interstellar, reset this to 0. Whenever making a
/// change to just the template, increment this.
let currentTemplateMinorVersion = 2
let currentTemplateMinorVersion = 1

let addProperties props defaults = { defaults with Properties = [yield! defaults.Properties; yield! props]}

Expand Down Expand Up @@ -134,13 +134,12 @@ let getNupkgPath version projPath =
Path.Combine ([|projDir; "bin"; "Release";
sprintf "%s%s.nupkg" (Path.GetFileNameWithoutExtension projPath) vstr|])

let getNupkgArtifactPath proj = Path.Combine (artifactsPath, sprintf "%s.nupkg" (Path.GetFileNameWithoutExtension proj))

Target.create "Clean" (fun _ ->
Trace.log " --- Cleaning --- "
for proj in projects do
try File.Delete (getNupkgPath (Some currentVersionInfo.versionName) proj) with _ -> ()
try File.Delete (getNupkgArtifactPath proj) with _ -> ()
let vstr = currentVersionInfo.versionName
File.delete (getNupkgPath (Some vstr) proj)
!! (Path.Combine (artifactsPath, "**/*.nupkg")) |> File.deleteAll
let projects =
if Environment.isWindows then [ Projects.winFormsLib; Projects.wpfLib; yield! Templates.winProjects ]
else if Environment.isMacOS then [ Solutions.macos; yield! Templates.macosProjects ]
Expand All @@ -150,7 +149,6 @@ Target.create "Clean" (fun _ ->
Shell.deleteDir ".fsdocs"
Shell.deleteDir "output"
Shell.deleteDir "temp"
Shell.deleteDir artifactsPath
)

Target.create "Restore" (fun _ ->
Expand Down Expand Up @@ -201,14 +199,14 @@ Target.create "Pack" (fun _ ->
Trace.log (sprintf "PROJECT LIST: %A" projects)
for proj in projects do
msbuild id proj
// Strip version stuff from the file name, and collect all generated package archives into a common folder
let oldNupkgPath = getNupkgPath (Some currentVersionInfo.versionName) proj
Directory.CreateDirectory "artifacts" |> ignore
let nupkgArtifact = getNupkgArtifactPath proj
Trace.log (sprintf "Moving %s -> %s" oldNupkgPath nupkgArtifact)
try File.Delete nupkgArtifact with _ -> ()
File.Copy (oldNupkgPath, nupkgArtifact)
``Nupkg-hack``.hackNupkgAtPath nupkgArtifact // see #3
// Collect all generated package archives into a common folder
let vstr = currentVersionInfo.versionName
let oldNupkgPath = getNupkgPath (Some vstr) proj
Shell.mkdir artifactsPath
Shell.moveFile artifactsPath oldNupkgPath
// see https://github.com/jwosty/Interstellar/issues/3
!! (Path.Combine (artifactsPath, "**", "*.nupkg"))
|> Seq.iter (``Nupkg-hack``.hackNupkgAtPath)
)

Target.create "BuildTemplateProjects" (fun _ ->
Expand Down Expand Up @@ -243,20 +241,20 @@ Target.create "PackTemplates" (fun _ ->

Target.create "PackAll" ignore

Target.create "TestAll" ignore

Target.create "All" ignore

open Fake.Core.TargetOperators

// *** Define Dependencies ***
"Clean"
==> "Restore"
"Restore"
==> "Build"
==> "Pack"
==> "PackAll"
==> "All"

"Clean"
==> "PackTemplates"
"PackTemplates"
==> "PackAll"
==> "All"

Expand All @@ -265,6 +263,14 @@ open Fake.Core.TargetOperators
==> "ReleaseDocs"
==> "All"

"BuildTemplateProjects"
==> "TestAll"

// "Build"
// ==> "Test"
"Test"
==> "TestAll"

"Build"
==> "BuildTemplateProjects"

Expand Down
6 changes: 4 additions & 2 deletions nupkg-hack.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ open System.IO
open System.IO.Compression
open System.Text
open System.Text.RegularExpressions
open Fake.Core
open Fake.IO

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__

Expand All @@ -27,8 +29,7 @@ let changeVersionConstraints text =

let hackNupkgFromStream (path: string) (stream: Stream) =
use archive = new ZipArchive(stream, ZipArchiveMode.Update)
let nuspecName = sprintf "%s.nuspec" (Path.GetFileNameWithoutExtension path)
let oldEntry = archive.GetEntry nuspecName
let oldEntry = archive.Entries |> Seq.find (fun e -> e.Name.EndsWith ".nuspec")
let input =
(use nuspecReader = new StreamReader(oldEntry.Open(), Encoding.UTF8) in nuspecReader.ReadToEnd())
let output = changeVersionConstraints input
Expand All @@ -37,6 +38,7 @@ let hackNupkgFromStream (path: string) (stream: Stream) =

/// Cracks open a nupkg and changes all Interstellar package reference constraints from >= to =
let hackNupkgAtPath (path: string) =
Trace.log ("Hacking nupkg: " + path)
use file = File.Open (path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
hackNupkgFromStream path file

Expand Down