Invalid F# template when dotnet new
See original GitHub issueSteps to reproduce
dotnet new console -lang F#
dotnet build
Expected behavior
Build should pass. When F# compilation items should be either not listed or there should be <EnableDefaultCompileItems>False</EnableDefaultCompileItems>
. My vote is for the latter, because order of compiled files is important in F#.
Actual behavior
This is the generated fsproj
$ cat example.fsproj
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
</ItemGroup>
</Project>
And build failure:
ide@9e64a121ed53:/ide/work/example$ dotnet build
Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(165,5): error : Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'Program.fs' [/ide/work/example/example.fsproj]
Build FAILED.
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(165,5): error : Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'Program.fs' [/ide/work/example/example.fsproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.60
Environment data
$ dotnet --info
.NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: debian
OS Version: 8
OS Platform: Linux
RID: debian.8-x64
Base Path: /usr/share/dotnet/sdk/1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
dotnet new fails if there's an invalidly pathed template ...
I found a workaround to fix this by re-creating the offending folder from the error message. It worked just by creating the folder...
Read more >dotnet new <TEMPLATE> - .NET CLI
The dotnet new command creates new .NET projects based on the specified template.
Read more >How to fix "failed to create template" when creating new ...
NET sdk and opening a new command prompt and running the following command:dotnet everything went smoothly but after entering this command:
Read more >Invalid syntax of template instantiation is accepted
[severity:It's more difficult to complete my work] This program is accepted by the compiler: template<class T> struct A{}; using AInt ...
Read more >How to Create Your .NET Project Template
Let's install it locally by running the following command in the templates-playground/templates/auth0-webapp folder: dotnet new --install . This command lets ...
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
@tomzo @petertiedemann you miss the
dotnet restore
step.for more info about f# see wiki https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-1.0.1
@tomzo as a note,
EnableDefaultCompileItems
is added already byFSharp.NET.Sdk
But because there was not dotnet resto, it was not addedif you get more issues, please fill in https://github.com/dotnet/netcorecli-fsc/issues
@piotrpMSFT this can be closed.
@Fedreg the new sdk 1.0 released some days ago now will show two warnings (if fsharp.net.sdk is not added/restored as package ref) and an error if restore is not done (the
obj/project.assets.json
doesnt exists), with a more clear message about “you forgot restore”