diff --git a/.gitignore b/.gitignore
index bc78471..80e90a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,10 @@
##
## Get latest from `dotnet new gitignore`
+TODO.md
+meeting.md
+dotnet-tools.json
+
# dotenv files
.env
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e15c922..16e071e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# CHANGELOG
+## 1.0.6
+
+### added
+
+* support for "source", "project" and "dll" reference directives
+
## 1.0.5
### changed
diff --git a/README.md b/README.md
index 0a1028b..7233f30 100644
--- a/README.md
+++ b/README.md
@@ -22,9 +22,9 @@ The following directives (source lines) are recognized by runfs:
- `#r_package "pp@1.0.0"` - references package pp, version 1.0.0
- `#r_sdk "mysdk@0.0.1"` - references an sdk
- `#r_property "myprop=42"` - sets a build property
-- `#r_project "xyz.fsproj"` - references a project [not yet implemented]
-- `#r_dll "mylib.dll"` - references a library [not yet implemented]
-- `#r_source "utilities.fs"` - references a source file [not yet implemented]
+- `#r_project "xyz.fsproj"` - references a project
+- `#r_dll "mylib.dll"` - references a library
+- `#r_source "utilities.fs"` - references a source file
> The above directive syntax is preliminary and made to work with the current F# compiler (the parser accepts and ignores them). Ideally, the syntax defined for "dotnet run app.cs" should be reused, like `#:package pp@1.0.0`, but this needs a compiler fix first.
@@ -63,7 +63,7 @@ Main learnings
Runfs
- investigate if the "compile only" shortcut can be replicated for F#
- add more tests, possibly Rid-package, fix case sensitivity issue in Directives.fs
-- implement the #project, #source and #dll directives and `--convert`
+- implement `--convert`
Elsewhere
- propose and possibly implement a compiler change so that the 'dotnet run app.cs' syntax for directives can be used
diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs
index eea9551..538a15a 100644
--- a/src/Runfs/ProjectFile.fs
+++ b/src/Runfs/ProjectFile.fs
@@ -27,6 +27,15 @@ let private packageLine (name, version) =
| None -> $""" """
| Some v -> $""" """
+let private sourceLine name =
+ $""" """
+
+let private dllLine name =
+ $""" """
+
+let private projectLine name =
+ $""" """
+
let createProjectFileLines directives entryPointSourceFullPath artifactsPath assemblyName =
let sdks =
match directives |> List.choose (function Sdk(n, v) -> Some(n, v) | _ -> None) with
@@ -37,6 +46,9 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass
let remainingDefaultProperties =
DefaultProperties |> List.filter (fun (k, _) -> not (Map.containsKey (k.ToLowerInvariant()) properties))
let packages = directives |> List.choose (function Package(n, v) -> Some(n, v) | _ -> None)
+ let dlls = directives |> List.choose (function Dll n -> Some n | _ -> None)
+ let sources = directives |> List.choose (function Source n -> Some n | _ -> None)
+ let projects = directives |> List.choose (function Project n -> Some n | _ -> None)
[
""
@@ -56,6 +68,13 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass
yield! packages |> List.map packageLine
" "
" "
+ yield! dlls |> List.map dllLine
+ " "
+ " "
+ yield! projects |> List.map projectLine
+ " "
+ " "
+ yield! sources |> List.map sourceLine
$""" """
" "
yield! sdks |> List.map (sdkLine "Sdk.targets")
diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs
index 7ae69b8..3bf5f3b 100644
--- a/src/Runfs/Runfs.fs
+++ b/src/Runfs/Runfs.fs
@@ -118,7 +118,8 @@ let run (options, sourcePath, args) =
let readPreviousSourceHash() = File.ReadAllText sourceHashPath
not (File.Exists sourceHashPath && readPreviousSourceHash() = sourceHash)
let noDll = not (File.Exists dllPath)
- Ok (dependenciesChanged || noDll, sourceChanged)
+ let hasProjectDirective = directives |> List.exists (function Project _ -> true | _ -> false)
+ Ok (dependenciesChanged || noDll || hasProjectDirective, sourceChanged)
if needsRestore then
do! guardAndTime "creating and writing project file" <| fun () ->
diff --git a/src/Runfs/Runfs.fsproj b/src/Runfs/Runfs.fsproj
index f020813..ac2c7e5 100644
--- a/src/Runfs/Runfs.fsproj
+++ b/src/Runfs/Runfs.fsproj
@@ -2,7 +2,7 @@
Runfs
- 1.0.5
+ 1.0.6
"dotnet run app.cs" functionality for F#.
Copyright 2025 by Martin521
Martin521 and contributors
@@ -14,7 +14,13 @@
F#
True
runfs
- https://github.com/Martin521/Runfs/blob/main/CHANGELOG.md
+
+## 1.0.6
+
+### added
+
+* support for "source", "project" and "dll" reference directives
+
true
@@ -39,7 +45,5 @@
-
-
\ No newline at end of file
diff --git a/tests/Runfs.Tests/TestFiles/test1.fs b/tests/Runfs.Tests/TestFiles/test1.fs
index fc3b416..43b3266 100644
--- a/tests/Runfs.Tests/TestFiles/test1.fs
+++ b/tests/Runfs.Tests/TestFiles/test1.fs
@@ -1,8 +1,8 @@
module A =
open System
-#r_project "abc/xyz.fsproj"
-#r_dll "System.dll"
+// #r_project "abc/xyz.fsproj"
+// #r_dll "System.dll"
#r_property "myprop=43"
#r_property "TargetFramework=net9.0"