Fsharp: "Main module of program is empty: nothing will happen when it is run" warning when running xunit tests on .net core.

Created on 21 Mar 2017  路  2Comments  路  Source: dotnet/fsharp

Please provide a succinct description of the issue.

Repro steps

Create a test directory then from command line

  1. dotnet new xunit -lang F#

  2. dotnet add package xUnit

  3. dotnet restore

  4. dotnet test

Expected behavior

Run the tests without warnings.

Actual behavior

It generates a warning, Main module of program is empty: nothing will happen when it is run

Here's my output

C:\...\Documents\Projects\xunit_test>dotnet test
Build started, please wait...
C:\Users\onur.gumus\Documents\Projects\xunit_test\Tests.fs(8,22): warning FS0988: Main module of program is empty: nothing will happen when
it is run [C:\Users\onur.gumus\Documents\Projects\xunit_test\xunit_test.fsproj]
Build completed.

Test run for C:\Users\onur.gumus\Documents\Projects\xunit_test\bin\Debug\netcoreapp1.1\xunit_test.dll(.NETCoreApp,Version=v1.1)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
[xUnit.net 00:00:01.0591665]   Discovering: xunit_test
[xUnit.net 00:00:01.1484271]   Discovered:  xunit_test
[xUnit.net 00:00:01.1898693]   Starting:    xunit_test
[xUnit.net 00:00:01.2949161]   Finished:    xunit_test

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.0677 Seconds

Known workarounds

No

Related information

Windows with dotnet version 1.0.1 SDK version 1.1.0

All 2 comments

this a problem with the template, netcore test projects are all console apps, and F# console apps need a function with [<EntryPoint>]

this is all you need to make the warning go away

[<EntryPoint>]
let main argv = 0


cc @enricosada

@OnurGumus it's like @cloudRoutine say, and is tracked in https://github.com/dotnet/netcorecli-fsc/issues/79

@KevinRansom @OnurGumus this can be closed, the update of xunit/mstest templates is tracked in the referenced issue

Was this page helpful?
0 / 5 - 0 ratings