netcorecli-fsc icon indicating copy to clipboard operation
netcorecli-fsc copied to clipboard

None MSBuild items added for .fs files when compiling

Open mrward opened this issue 7 years ago • 1 comments

If you compile a F# console project you see None items added for each .fs file in the project.

To reproduce:

.NET SDK 1.0.1 installed.

  1. dotnet new console -lang F#
  2. dotnet restore
  3. dotnet build /v:diag > build.log

If you look in the build.log you see a None and a Compile item for Program.fs:

                   Compile
                       Program.fs
                   DebugSymbolsProjectOutputGroupOutput
                      ~/Projects/Tests/dotnet/bar/obj/Debug/netcoreapp1.1/bar.pdb
                           FinalOutputPath = ~/Tests/dotnet/bar/bin/Debug/netcoreapp1.1/bar.pdb
                           TargetPath = bar.pdb
                   DeployManifest
                       obj/Debug/netcoreapp1.1/bar.application
                           TargetPath = bar.application
                   IntermediateAssembly
                       obj/Debug/netcoreapp1.1/bar.dll
                   None
                       Program.fs

If you edit the .fsproj file and add <EnableDefaultItems>false</EnableDefaultItems> the None items are not added.

The FSharp.NET.Sdk 1.0.1 NuGet package has the following in its FSharp.NET.Sdk.props:

<EnableDefaultCompileItems>false</EnableDefaultCompileItems>

So maybe this should also have EnableDefaultItems set to false. Not sure if EnableDefaultEmbeddedResourceItems and EnableDefaultNoneItems need to be set to false. It looks like just setting EnableDefaultItems to false would fix the problem.

In general this does not seem to break anything. The build still works. I only noticed it with recent VS for Mac builds since VS for Mac is now using the SDK imports to determine the files that should be displayed in the Solution window and I was seeing duplicate files. The duplicate files in VS for Mac was not caused by this, since due to another bug it is using resolved MSBuild items ignoring the conditions, but I whilst debugging I ran across this and initially thought it was the cause.

mrward avatar Mar 15 '17 20:03 mrward

@mrward i checked and i can repro.

But i prefer try to not disable defaults (EnableDefaultItems) if possibile, because it mean duplicate that logic (like for Resource) and that mean more maintenance.

Also is not f# specific but more a corner case in sdk default items.

I think i fixed that directly with https://github.com/dotnet/sdk/pull/1163 , removing from None all the Compile items (in that special scenario).

enricosada avatar Apr 30 '17 13:04 enricosada