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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
##
## Get latest from `dotnet new gitignore`

TODO.md
meeting.md
dotnet-tools.json

# dotenv files
.env

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 1.0.6

### added

* support for "source", "project" and "dll" reference directives

## 1.0.5

### changed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions src/Runfs/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ let private packageLine (name, version) =
| None -> $""" <PackageReference Include="{escape name}" />"""
| Some v -> $""" <PackageReference Include="{escape name}" Version="{escape v}"/>"""

let private sourceLine name =
$""" <Compile Include="{escape name}" />"""

let private dllLine name =
$""" <Reference Include="{escape name}" />"""

let private projectLine name =
$""" <ProjectReference Include="{escape name}" />"""

let createProjectFileLines directives entryPointSourceFullPath artifactsPath assemblyName =
let sdks =
match directives |> List.choose (function Sdk(n, v) -> Some(n, v) | _ -> None) with
Expand All @@ -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)

[
"<Project>"
Expand All @@ -56,6 +68,13 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass
yield! packages |> List.map packageLine
" </ItemGroup>"
" <ItemGroup>"
yield! dlls |> List.map dllLine
" </ItemGroup>"
" <ItemGroup>"
yield! projects |> List.map projectLine
" </ItemGroup>"
" <ItemGroup>"
yield! sources |> List.map sourceLine
$""" <Compile Include="{escape entryPointSourceFullPath}" />"""
" </ItemGroup>"
yield! sdks |> List.map (sdkLine "Sdk.targets")
Expand Down
3 changes: 2 additions & 1 deletion src/Runfs/Runfs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () ->
Expand Down
12 changes: 8 additions & 4 deletions src/Runfs/Runfs.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- General -->
<AssemblyName>Runfs</AssemblyName>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<Description>"dotnet run app.cs" functionality for F#.</Description>
<Copyright>Copyright 2025 by Martin521</Copyright>
<Authors>Martin521 and contributors</Authors>
Expand All @@ -14,7 +14,13 @@
<PackageTags>F#</PackageTags>
<PackAsTool>True</PackAsTool>
<ToolCommandName>runfs</ToolCommandName>
<PackageReleaseNotes>https://github.com/Martin521/Runfs/blob/main/CHANGELOG.md</PackageReleaseNotes>
<PackageReleaseNotes>
## 1.0.6

### added

* support for "source", "project" and "dll" reference directives
</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageIcon>
</PackageIcon>
Expand All @@ -39,7 +45,5 @@

<PackageReference Include="Microsoft.Build" Version="17.14.8" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.9.1" />

<!-- <PackageReference Include="Microsoft.Build" Version="17.15.0-preview-25277-114" /> -->
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions tests/Runfs.Tests/TestFiles/test1.fs
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
Loading