From 9006041ff19d8e012f2bcbdc475e8b2aeae33c51 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:08:08 +0200 Subject: [PATCH 01/22] intermediate, not yet working --- src/Runfs/Build.fs | 13 ++++++++----- src/Runfs/Program.fs | 6 +++--- src/Runfs/ProjectFile.fs | 6 +++--- src/Runfs/Runfs.fs | 22 ++++++++-------------- tests/Runfs.Tests/TestFiles/test1.fs | 16 ++++++++-------- 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 18cea95..c81366c 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -14,6 +14,7 @@ open Runfs.ProjectFile let verbosity = "normal" type Project = {projectInstance: ProjectInstance; parameters: BuildParameters} +type MsRestoreError = MsRestoreError of string let createProject projectFilePath projectFileText : Project = let loggerArgs = [|$"--verbosity:{verbosity}"|] @@ -40,7 +41,7 @@ let createProject projectFilePath projectFileText : Project = parameters.LogTaskInputs <- false {projectInstance = projectInstance; parameters = parameters} -let restore project parameters = +let restore (project: Project) = let buildManager = BuildManager.DefaultBuildManager let flags = BuildRequestDataFlags.ClearCachesAfterBuild @@ -48,9 +49,11 @@ let restore project parameters = ||| BuildRequestDataFlags.IgnoreMissingEmptyAndInvalidImports ||| BuildRequestDataFlags.FailOnUnresolvedSdk let restoreRequest = - new BuildRequestData(project, [|"Restore"|], null, flags) + new BuildRequestData(project.projectInstance, [|"Restore"|], null, flags) - buildManager.BeginBuild parameters + buildManager.BeginBuild project.parameters let restoreResult = buildManager.BuildRequest restoreRequest - if restoreResult.OverallResult <> BuildResultCode.Success then 1 - else 0 + if restoreResult.OverallResult = BuildResultCode.Success then + Ok() + else + Error(MsRestoreError (string restoreResult)) diff --git a/src/Runfs/Program.fs b/src/Runfs/Program.fs index 72e5d64..ac77be2 100644 --- a/src/Runfs/Program.fs +++ b/src/Runfs/Program.fs @@ -2,6 +2,7 @@ open Runfs.Runfs open Runfs.Directives +open Runfs.Build [] let main argv = @@ -37,9 +38,8 @@ let main argv = | CaughtException ex -> [$"Unexpected: {ex.Message}"] | InvalidSourcePath s -> [$"Invalid source path: {s}"] | InvalidSourceDirectory s -> [$"Invalid source directory: {s}"] - | RestoreError(stdoutLines, stderrLines) -> - "Restore error" :: indent stdoutLines @ indent stderrLines - | BuildError(stdoutLines, stderrLines) -> + | RestoreError(MsRestoreError s) -> [$"Restore error: {s}"] + | BuildError(stdoutLines, stderrLines) -> "Build error" :: indent stdoutLines @ indent stderrLines | DirectiveError parseErrors -> let getParseErrorString parseError = diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs index 8458105..7ace5bb 100644 --- a/src/Runfs/ProjectFile.fs +++ b/src/Runfs/ProjectFile.fs @@ -16,8 +16,8 @@ let private escape str = SecurityElement.Escape str |> string let private sdkLine project (name, version) = match version with - | Some v -> $""" """ - | None -> $""" """ + | Some v -> $""" """ + | None -> $""" """ let private propertyLine (name, version) = $""" <{name}>{escape version}""" @@ -41,7 +41,7 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass [ "" " " - $""" {assemblyName}""" + $""" {escape assemblyName}""" " true" " false" $""" {escape artifactsPath}""" diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 1c346e6..32b0653 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -15,7 +15,7 @@ type RunfsError = | InvalidSourcePath of string | InvalidSourceDirectory of string | DirectiveError of ParseError list - | RestoreError of stdout: string list * stderr: string list + | RestoreError of MsRestoreError | BuildError of stdout: string list * stderr: string list let ThisPackageName = "Runfs" @@ -57,6 +57,7 @@ let wrap showTimings name f = /// TODO /// virtual project file +/// => check about global properties /// clean my repos /// fsharp/lang-design issue: parse and ignore #: /// readme/ blog @@ -129,22 +130,15 @@ let run (options, sourcePath, args) = let noDll = not (File.Exists dllPath) Ok (dependenciesChanged, sourceChanged, noDll) - if dependenciesChanged || sourceChanged || noDll then - do! wrap "creating and writing project file" <| fun () -> - let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName - File.WriteAllLines(projectFilePath, projectFileLines) |> Ok + let! project = wrap "creating virtual project" <| fun () -> + let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName + let projectFileText = projectFileLines |> String.concat Environment.NewLine + lazy (createProject projectFilePath projectFileText) |> Ok if dependenciesChanged || noDll then - do! wrap "running dotnet restore" <| fun () -> + do! wrap "running restore" <| fun () -> File.Delete dependenciesHashPath - let args = [ - "restore" - if not verbose then "-v:q" - projectFilePath - ] - let exitCode, stdoutLines, stderrLines = - runCommandCollectOutput "dotnet" args fullSourceDir - if exitCode <> 0 then Error(RestoreError(stdoutLines, stderrLines)) else Ok() + restore (project.Force()) |> Result.mapError RestoreError if sourceChanged || dependenciesChanged || noDll then do! wrap "running dotnet build" <| fun () -> diff --git a/tests/Runfs.Tests/TestFiles/test1.fs b/tests/Runfs.Tests/TestFiles/test1.fs index 1a57c5b..5274e98 100644 --- a/tests/Runfs.Tests/TestFiles/test1.fs +++ b/tests/Runfs.Tests/TestFiles/test1.fs @@ -1,11 +1,11 @@ -open System +module A = + open System -#r_project "abc/xyz.fsproj" -#r_dll "System.dll" -#r_property "myprop=43" -#r_property "TargetFramework=net8.0" - -let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail -printfn $"args: {args}" + // #r_project "abc/xyz.fsproj" + // #r_dll "System.dll" + // #r_property "myprop=42" + // #r_property "TargetFramework=net8.0" + let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail + printfn $"args: {args}" From 2c99c13939f16321a461d3aa121e9e723a158111 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 25 Aug 2025 14:28:36 +0200 Subject: [PATCH 02/22] further trials --- src/Runfs/Build.fs | 20 +++++++++++--------- src/Runfs/ProjectFile.fs | 2 +- tests/Runfs.Tests/TestFiles/__Runfs__.fsproj | 13 ++++++------- tests/Runfs.Tests/TestFiles/test1.fs | 8 ++++---- ttt/test1.fs | 11 +++++++++++ 5 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 ttt/test1.fs diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index c81366c..8147ae7 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -16,7 +16,7 @@ let verbosity = "normal" type Project = {projectInstance: ProjectInstance; parameters: BuildParameters} type MsRestoreError = MsRestoreError of string -let createProject projectFilePath projectFileText : Project = +let createProject projectFilePath (projectFileText: string) : Project = let loggerArgs = [|$"--verbosity:{verbosity}"|] let consoleLogger = TerminalLogger.CreateTerminalOrConsoleLogger loggerArgs let loggers = [|consoleLogger|] @@ -25,17 +25,19 @@ let createProject projectFilePath projectFileText : Project = globalProperties, loggers, ToolsetDefinitionLocations.Default) - let createProjectRootElement() = - let reader = new StringReader(projectFileText) - let xmlReader = XmlReader.Create reader - let projectRoot = ProjectRootElement.Create(xmlReader, projectCollection) - projectRoot.FullPath <- projectFilePath - projectRoot - let projectRoot = createProjectRootElement(); let options = ProjectOptions() options.ProjectCollection <- projectCollection options.GlobalProperties <- globalProperties - let projectInstance = ProjectInstance.FromProjectRootElement(projectRoot, options) + // let createProjectRootElement() = + // let reader = new StringReader(projectFileText) + // let xmlReader = XmlReader.Create reader + // let projectRoot = ProjectRootElement.Create(xmlReader, projectCollection) + // projectRoot.FullPath <- projectFilePath + // projectRoot + // let projectRoot = createProjectRootElement(); + // let projectInstance = ProjectInstance.FromProjectRootElement(projectRoot, options) + File.WriteAllText(projectFilePath, projectFileText) + let projectInstance = ProjectInstance.FromFile(projectFilePath, options) let parameters = BuildParameters(projectCollection) parameters.Loggers <- loggers parameters.LogTaskInputs <- false diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs index 7ace5bb..e8eab3d 100644 --- a/src/Runfs/ProjectFile.fs +++ b/src/Runfs/ProjectFile.fs @@ -30,7 +30,7 @@ let private packageLine (name, version) = let createProjectFileLines directives entryPointSourceFullPath artifactsPath assemblyName = let sdks = match directives |> List.choose (function Sdk(n, v) -> Some(n, v) | _ -> None) with - | [] -> ["Microsoft.NET.Sdk", None] + | [] -> ["Microsoft.NET.Sdk", Some "9.0.304"] | d -> d let properties = directives |> List.choose (function Property(n, v) -> Some(n.ToLowerInvariant(), v) | _ -> None) |> Map diff --git a/tests/Runfs.Tests/TestFiles/__Runfs__.fsproj b/tests/Runfs.Tests/TestFiles/__Runfs__.fsproj index 1e432e4..29dc7ff 100644 --- a/tests/Runfs.Tests/TestFiles/__Runfs__.fsproj +++ b/tests/Runfs.Tests/TestFiles/__Runfs__.fsproj @@ -3,20 +3,19 @@ Runfs true false - C:\Users\Martin\AppData\Local\Temp\Runfs\test1-fc74c07713b10a174ef5bf2ab362c8ad6dc5683e710d2f3c747d36fa602a0d87 + C:\Users\Martin\AppData\Local\Temp\Runfs\test1-b5f58240b3f791a070267eb9dd0de8e92e33088cc3e2f78d9a93598ef06bb7dd - + Exe + net9.0 en-US enable - 43 - net8.0 - + - - + + \ No newline at end of file diff --git a/tests/Runfs.Tests/TestFiles/test1.fs b/tests/Runfs.Tests/TestFiles/test1.fs index 5274e98..1242c85 100644 --- a/tests/Runfs.Tests/TestFiles/test1.fs +++ b/tests/Runfs.Tests/TestFiles/test1.fs @@ -1,10 +1,10 @@ module A = open System - // #r_project "abc/xyz.fsproj" - // #r_dll "System.dll" - // #r_property "myprop=42" - // #r_property "TargetFramework=net8.0" + #r_project "abc/xyz.fsproj" + #r_dll "System.dll" + #r_property "myprop=42" + #r_property "TargetFramework=net8.0" let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail printfn $"args: {args}" diff --git a/ttt/test1.fs b/ttt/test1.fs new file mode 100644 index 0000000..5274e98 --- /dev/null +++ b/ttt/test1.fs @@ -0,0 +1,11 @@ +module A = + open System + + // #r_project "abc/xyz.fsproj" + // #r_dll "System.dll" + // #r_property "myprop=42" + // #r_property "TargetFramework=net8.0" + + let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail + printfn $"args: {args}" + From 2c8b3418e0a5cb738eda90dac2920fd9016d94ec Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sat, 30 Aug 2025 13:48:04 +0200 Subject: [PATCH 03/22] intermediate step --- src/Runfs/Build.fs | 12 ++++++-- src/Runfs/Dependencies.fs | 2 +- src/Runfs/ProjectFile.fs | 2 +- src/Runfs/Runfs.fs | 46 ++++++++++++++++------------ src/Runfs/Runfs.fsproj | 5 +-- tests/Runfs.Tests/ScriptTests.fs | 29 ++++++++++-------- tests/Runfs.Tests/TestFiles/test1.fs | 6 ++++ tests/Runfs.Tests/TestFiles/test2.fs | 1 + 8 files changed, 64 insertions(+), 39 deletions(-) diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 8147ae7..614b9d1 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -6,21 +6,27 @@ open Microsoft.Build.Evaluation open Microsoft.Build.Execution open Microsoft.Build.Framework open Microsoft.Build.Logging +open Microsoft.Build.Locator open System open System.IO open System.Xml open Runfs.ProjectFile -let verbosity = "normal" +let private verbosity = "quiet" type Project = {projectInstance: ProjectInstance; parameters: BuildParameters} type MsRestoreError = MsRestoreError of string +let initBuild() = MSBuildLocator.RegisterDefaults() |> ignore +let finishBuild() = BuildManager.DefaultBuildManager.EndBuild() + let createProject projectFilePath (projectFileText: string) : Project = - let loggerArgs = [|$"--verbosity:{verbosity}"|] + let loggerArgs = [|$"--verbosity:{verbosity}"; "NoSummary"|] let consoleLogger = TerminalLogger.CreateTerminalOrConsoleLogger loggerArgs let loggers = [|consoleLogger|] - let globalProperties = Collections.Generic.Dictionary() // TODO: empty ok? + let globalProperties = + dict [ + ] let projectCollection = new ProjectCollection( globalProperties, loggers, diff --git a/src/Runfs/Dependencies.fs b/src/Runfs/Dependencies.fs index dd47cb7..e1f8a04 100644 --- a/src/Runfs/Dependencies.fs +++ b/src/Runfs/Dependencies.fs @@ -8,7 +8,7 @@ open Runfs.Directives open Runfs.Utilities let RuntimeVersion = Environment.Version -let SdkVersion = Runtime.InteropServices.RuntimeInformation.FrameworkDescription +let SdkVersion = "t.b.d" // TODO (needed?) let TargetFramework = $"net{RuntimeVersion.Major}.{RuntimeVersion.Minor}" let PotentialImplicitBuildFileNames = [ diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs index f913e2d..f0078e6 100644 --- a/src/Runfs/ProjectFile.fs +++ b/src/Runfs/ProjectFile.fs @@ -30,7 +30,7 @@ let private packageLine (name, version) = let createProjectFileLines directives entryPointSourceFullPath artifactsPath assemblyName = let sdks = match directives |> List.choose (function Sdk(n, v) -> Some(n, v) | _ -> None) with - | [] -> ["Microsoft.NET.Sdk", Some "9.0.304"] + | [] -> ["Microsoft.NET.Sdk", None] //DODO verison? | d -> d let properties = directives |> List.choose (function Property(n, v) -> Some(n.ToLowerInvariant(), v) | _ -> None) |> Map diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index e7ef7b8..6167279 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -8,6 +8,7 @@ open Runfs.Directives open Runfs.ProjectFile open Runfs.Dependencies open Runfs.Utilities +open Runfs.Build type RunfsError = | CaughtException of Exception @@ -58,9 +59,10 @@ let run (options, sourcePath, args) = let showTimings = Set.contains "time" options let verbose = Set.contains "verbose" options let noDependencyCheck = Set.contains "no-dependency-check" options - let withOutput = Set.contains "with-output" options let inline guardAndTime name f = guardAndTime showTimings name f + initBuild() + result { let! fullSourcePath, fullSourceDir, artifactsDir, projectFilePath, savedProjectFilePath, dependenciesHashPath, sourceHashPath, dllPath = @@ -123,21 +125,28 @@ let run (options, sourcePath, args) = do! guardAndTime "creating and writing project file" <| fun () -> let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName File.WriteAllLines(savedProjectFilePath, projectFileLines) |> Ok + + do! guardAndTime "running msbuild restore" <| fun () -> result { + let projectFileText = File.ReadAllText savedProjectFilePath + let project = createProject projectFilePath projectFileText + do! restore project |> Result.mapError RestoreError + } - if dependenciesChanged || noDll then - do! guardAndTime "running dotnet restore" <| fun () -> - File.Delete dependenciesHashPath - if File.Exists projectFilePath then File.Delete projectFilePath - File.Copy(savedProjectFilePath, projectFilePath) - let args = [ - "restore" - if not verbose then "-v:q" - projectFilePath - ] - let exitCode, stdoutLines, stderrLines = - runCommandCollectOutput "dotnet" args fullSourceDir - File.Delete projectFilePath - if exitCode <> 0 then Error(RestoreError(stdoutLines, stderrLines)) else Ok() + + // if dependenciesChanged || noDll then + // do! guardAndTime "running dotnet restore" <| fun () -> + // File.Delete dependenciesHashPath + // if File.Exists projectFilePath then File.Delete projectFilePath + // File.Copy(savedProjectFilePath, projectFilePath) + // let args = [ + // "restore" + // if not verbose then "-v:q" + // projectFilePath + // ] + // let exitCode, stdoutLines, stderrLines = + // runCommandCollectOutput "dotnet" args fullSourceDir + // File.Delete projectFilePath + // if exitCode <> 0 then Error(BuildError(stdoutLines, stderrLines)) else Ok() if sourceChanged || dependenciesChanged || noDll then do! guardAndTime "running dotnet build" <| fun () -> @@ -164,11 +173,10 @@ let run (options, sourcePath, args) = File.WriteAllText(sourceHashPath, sourceHash) |> Ok let! exitCode = guardAndTime "executing program" <| fun () -> - if withOutput then - runCommandCollectOutput "dotnet" (dllPath::args) "." |> Ok - else - runCommand "dotnet" (dllPath::args) "." |> Ok + runCommand "dotnet" (dllPath::args) "." |> Ok + finishBuild() + return exitCode } diff --git a/src/Runfs/Runfs.fsproj b/src/Runfs/Runfs.fsproj index 97cdbd4..e2eb4a1 100644 --- a/src/Runfs/Runfs.fsproj +++ b/src/Runfs/Runfs.fsproj @@ -29,13 +29,14 @@ - + - + + \ No newline at end of file diff --git a/tests/Runfs.Tests/ScriptTests.fs b/tests/Runfs.Tests/ScriptTests.fs index 59292db..8466295 100644 --- a/tests/Runfs.Tests/ScriptTests.fs +++ b/tests/Runfs.Tests/ScriptTests.fs @@ -1,29 +1,32 @@ -module Runfs.Test.Simple +module Runfs.Test.ScriptTests open System.IO open Xunit +open Runfs.Utilities open Runfs.Runfs let thisFileDirectory = __SOURCE_DIRECTORY__ let testFile1 = Path.Join(thisFileDirectory, "TestFiles/test1.fs") let testFile2 = Path.Join(thisFileDirectory, "TestFiles/test2.fs") +let runfsDll = Path.Join(thisFileDirectory, "../../artifacts/bin/runfs/debug/Runfs.dll") + +[] +let ``found runfs executable`` () = + Assert.True(File.Exists runfsDll) + [] let ``testFile1 runs correctly`` () = - match run (Set["with-output"], testFile1, ["a"; "b"]) with - | Error err -> Assert.Fail $"unexpected error {err}" - | Ok (exitCode, outLines, errLines) -> - Assert.Equal(0, exitCode) - Assert.True(("args: [a; b]" = List.exactlyOne outLines)) - Assert.Empty errLines + let exitCode, outLines, errLines = runCommandCollectOutput "dotnet" [runfsDll; testFile1; "a"; "b"] thisFileDirectory + Assert.Equal(0, exitCode) + Assert.Equal("args: [a; b]", List.exactlyOne outLines) + Assert.Empty errLines [] let ``testFile2 runs correctly`` () = - match run (Set["with-output"], testFile2, []) with - | Error err -> Assert.Fail $"unexpected error {err}" - | Ok (exitCode, outLines, errLines) -> - Assert.Equal(0, exitCode) - Assert.True(("""{"x":"Hello","y":"world!"}""" = List.exactlyOne outLines)) - Assert.Empty errLines + let exitCode, outLines, errLines = runCommandCollectOutput "dotnet" [runfsDll; testFile2] thisFileDirectory + Assert.Equal(0, exitCode) + Assert.Equal("""{"x":"Hello","y":"world!"}""", List.exactlyOne outLines) + Assert.Empty errLines \ No newline at end of file diff --git a/tests/Runfs.Tests/TestFiles/test1.fs b/tests/Runfs.Tests/TestFiles/test1.fs index ff1ccae..cac4644 100644 --- a/tests/Runfs.Tests/TestFiles/test1.fs +++ b/tests/Runfs.Tests/TestFiles/test1.fs @@ -6,6 +6,12 @@ module A = #r_property "myprop=43" #r_property "TargetFramework=net9.0" +open System + let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail printfn $"args: {args}" +// let RuntimeVersion = Environment.Version +// printfn $"Runtime version: {RuntimeVersion}" + + diff --git a/tests/Runfs.Tests/TestFiles/test2.fs b/tests/Runfs.Tests/TestFiles/test2.fs index 2d3c6e7..7b628bf 100644 --- a/tests/Runfs.Tests/TestFiles/test2.fs +++ b/tests/Runfs.Tests/TestFiles/test2.fs @@ -1,4 +1,5 @@ #r_package "FSharp.SystemTextJson@1.4.36" +#r_sdk "Microsoft.Net.Sdk" open System.Text.Json open System.Text.Json.Serialization From 76911ccb165fc0f561a710ba95a89238a57d04a6 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sat, 30 Aug 2025 14:10:41 +0200 Subject: [PATCH 04/22] delta --- src/Runfs/Build.fs | 16 +++++++++----- src/Runfs/Runfs.fs | 4 +--- ...tifact_of_Runfs_that_can_be_deleted.fsproj | 22 +++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 614b9d1..6e931e0 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -14,11 +14,14 @@ open Runfs.ProjectFile let private verbosity = "quiet" -type Project = {projectInstance: ProjectInstance; parameters: BuildParameters} +type Project = + {buildManager: BuildManager; projectInstance: ProjectInstance} + interface IDisposable with + member this.Dispose() = this.buildManager.EndBuild() + type MsRestoreError = MsRestoreError of string -let initBuild() = MSBuildLocator.RegisterDefaults() |> ignore -let finishBuild() = BuildManager.DefaultBuildManager.EndBuild() +let initMSBuild() = MSBuildLocator.RegisterDefaults() |> ignore let createProject projectFilePath (projectFileText: string) : Project = let loggerArgs = [|$"--verbosity:{verbosity}"; "NoSummary"|] @@ -44,10 +47,12 @@ let createProject projectFilePath (projectFileText: string) : Project = // let projectInstance = ProjectInstance.FromProjectRootElement(projectRoot, options) File.WriteAllText(projectFilePath, projectFileText) let projectInstance = ProjectInstance.FromFile(projectFilePath, options) - let parameters = BuildParameters(projectCollection) + let parameters = BuildParameters projectCollection parameters.Loggers <- loggers parameters.LogTaskInputs <- false - {projectInstance = projectInstance; parameters = parameters} + let buildManager = BuildManager.DefaultBuildManager + buildManager.BeginBuild parameters + {buildManager = buildManager; projectInstance = projectInstance} let restore (project: Project) = let buildManager = BuildManager.DefaultBuildManager @@ -59,7 +64,6 @@ let restore (project: Project) = let restoreRequest = new BuildRequestData(project.projectInstance, [|"Restore"|], null, flags) - buildManager.BeginBuild project.parameters let restoreResult = buildManager.BuildRequest restoreRequest if restoreResult.OverallResult = BuildResultCode.Success then Ok() diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 6167279..753eada 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -61,7 +61,7 @@ let run (options, sourcePath, args) = let noDependencyCheck = Set.contains "no-dependency-check" options let inline guardAndTime name f = guardAndTime showTimings name f - initBuild() + initMSBuild() result { let! fullSourcePath, fullSourceDir, artifactsDir, projectFilePath, @@ -175,8 +175,6 @@ let run (options, sourcePath, args) = let! exitCode = guardAndTime "executing program" <| fun () -> runCommand "dotnet" (dllPath::args) "." |> Ok - finishBuild() - return exitCode } diff --git a/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj b/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj new file mode 100644 index 0000000..6ae3ab1 --- /dev/null +++ b/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj @@ -0,0 +1,22 @@ + + + Runfs + true + false + C:\Users\Martin\AppData\Local\Temp\Runfs\test1-fc74c07713b10a174ef5bf2ab362c8ad6dc5683e710d2f3c747d36fa602a0d87 + + + + Exe + en-US + enable + 43 + net9.0 + + + + + + + + From 94cd2642882db3ff3b7be0ed85bc14c7a0fc637c Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sat, 30 Aug 2025 14:20:44 +0200 Subject: [PATCH 05/22] new runfs project logic --- src/Runfs/Runfs.fs | 44 ++++++------------- ...tifact_of_Runfs_that_can_be_deleted.fsproj | 22 ---------- 2 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 753eada..50877e8 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -122,33 +122,17 @@ let run (options, sourcePath, args) = Ok (dependenciesChanged, sourceChanged, noDll) if dependenciesChanged || sourceChanged || noDll then - do! guardAndTime "creating and writing project file" <| fun () -> + use! project = guardAndTime "creating and writing project file" <| fun () -> let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName - File.WriteAllLines(savedProjectFilePath, projectFileLines) |> Ok + File.WriteAllLines(savedProjectFilePath, projectFileLines) + let projectFileText = File.ReadAllText savedProjectFilePath + createProject projectFilePath projectFileText |> Ok - do! guardAndTime "running msbuild restore" <| fun () -> result { - let projectFileText = File.ReadAllText savedProjectFilePath - let project = createProject projectFilePath projectFileText - do! restore project |> Result.mapError RestoreError - } - + if dependenciesChanged || noDll then + do! guardAndTime "running msbuild restore" <| fun () -> result { + do! restore project |> Result.mapError RestoreError + } - // if dependenciesChanged || noDll then - // do! guardAndTime "running dotnet restore" <| fun () -> - // File.Delete dependenciesHashPath - // if File.Exists projectFilePath then File.Delete projectFilePath - // File.Copy(savedProjectFilePath, projectFilePath) - // let args = [ - // "restore" - // if not verbose then "-v:q" - // projectFilePath - // ] - // let exitCode, stdoutLines, stderrLines = - // runCommandCollectOutput "dotnet" args fullSourceDir - // File.Delete projectFilePath - // if exitCode <> 0 then Error(BuildError(stdoutLines, stderrLines)) else Ok() - - if sourceChanged || dependenciesChanged || noDll then do! guardAndTime "running dotnet build" <| fun () -> if File.Exists projectFilePath then File.Delete projectFilePath File.Copy(savedProjectFilePath, projectFilePath) @@ -164,13 +148,13 @@ let run (options, sourcePath, args) = File.Delete projectFilePath if exitCode <> 0 then Error(BuildError(stdoutLines, stderrLines)) else Ok() - if dependenciesChanged then - do! guardAndTime "saving dependencies hash" <| fun () -> - File.WriteAllText(dependenciesHashPath, dependenciesHash) |> Ok + if dependenciesChanged then + do! guardAndTime "saving dependencies hash" <| fun () -> + File.WriteAllText(dependenciesHashPath, dependenciesHash) |> Ok - if sourceChanged then - do! guardAndTime "saving source hash" <| fun () -> - File.WriteAllText(sourceHashPath, sourceHash) |> Ok + if sourceChanged then + do! guardAndTime "saving source hash" <| fun () -> + File.WriteAllText(sourceHashPath, sourceHash) |> Ok let! exitCode = guardAndTime "executing program" <| fun () -> runCommand "dotnet" (dllPath::args) "." |> Ok diff --git a/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj b/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj deleted file mode 100644 index 6ae3ab1..0000000 --- a/tests/Runfs.Tests/TestFiles/artifact_of_Runfs_that_can_be_deleted.fsproj +++ /dev/null @@ -1,22 +0,0 @@ - - - Runfs - true - false - C:\Users\Martin\AppData\Local\Temp\Runfs\test1-fc74c07713b10a174ef5bf2ab362c8ad6dc5683e710d2f3c747d36fa602a0d87 - - - - Exe - en-US - enable - 43 - net9.0 - - - - - - - - From fb8c3455451bf6be5bf36eb47cb07fec0783e693 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sat, 30 Aug 2025 14:45:52 +0200 Subject: [PATCH 06/22] new error types --- src/Runfs/Build.fs | 14 +++++++------- src/Runfs/Program.fs | 4 ++-- src/Runfs/Runfs.fs | 9 +++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 6e931e0..2603549 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -19,7 +19,7 @@ type Project = interface IDisposable with member this.Dispose() = this.buildManager.EndBuild() -type MsRestoreError = MsRestoreError of string +type MSBuildError = MSBuildError of target: string * result: string let initMSBuild() = MSBuildLocator.RegisterDefaults() |> ignore @@ -54,18 +54,18 @@ let createProject projectFilePath (projectFileText: string) : Project = buildManager.BeginBuild parameters {buildManager = buildManager; projectInstance = projectInstance} -let restore (project: Project) = +let build target project = let buildManager = BuildManager.DefaultBuildManager let flags = BuildRequestDataFlags.ClearCachesAfterBuild ||| BuildRequestDataFlags.SkipNonexistentTargets ||| BuildRequestDataFlags.IgnoreMissingEmptyAndInvalidImports ||| BuildRequestDataFlags.FailOnUnresolvedSdk - let restoreRequest = - new BuildRequestData(project.projectInstance, [|"Restore"|], null, flags) + let buildRequest = + new BuildRequestData(project.projectInstance, [|target|], null, flags) - let restoreResult = buildManager.BuildRequest restoreRequest - if restoreResult.OverallResult = BuildResultCode.Success then + let buildResult = buildManager.BuildRequest buildRequest + if buildResult.OverallResult = BuildResultCode.Success then Ok() else - Error(MsRestoreError (string restoreResult)) + Error(MSBuildError(target, string buildResult)) diff --git a/src/Runfs/Program.fs b/src/Runfs/Program.fs index ac77be2..1bd529b 100644 --- a/src/Runfs/Program.fs +++ b/src/Runfs/Program.fs @@ -38,8 +38,8 @@ let main argv = | CaughtException ex -> [$"Unexpected: {ex.Message}"] | InvalidSourcePath s -> [$"Invalid source path: {s}"] | InvalidSourceDirectory s -> [$"Invalid source directory: {s}"] - | RestoreError(MsRestoreError s) -> [$"Restore error: {s}"] - | BuildError(stdoutLines, stderrLines) -> + | BuildError(MSBuildError(target, result)) -> [$"MSBuild {target} error: {result}"] + | XBuildError(stdoutLines, stderrLines) -> "Build error" :: indent stdoutLines @ indent stderrLines | DirectiveError parseErrors -> let getParseErrorString parseError = diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 50877e8..29267f8 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -15,8 +15,8 @@ type RunfsError = | InvalidSourcePath of string | InvalidSourceDirectory of string | DirectiveError of ParseError list - | RestoreError of MsRestoreError - | BuildError of stdout: string list * stderr: string list + | BuildError of MSBuildError + | XBuildError of string list * string list let ThisPackageName = "Runfs" let DependenciesHashFileName = "dependencies.hash" @@ -129,8 +129,9 @@ let run (options, sourcePath, args) = createProject projectFilePath projectFileText |> Ok if dependenciesChanged || noDll then + File.Delete dependenciesHashPath do! guardAndTime "running msbuild restore" <| fun () -> result { - do! restore project |> Result.mapError RestoreError + do! build "restore" project |> Result.mapError BuildError } do! guardAndTime "running dotnet build" <| fun () -> @@ -146,7 +147,7 @@ let run (options, sourcePath, args) = let exitCode, stdoutLines, stderrLines = runCommandCollectOutput "dotnet" args fullSourceDir File.Delete projectFilePath - if exitCode <> 0 then Error(BuildError(stdoutLines, stderrLines)) else Ok() + if exitCode <> 0 then Error(XBuildError(stdoutLines, stderrLines)) else Ok() if dependenciesChanged then do! guardAndTime "saving dependencies hash" <| fun () -> From 2a263939d55a604bdcda1ef7316ea28f1e8a85c2 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sat, 30 Aug 2025 15:04:31 +0200 Subject: [PATCH 07/22] verbosity --- src/Runfs/Build.fs | 7 +++---- src/Runfs/Runfs.fs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 2603549..68b54f5 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -12,8 +12,6 @@ open System.IO open System.Xml open Runfs.ProjectFile -let private verbosity = "quiet" - type Project = {buildManager: BuildManager; projectInstance: ProjectInstance} interface IDisposable with @@ -23,8 +21,9 @@ type MSBuildError = MSBuildError of target: string * result: string let initMSBuild() = MSBuildLocator.RegisterDefaults() |> ignore -let createProject projectFilePath (projectFileText: string) : Project = - let loggerArgs = [|$"--verbosity:{verbosity}"; "NoSummary"|] +let createProject verbose projectFilePath (projectFileText: string) : Project = + let verbosity = if verbose then "m" else "q" + let loggerArgs = [|$"-verbosity:{verbosity}"; "-tl:off"; "NoSummary"|] let consoleLogger = TerminalLogger.CreateTerminalOrConsoleLogger loggerArgs let loggers = [|consoleLogger|] let globalProperties = diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 29267f8..644034f 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -126,7 +126,7 @@ let run (options, sourcePath, args) = let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName File.WriteAllLines(savedProjectFilePath, projectFileLines) let projectFileText = File.ReadAllText savedProjectFilePath - createProject projectFilePath projectFileText |> Ok + createProject verbose projectFilePath projectFileText |> Ok if dependenciesChanged || noDll then File.Delete dependenciesHashPath From d385b32b618ab9c359f7b714bf4e14f886084fc8 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sun, 31 Aug 2025 17:06:48 +0200 Subject: [PATCH 08/22] direct msbuild calls working, not virtual yet --- global.json | 4 ++- src/Runfs/Build.fs | 21 +++++++-------- src/Runfs/Program.fs | 2 -- src/Runfs/ProjectFile.fs | 1 + src/Runfs/Runfs.fs | 38 +++++++++++----------------- src/Runfs/Runfs.fsproj | 4 +++ tests/Runfs.Tests/TestFiles/test2.fs | 1 - 7 files changed, 34 insertions(+), 37 deletions(-) diff --git a/global.json b/global.json index d599efa..9334ba5 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,7 @@ { "sdk": { - "version": "9.0.304" + "version": "9.0.304", + "rollForward": "latestMinor", + "allowPrerelease": true } } \ No newline at end of file diff --git a/src/Runfs/Build.fs b/src/Runfs/Build.fs index 68b54f5..98e9d18 100644 --- a/src/Runfs/Build.fs +++ b/src/Runfs/Build.fs @@ -15,7 +15,9 @@ open Runfs.ProjectFile type Project = {buildManager: BuildManager; projectInstance: ProjectInstance} interface IDisposable with - member this.Dispose() = this.buildManager.EndBuild() + member this.Dispose() = + this.buildManager.EndBuild() + this.projectInstance.FullPath |> File.Delete type MSBuildError = MSBuildError of target: string * result: string @@ -36,16 +38,16 @@ let createProject verbose projectFilePath (projectFileText: string) : Project = let options = ProjectOptions() options.ProjectCollection <- projectCollection options.GlobalProperties <- globalProperties - // let createProjectRootElement() = - // let reader = new StringReader(projectFileText) - // let xmlReader = XmlReader.Create reader - // let projectRoot = ProjectRootElement.Create(xmlReader, projectCollection) - // projectRoot.FullPath <- projectFilePath - // projectRoot - // let projectRoot = createProjectRootElement(); + + // let reader = new StringReader(projectFileText) + // let xmlReader = XmlReader.Create reader + // let projectRoot = ProjectRootElement.Create(xmlReader, projectCollection) + // projectRoot.FullPath <- projectFilePath // let projectInstance = ProjectInstance.FromProjectRootElement(projectRoot, options) + File.WriteAllText(projectFilePath, projectFileText) let projectInstance = ProjectInstance.FromFile(projectFilePath, options) + let parameters = BuildParameters projectCollection parameters.Loggers <- loggers parameters.LogTaskInputs <- false @@ -54,7 +56,6 @@ let createProject verbose projectFilePath (projectFileText: string) : Project = {buildManager = buildManager; projectInstance = projectInstance} let build target project = - let buildManager = BuildManager.DefaultBuildManager let flags = BuildRequestDataFlags.ClearCachesAfterBuild ||| BuildRequestDataFlags.SkipNonexistentTargets @@ -63,7 +64,7 @@ let build target project = let buildRequest = new BuildRequestData(project.projectInstance, [|target|], null, flags) - let buildResult = buildManager.BuildRequest buildRequest + let buildResult = project.buildManager.BuildRequest buildRequest if buildResult.OverallResult = BuildResultCode.Success then Ok() else diff --git a/src/Runfs/Program.fs b/src/Runfs/Program.fs index 1bd529b..2723168 100644 --- a/src/Runfs/Program.fs +++ b/src/Runfs/Program.fs @@ -39,8 +39,6 @@ let main argv = | InvalidSourcePath s -> [$"Invalid source path: {s}"] | InvalidSourceDirectory s -> [$"Invalid source directory: {s}"] | BuildError(MSBuildError(target, result)) -> [$"MSBuild {target} error: {result}"] - | XBuildError(stdoutLines, stderrLines) -> - "Build error" :: indent stdoutLines @ indent stderrLines | DirectiveError parseErrors -> let getParseErrorString parseError = let prefix n = $" Line %3d{n}: " diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs index f0078e6..8a9a415 100644 --- a/src/Runfs/ProjectFile.fs +++ b/src/Runfs/ProjectFile.fs @@ -45,6 +45,7 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass " true" " false" $""" {escape artifactsPath}""" + $""" true""" " " yield! sdks |> List.map (sdkLine "Sdk.props") " " diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 644034f..dffb70e 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -16,7 +16,6 @@ type RunfsError = | InvalidSourceDirectory of string | DirectiveError of ParseError list | BuildError of MSBuildError - | XBuildError of string list * string list let ThisPackageName = "Runfs" let DependenciesHashFileName = "dependencies.hash" @@ -64,7 +63,7 @@ let run (options, sourcePath, args) = initMSBuild() result { - let! fullSourcePath, fullSourceDir, artifactsDir, projectFilePath, + let! fullSourcePath, fullSourceDir, artifactsDir, virtualProjectFilePath, savedProjectFilePath, dependenciesHashPath, sourceHashPath, dllPath = guardAndTime "creating paths" <| fun () -> result { do! File.Exists sourcePath |> Result.requireTrue (InvalidSourcePath sourcePath) @@ -108,7 +107,7 @@ let run (options, sourcePath, args) = return computeDependenciesHash (string fullSourceDir) directives } - let! dependenciesChanged, sourceChanged, noDll = guardAndTime "computing build level" <| fun () -> + let! dependenciesChanged, sourceChanged, noExecutable = guardAndTime "computing build level" <| fun () -> let dependenciesChanged = if noDependencyCheck then false @@ -121,33 +120,26 @@ let run (options, sourcePath, args) = let noDll = not (File.Exists dllPath) Ok (dependenciesChanged, sourceChanged, noDll) - if dependenciesChanged || sourceChanged || noDll then - use! project = guardAndTime "creating and writing project file" <| fun () -> + if dependenciesChanged || noExecutable then + do! guardAndTime "creating and writing project file" <| fun () -> let projectFileLines = createProjectFileLines directives fullSourcePath artifactsDir AssemblyName - File.WriteAllLines(savedProjectFilePath, projectFileLines) + File.WriteAllLines(savedProjectFilePath, projectFileLines) |> Ok + + if dependenciesChanged || sourceChanged || noExecutable then + use! project = guardAndTime "creating msbuild project instance" <| fun () -> let projectFileText = File.ReadAllText savedProjectFilePath - createProject verbose projectFilePath projectFileText |> Ok + createProject verbose virtualProjectFilePath projectFileText |> Ok - if dependenciesChanged || noDll then - File.Delete dependenciesHashPath + if dependenciesChanged || noExecutable then do! guardAndTime "running msbuild restore" <| fun () -> result { + File.Delete dependenciesHashPath do! build "restore" project |> Result.mapError BuildError } - do! guardAndTime "running dotnet build" <| fun () -> - if File.Exists projectFilePath then File.Delete projectFilePath - File.Copy(savedProjectFilePath, projectFilePath) - let args = [ - "build" - "--no-restore" - "-consoleLoggerParameters:NoSummary" - if not verbose then "-v:q" - projectFilePath - ] - let exitCode, stdoutLines, stderrLines = - runCommandCollectOutput "dotnet" args fullSourceDir - File.Delete projectFilePath - if exitCode <> 0 then Error(XBuildError(stdoutLines, stderrLines)) else Ok() + do! guardAndTime "running dotnet build" <| fun () -> result { + File.Delete sourceHash + do! build "build" project |> Result.mapError BuildError + } if dependenciesChanged then do! guardAndTime "saving dependencies hash" <| fun () -> diff --git a/src/Runfs/Runfs.fsproj b/src/Runfs/Runfs.fsproj index e2eb4a1..c3cb90d 100644 --- a/src/Runfs/Runfs.fsproj +++ b/src/Runfs/Runfs.fsproj @@ -38,5 +38,9 @@ + \ No newline at end of file diff --git a/tests/Runfs.Tests/TestFiles/test2.fs b/tests/Runfs.Tests/TestFiles/test2.fs index 7b628bf..9359faa 100644 --- a/tests/Runfs.Tests/TestFiles/test2.fs +++ b/tests/Runfs.Tests/TestFiles/test2.fs @@ -8,4 +8,3 @@ let options = JsonFSharpOptions.Default().ToJsonSerializerOptions() let s = JsonSerializer.Serialize({| x = "Hello"; y = "world!" |}, options) printfn $"%s{s}" - From 51e13f8ff561dd7b7f020ee510996214c71f8d96 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sun, 31 Aug 2025 17:28:17 +0200 Subject: [PATCH 09/22] change log update --- CHANGELOG.md | 13 +++++++++++++ src/Runfs/Runfs.fsproj | 4 ++-- ttt/test1.fs | 11 ----------- 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 ttt/test1.fs diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..71c9281 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# CHANGELOG + +## 1.0.3 + +### changed + +* direct calls to msbuild, but still no virtual (in-memory) project file + +## 1.0.2 + +### added + +* initial version diff --git a/src/Runfs/Runfs.fsproj b/src/Runfs/Runfs.fsproj index c3cb90d..9fcbad1 100644 --- a/src/Runfs/Runfs.fsproj +++ b/src/Runfs/Runfs.fsproj @@ -2,7 +2,7 @@ Runfs - 1.0.2 + 1.0.3 "dotnet run app.cs" functionality for F#. Copyright 2025 by Martin521 Martin521 and contributors @@ -14,7 +14,7 @@ F# True runfs - + https://github.com/Martin521/Runfs/CHANGELOG.md true diff --git a/ttt/test1.fs b/ttt/test1.fs deleted file mode 100644 index 5274e98..0000000 --- a/ttt/test1.fs +++ /dev/null @@ -1,11 +0,0 @@ -module A = - open System - - // #r_project "abc/xyz.fsproj" - // #r_dll "System.dll" - // #r_property "myprop=42" - // #r_property "TargetFramework=net8.0" - - let args = System.Environment.GetCommandLineArgs() |> Array.toList |> List.tail - printfn $"args: {args}" - From 7dfd272a8b5748725fe81c7a6a5ab3fc6a405632 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 10:47:01 +0200 Subject: [PATCH 10/22] workflow updates --- .github/workflows/main.yaml | 8 +++++-- .github/workflows/release.yaml | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4841fd9..9428203 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,15 +14,19 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest ] + os: [ ubuntu-latest, windows-latest ] steps: - name: Checkout uses: actions/checkout@v5 + - name: Setup .NET Core uses: actions/setup-dotnet@v4 + - name: Restore run: dotnet restore + - name: Build run: dotnet build -c Release --no-restore + - name: Test - run: dotnet test -c Release + run: dotnet test -c Release --no-build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ca0a73f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,40 @@ +name: Test + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore + + - name: Test + run: dotnet test -c Release --no-build + + - name: Pack + run: dotnet pack + + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Dump job context + env: + JOB_CONTEXT: ${{ toJson(job) }} + run: echo "$JOB_CONTEXT" + # - name: Publish to GPR + # run: dotnet nuget push "./artifacts/package/release/*.nupkg" -k ${{ secrets.YOUR_NUGET_KEY }} From 3bc91438ee171da132e4d3eee81d3fb89c717ef5 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:00:36 +0200 Subject: [PATCH 11/22] update test re config path --- tests/Runfs.Tests/ScriptTests.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Runfs.Tests/ScriptTests.fs b/tests/Runfs.Tests/ScriptTests.fs index 8466295..b719121 100644 --- a/tests/Runfs.Tests/ScriptTests.fs +++ b/tests/Runfs.Tests/ScriptTests.fs @@ -9,11 +9,17 @@ let thisFileDirectory = __SOURCE_DIRECTORY__ let testFile1 = Path.Join(thisFileDirectory, "TestFiles/test1.fs") let testFile2 = Path.Join(thisFileDirectory, "TestFiles/test2.fs") -let runfsDll = Path.Join(thisFileDirectory, "../../artifacts/bin/runfs/debug/Runfs.dll") +let configPath = + #if DEBUG + "debug" + #else + "release" + #endif +let runfsDll = Path.Join(thisFileDirectory, $"../../artifacts/bin/runfs/{configPath}/Runfs.dll") [] let ``found runfs executable`` () = - Assert.True(File.Exists runfsDll) + Assert.True(File.Exists runfsDll, $"not found: {runfsDll}") [] let ``testFile1 runs correctly`` () = From 6de3790ea02c3a5903ab3e091011ce0a9e0c64d7 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:13:24 +0200 Subject: [PATCH 12/22] update test path --- tests/Runfs.Tests/ScriptTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Runfs.Tests/ScriptTests.fs b/tests/Runfs.Tests/ScriptTests.fs index b719121..3026e31 100644 --- a/tests/Runfs.Tests/ScriptTests.fs +++ b/tests/Runfs.Tests/ScriptTests.fs @@ -15,7 +15,7 @@ let configPath = #else "release" #endif -let runfsDll = Path.Join(thisFileDirectory, $"../../artifacts/bin/runfs/{configPath}/Runfs.dll") +let runfsDll = Path.Join(thisFileDirectory, $"../../artifacts/bin/Runfs/{configPath}/Runfs.dll") [] let ``found runfs executable`` () = From 8c71e8766f8290db0d87695575e6886b0e8d1597 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:14:00 +0200 Subject: [PATCH 13/22] workflow test --- .github/workflows/release.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ca0a73f..849351b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,6 +22,21 @@ jobs: - name: Build run: dotnet build -c Release --no-restore + - name: L1 + run: bash -c "ls ../.." + + - name: L2 + run: bash -c "ls ../.." + + - name: L3 + run: bash -c "ls ../../artifacts" + + - name: L4 + run: bash -c "ls ../../artifacts/bin" + + - name: L5 + run: bash -c "ls ../../artifacts/bin" + - name: Test run: dotnet test -c Release --no-build From 98577f9e269a7ccb7f65770522a6e24aae400941 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:16:29 +0200 Subject: [PATCH 14/22] test --- .github/workflows/release.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 849351b..9df2807 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,19 +23,16 @@ jobs: run: dotnet build -c Release --no-restore - name: L1 - run: bash -c "ls ../.." - - - name: L2 - run: bash -c "ls ../.." + run: bash -c "ls ." - name: L3 - run: bash -c "ls ../../artifacts" + run: bash -c "ls ./artifacts" - name: L4 - run: bash -c "ls ../../artifacts/bin" + run: bash -c "ls ./artifacts/bin" - name: L5 - run: bash -c "ls ../../artifacts/bin" + run: bash -c "ls ./artifacts/bin" - name: Test run: dotnet test -c Release --no-build From 4717cedfbe07fc16cd426f141786a18dc09ff313 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:26:54 +0200 Subject: [PATCH 15/22] test workflow --- .github/workflows/release.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9df2807..e70263e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,14 +25,17 @@ jobs: - name: L1 run: bash -c "ls ." - - name: L3 - run: bash -c "ls ./artifacts" + - name: L1 + run: bash -c "ls ./src" + + # - name: L3 + # run: bash -c "ls ./artifacts" - - name: L4 - run: bash -c "ls ./artifacts/bin" + # - name: L4 + # run: bash -c "ls ./artifacts/bin" - - name: L5 - run: bash -c "ls ./artifacts/bin" + # - name: L5 + # run: bash -c "ls ./artifacts/bin" - name: Test run: dotnet test -c Release --no-build From a7f97eb62db22cdad86e23177f282b9779436b40 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:30:37 +0200 Subject: [PATCH 16/22] c --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e70263e..9ad7833 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,8 +25,8 @@ jobs: - name: L1 run: bash -c "ls ." - - name: L1 - run: bash -c "ls ./src" + - name: L2 + run: bash -c "ls ./src/Runfs" # - name: L3 # run: bash -c "ls ./artifacts" From 9b340eb3fc60d1fdaa46657324b0551a1c640362 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:32:49 +0200 Subject: [PATCH 17/22] pre-rename --- Directory.Build.propsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Directory.Build.propsx diff --git a/Directory.Build.propsx b/Directory.Build.propsx new file mode 100644 index 0000000..c91fe30 --- /dev/null +++ b/Directory.Build.propsx @@ -0,0 +1,7 @@ + + + en-US + true + enable + + From ef84a2000d0ad5addc0d57f613f8860670d813dc Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:33:04 +0200 Subject: [PATCH 18/22] pre-rename2 --- Directory.Build.Props | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Directory.Build.Props diff --git a/Directory.Build.Props b/Directory.Build.Props deleted file mode 100644 index c91fe30..0000000 --- a/Directory.Build.Props +++ /dev/null @@ -1,7 +0,0 @@ - - - en-US - true - enable - - From b590dc9a8092f94a3c2d6cf5430136f0165829a9 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:33:55 +0200 Subject: [PATCH 19/22] rename --- Directory.Build.propsx => Directory.Build.props | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Directory.Build.propsx => Directory.Build.props (100%) diff --git a/Directory.Build.propsx b/Directory.Build.props similarity index 100% rename from Directory.Build.propsx rename to Directory.Build.props From 2827dfffedb958d48390d2e5e0390a2d7f183f02 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:02:26 +0200 Subject: [PATCH 20/22] change test --- .github/workflows/release.yaml | 15 --------------- tests/Runfs.Tests/TestFiles/test2.fs | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9ad7833..ca0a73f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,21 +22,6 @@ jobs: - name: Build run: dotnet build -c Release --no-restore - - name: L1 - run: bash -c "ls ." - - - name: L2 - run: bash -c "ls ./src/Runfs" - - # - name: L3 - # run: bash -c "ls ./artifacts" - - # - name: L4 - # run: bash -c "ls ./artifacts/bin" - - # - name: L5 - # run: bash -c "ls ./artifacts/bin" - - name: Test run: dotnet test -c Release --no-build diff --git a/tests/Runfs.Tests/TestFiles/test2.fs b/tests/Runfs.Tests/TestFiles/test2.fs index 9359faa..58d3815 100644 --- a/tests/Runfs.Tests/TestFiles/test2.fs +++ b/tests/Runfs.Tests/TestFiles/test2.fs @@ -1,5 +1,5 @@ #r_package "FSharp.SystemTextJson@1.4.36" -#r_sdk "Microsoft.Net.Sdk" +//#r_sdk "Microsoft.Net.Sdk" open System.Text.Json open System.Text.Json.Serialization From bb1c96abebe7effa8565f61d6cec015aff958515 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:14:15 +0200 Subject: [PATCH 21/22] try find version --- .github/workflows/release.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ca0a73f..2e117c3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,13 +28,9 @@ jobs: - name: Pack run: dotnet pack - - name: Dump GitHub context + - name: Version (from tag) env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Dump job context - env: - JOB_CONTEXT: ${{ toJson(job) }} - run: echo "$JOB_CONTEXT" + VERSION: ${{ github.ref_name }} + run: echo "$VERSION" # - name: Publish to GPR # run: dotnet nuget push "./artifacts/package/release/*.nupkg" -k ${{ secrets.YOUR_NUGET_KEY }} From 333d6123c50744b2856dee0b90c2eb2403a8e426 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:28:22 +0200 Subject: [PATCH 22/22] final delta --- .github/workflows/release.yaml | 6 ++---- CHANGELOG.md | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e117c3..81e9c3f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,9 +28,7 @@ jobs: - name: Pack run: dotnet pack - - name: Version (from tag) + - name: Push to nuget.org env: VERSION: ${{ github.ref_name }} - run: echo "$VERSION" - # - name: Publish to GPR - # run: dotnet nuget push "./artifacts/package/release/*.nupkg" -k ${{ secrets.YOUR_NUGET_KEY }} + run: dotnet nuget push "./artifacts/package/release/runfs.${VERSION}.nupkg" -k ${{ secrets.NUGET_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c9281..98c0711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,10 @@ ### changed -* direct calls to msbuild, but still no virtual (in-memory) project file +* Direct calls to msbuild, making runfs faster. But still no virtual (in-memory) project file due to sdk dll hell. ## 1.0.2 ### added -* initial version +* Initial version