.NET Core example fails to compile
See original GitHub issueMy 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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
:ref https://andrewlock.net/fixing-the-error-program-has-more-than-one-entry-point-defined-for-console-apps-containing-xunit-tests/
Perfect! It is working smoothly.
Thanks!