Where does Ionide + Fake put the output executable?

Viewed 154

I am trying to use .NET Core + Ionide + VS Code + Fake + Paket on macOS High Sierra.

Using the project generator, I have created a Suave application called Test. Ionide seems to have generated the appropriate files. After tweaking the TargetFramework to .NET Core, I can build successfully:

$ ./build.sh
...
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.72
Finished Target: Build

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target             Duration
------             --------
Clean              00:00:00.0026904
InstallDotNetCLI   00:00:01.2292511
Restore            00:00:04.2731055
Build              00:00:07.1234434
Total:             00:00:12.7035334
---------------------------------------------------------------------
Status:            Ok
---------------------------------------------------------------------

There are now some files in Test/bin, but none of them are .exe, which is what I would expect as output from fsharpc.

Where does Ionide + Fake put the output executable?


My project has OutputType executable:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
    <Compile Include="Test.fs" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
2 Answers

.Net Core compiles all projects (even executable applications) to .dll not .exe that can be run with dotnet PATH_TO_DLL. In the bin folder, in the subfolder for given framework target there should be file YOUR_PROJECT_NAME.dll that can be run with dotnet CLI.

To generate an exe you need to supply a run-time identifier. You can include this in the fsproj with
<PropertyGroup> <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers> </PropertyGroup>
but you don't need to do that. You can use VSCode's tasks.json file to set up a build task.

My suggestion is just to run the dotnet CLI:

dotnet build -c Release -r win10-x64

This will create an exe in the bin\release\netcoreapp2.0\win10-x64 folder. You can also dotnet publish if you want a self-contained directory to deploy (this can get large). The id for OSX will be something like osx-x64.

By default ionide generates an fsproj file that is targetting net461, and you might also need Fake 5 for dotnetcore. I also suggest you use paket in magic-mode, and commit the .exe to github (if you use git).

Related