Skip to content

Commit f18ce47

Browse files
Replace .fsproj in fable_modules
1 parent 974d1d1 commit f18ce47

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/Fable.Cli/ProjectCracker.fs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,14 @@ let createFableDir (opts: CrackerOptions) =
463463

464464
fableDir
465465

466-
let copyDirIfDoesNotExist (source: string) (target: string) =
466+
// Replace the .fsproj extension with .fableproj for files in fable_modules
467+
// We do this to avoid conflicts with other F# tooling that scan for .fsproj files
468+
let changeFsprojToFableproj (path: string) =
469+
if path.EndsWith(".fsproj") then
470+
IO.Path.ChangeExtension(path, Naming.fableProjExt)
471+
else path
472+
473+
let copyDirIfDoesNotExist replaceFsprojExt (source: string) (target: string) =
467474
if isDirectoryEmpty target then
468475
IO.Directory.CreateDirectory(target) |> ignore
469476
if IO.Directory.Exists source |> not then
@@ -472,8 +479,10 @@ let copyDirIfDoesNotExist (source: string) (target: string) =
472479
let target = target.TrimEnd('/', '\\')
473480
for dirPath in IO.Directory.GetDirectories(source, "*", IO.SearchOption.AllDirectories) do
474481
IO.Directory.CreateDirectory(dirPath.Replace(source, target)) |> ignore
475-
for newPath in IO.Directory.GetFiles(source, "*.*", IO.SearchOption.AllDirectories) do
476-
IO.File.Copy(newPath, newPath.Replace(source, target), true)
482+
for fromPath in IO.Directory.GetFiles(source, "*.*", IO.SearchOption.AllDirectories) do
483+
let toPath = fromPath.Replace(source, target)
484+
let toPath = if replaceFsprojExt then changeFsprojToFableproj toPath else toPath
485+
IO.File.Copy(fromPath, toPath, true)
477486

478487
let copyFableLibraryAndPackageSources (opts: CrackerOptions) (pkgs: FablePackage list) =
479488
let fableLibDir = createFableDir opts
@@ -501,15 +510,16 @@ let copyFableLibraryAndPackageSources (opts: CrackerOptions) (pkgs: FablePackage
501510

502511
Log.verbose(lazy ("fable-library: " + fableLibrarySource))
503512
let fableLibraryTarget = IO.Path.Combine(fableLibDir, "fable-library" + "." + Literals.VERSION)
504-
copyDirIfDoesNotExist fableLibrarySource fableLibraryTarget
513+
copyDirIfDoesNotExist false fableLibrarySource fableLibraryTarget
505514
fableLibraryTarget
506515

507516
let pkgRefs =
508517
pkgs |> List.map (fun pkg ->
509518
let sourceDir = IO.Path.GetDirectoryName(pkg.FsprojPath)
510519
let targetDir = IO.Path.Combine(fableLibDir, pkg.Id + "." + pkg.Version)
511-
copyDirIfDoesNotExist sourceDir targetDir
512-
{ pkg with FsprojPath = IO.Path.Combine(targetDir, IO.Path.GetFileName(pkg.FsprojPath)) })
520+
copyDirIfDoesNotExist true sourceDir targetDir
521+
let fsprojFile = IO.Path.GetFileName(pkg.FsprojPath) |> changeFsprojToFableproj
522+
{ pkg with FsprojPath = IO.Path.Combine(targetDir, fsprojFile) })
513523

514524
fableLibraryPath, pkgRefs
515525

src/Fable.Transforms/Global/Prelude.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ module Naming =
129129
let [<Literal>] placeholder = "__PLACE-HOLDER__"
130130
let [<Literal>] dummyFile = "__DUMMY-FILE__.txt"
131131
let [<Literal>] fableHiddenDir = "fable_modules"
132+
let [<Literal>] fableProjExt = ".fableproj"
132133
let [<Literal>] unknown = "UNKNOWN"
133134

134135
let isInFableHiddenDir (file: string) =

0 commit comments

Comments
 (0)