question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Core example fails to compile

See original GitHub issue

My settings:

  • dotnet version: 2.1.302
  • Expecto.Template::9.0.0

I just followed the instructions on REAME and I get a build failure. I think I’m missing something very simple.

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 50 ms for /home/boechat/Codes/Fsharp/ExpectoTest/ExpectoTest.fsproj.
/home/boechat/Codes/Fsharp/ExpectoTest/Main.fs(6,5): error FS0433: A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence. [/home/boechat/Codes/Fsharp/ExpectoTest/ExpectoTest.fsproj]         

Build FAILED.

/home/boechat/Codes/Fsharp/ExpectoTest/Main.fs(6,5): error FS0433: A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence. [/home/boechat/Codes/Fsharp/ExpectoTest/ExpectoTest.fsproj]         
    0 Warning(s)
    1 Error(s)

I’m not an experienced .NET developer, but the compilation order seems correct to me in ExpectoTest.fsproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Sample.fs" />
    <Compile Include="Main.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Expecto" Version="8.*" />
    <PackageReference Include="FSharp.Core" Version="4.*" />
    <PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.*" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.*" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.*" />
  </ItemGroup>
</Project>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
0x53Acommented, Sep 17, 2018

The issue is the Microsoft.NET.Test.Sdk.

It will add a new file into your build with a Main.

But you don’t want this synthesized main, you want to keep your own.

So add this to a PropertyGroup:

<GenerateProgramFile>false</GenerateProgramFile>

ref https://andrewlock.net/fixing-the-error-program-has-more-than-one-entry-point-defined-for-console-apps-containing-xunit-tests/

1reaction
boechat107commented, Sep 23, 2018

Perfect! It is working smoothly.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.Net Core: Hundreds of Build Errors Suddenly
Try to close Visual Studio and reopen. That always works for me to get the libraries back.
Read more >
Fail to build asp.net core 5
Hello! I'm stuck with building asp dot net core 5.0 on Windows 10 I followed the instruction but have no luck. The output...
Read more >
.NET Core projects having compile issues : RSRP-483917
.NET Core projects having compile issues ... This is a long issue, so I will try to be as succinct as possible. I...
Read more >
New .NET Core 2.0 mvc app doesn't compile
Created a new .NET Core 2.0 mvc app and tried to ompile before I changed anything, but it fails to compile with the...
Read more >
Compile error targeting .NET 5.0. Support for .NET Core in ...
Problem. When trying to compile an application with Target Framework .NET 5.0, it fails with the following error: "Expected file "obj\Debug ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found