Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at FSharp.Compiler.CodeDom.Internal.Compiler.compileFiles(String args, CompilerResults res)
at FSharp.Compiler.CodeDom.Internal.Compiler.compileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames, CompilerResults results, FSharpFunc`2 sortf)
at Program.main(String[] argv)
open System.IO
open System.CodeDom.Compiler
open FSharp.Compiler.CodeDom
[<EntryPoint>]
let main argv =
let sourceFilePath = Array.get argv 0
if File.Exists(sourceFilePath) then
let provider = new FSharpCodeProvider()
let mutable compilerParameters = CompilerParameters()
compilerParameters.GenerateInMemory <- true
provider.CompileAssemblyFromFile(compilerParameters, [| sourceFilePath |])
|> ignore
else
printf "File does not exist"
0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Compiler.CodeDom" Version="1.0.0.1" />
</ItemGroup>
</Project>
namespace Foo
type Bar = { baz : int }
The program executes without throwing an exception.
No known workarounds.