I have a .NET Core project which I compile on Windows 10 x64 using the type provider workaround:
<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true' AND Exists('C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsc.exe')">
<FscToolPath>C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
(plus several other such PropertyGroups for various compiler locations, the most recent being VS2019 preview)
The project succesfully compiles using the .NET SDK 2.2.104 (current).
Using the 3.0 preview (3.0.100-preview3-010431), however, __the path to the dotnet fsc.exe compiler (DotnetFscCompilerPath) gets added as the first argument to the FscToolPath fsc.exe__, leading to a compilation error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe "C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\fsc.exe" -o:obj\Debug\netcoreapp2.1\PiastesProject.API.dll
FSC : error FS0226: The file extension of 'C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\fsc.exe' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli. [D:\ESPERIMENTI\PiastesProject.API\src\PiastesProject.API\PiastesProject.API.fsproj]
md5-73dc71d5ce630024df50dcbaf695e276
15:18:22.088 2:6>Target "CoreCompile: (TargetId:133)" in file "C:\Program Files\dotnet\sdk\2.2.104\FSharp\Microsoft.FSharp.Targets" from project "D:\ESPERIMENTI\PiastesProject.API\src\PiastesProject.API\PiastesProject.API.fsproj" (target "Compile" depends on it):
Building target "CoreCompile" completely.
Output file "obj\Debug\netcoreapp2.1\PiastesProject.API.xml" does not exist.
Task "Error" skipped, due to false condition; ('$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0') was evaluated as ('' != '' and '' != 'v5.0').
Task "Warning" skipped, due to false condition; ('$(Win32ResourceFile)' != '' ) was evaluated as ('' != '' ).
Using "Fsc" task from assembly "C:\Program Files\dotnet\sdk\2.2.104\FSharp\FSharp.Build.dll".
Task "Fsc" (TaskId:96)
Task Parameter:DebugSymbols=True (TaskId:96)
Task Parameter:DebugType=full (TaskId:96)
Task Parameter:
DefineConstants=
DEBUG
TRACE
DEBUG
NETCOREAPP
NETCOREAPP2_1 (TaskId:96)
Task Parameter:DisabledWarnings=1178;NU1603;NU1604;NU1605;NU1608 (TaskId:96)
Task Parameter:DocumentationFile=obj\Debug\netcoreapp2.1\PiastesProject.API.xml (TaskId:96)
Task Parameter:NoFramework=True (TaskId:96)
Task Parameter:Optimize=False (TaskId:96)
Task Parameter:OtherFlags= --warnon:1182 --mlcompatibility --simpleresolution --nocopyfsharpcore (TaskId:96)
Task Parameter:OutputAssembly=obj\Debug\netcoreapp2.1\PiastesProject.API.dll (TaskId:96)
Task Parameter:Prefer32Bit=False (TaskId:96)
Task Parameter:
References=
<list of assembly references>
Task Parameter:
Resources=
<list of resource files>
Task Parameter:
Sources=
<list of source files>
Task Parameter:Tailcalls=False (TaskId:96)
Task Parameter:TargetType=Exe (TaskId:96)
Task Parameter:TargetProfile=netcore (TaskId:96)
Task Parameter:ToolExe=fsc.exe (TaskId:96)
Task Parameter:ToolPath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp (TaskId:96)
Task Parameter:TreatWarningsAsErrors=False (TaskId:96)
Task Parameter:UseStandardResourceNames=True (TaskId:96)
Task Parameter:WarningLevel=5 (TaskId:96)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe -o:obj\Debug\netcoreapp2.1\PiastesProject.API.dll
-g
--debug:full
--noframework
--define:DEBUG
--define:TRACE
--define:DEBUG
--define:NETCOREAPP
--define:NETCOREAPP2_1
--doc:obj\Debug\netcoreapp2.1\PiastesProject.API.xml
--optimize-
--tailcalls-
<rest of the command line arguments>
md5-7c98f542724d34dc2ada808e8cbb74c1
12:58:16.975 3:6>Target "CoreCompile: (TargetId:144)" in file "C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\Microsoft.FSharp.Targets" from project "D:\ESPERIMENTI\PiastesProject.API\src\PiastesProject.API\PiastesProject.API.fsproj" (target "Compile" depends on it):
Building target "CoreCompile" completely.
Input file "D:\ESPERIMENTI\PiastesProject.API\src\PiastesProject.API.Client\bin\Debug\netstandard2.0\PiastesProject.API.Client.dll" is newer than output file "obj\Debug\netcoreapp2.1\PiastesProject.API.xml".
Task "Error" skipped, due to false condition; ('$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0') was evaluated as ('' != '' and '' != 'v5.0').
Task "Warning" skipped, due to false condition; ('$(Win32ResourceFile)' != '' ) was evaluated as ('' != '' ).
Using "Fsc" task from assembly "C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\FSharp.Build.dll".
Task "Fsc" (TaskId:106)
Task Parameter:DebugSymbols=True (TaskId:106)
Task Parameter:DebugType=full (TaskId:106)
Task Parameter:
DefineConstants=
DEBUG
TRACE
DEBUG
NETCOREAPP
NETCOREAPP2_1 (TaskId:106)
Task Parameter:DisabledWarnings=1178;NU1603;NU1604;NU1605;NU1608 (TaskId:106)
Task Parameter:DocumentationFile=obj\Debug\netcoreapp2.1\PiastesProject.API.xml (TaskId:106)
Task Parameter:DotnetFscCompilerPath="C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\fsc.exe" (TaskId:106)
Task Parameter:NoFramework=True (TaskId:106)
Task Parameter:Optimize=False (TaskId:106)
Task Parameter:OtherFlags= --warnon:1182 --mlcompatibility --simpleresolution (TaskId:106)
Task Parameter:OutputAssembly=obj\Debug\netcoreapp2.1\PiastesProject.API.dll (TaskId:106)
Task Parameter:Prefer32Bit=False (TaskId:106)
Task Parameter:
References=
<list of assembly references>
Task Parameter:
Resources=
<list of resource files>
Task Parameter:
Sources=
<list of source files>
Task Parameter:Tailcalls=False (TaskId:106)
Task Parameter:TargetType=Exe (TaskId:106)
Task Parameter:TargetProfile=netcore (TaskId:106)
Task Parameter:ToolExe=fsc.exe (TaskId:106)
Task Parameter:ToolPath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp (TaskId:106)
Task Parameter:TreatWarningsAsErrors=False (TaskId:106)
Task Parameter:UseStandardResourceNames=True (TaskId:106)
Task Parameter:WarningLevel=5 (TaskId:106)
Task Parameter:WarningsAsErrors=3239; (TaskId:106)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe "C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\FSharp\fsc.exe" -o:obj\Debug\netcoreapp2.1\PiastesProject.API.dll
-g
--debug:full
--noframework
--define:DEBUG
--define:TRACE
--define:DEBUG
--define:NETCOREAPP
--define:NETCOREAPP2_1
--doc:obj\Debug\netcoreapp2.1\PiastesProject.API.xml
--optimize-
--tailcalls-
<rest of the command line arguments>
I would guess that this line is the culprit maybe? I'm really not familiar with the workings of the compiler but that variable only appears in a very few spots.
Git blame says it's an old line, but as we can see from the above outputs, in the 2.2 SDK the DotnetFscCompilerPath parameter was null or empty, so the linked line did nothing.
In order to use those variables on the dotnet sdk, you need to set this variable:
What is happening is that you are running afoul of this: here
there is a dotnet host, so it thinks it needs to set DotnetCompilerPath to point to the coreclr version of the compiler. However, because you have already set FscToolPath to point to the desktop compiler it doesn't do the right thing and set FscToolPath to dotnet.exe.
So either add this to your project file:
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
or much better, stop using the work around, I believe all the reasons for using it have already been fixed.
If your project doesn't work without the workaround, raise a bug and we should address that.
Thanks
Kevin
Thanks @KevinRansom for the assistance.
If anybody stumbles on this issue: to restore the workaround, I had to also 'wipe' the DotNetFscToolPath in addition to setting that flag:
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
<DotNetFscToolPath></DotNetFscToolPath>
Removing the workaround altogether didn't work for me; it's possible that I could make it work by fiddling with the design-time dependencies (I'm using SQLProvider with multiple database vendors, which is kind of a nightmare scenario), but I'd rather put in the effort on refactoring SQLProvider into a more up-to-date layout.
@piaste, yes that is correct.
I encountered the same problem with .NET Core 2.2.203, which was only fixed by adding the following to my fsproj:
<PropertyGroup>
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
<DotnetFscCompilerPath></DotnetFscCompilerPath>
</PropertyGroup>
Sounds like I am in a similar situation with @piaste - removing the workaround causes SQLProvider to fail to compile, so I don't have much choice.
Just had the same issue, on Linux with .NET Core 2.2.203
But for me setting only
<DotnetFscCompilerPath></DotnetFscCompilerPath>
was enough.
https://github.com/dam5s/somanyfeeds.fs/commit/af8ee29dec7ddbf9561e790b849da6129c778b0b
Hey @piaste could I see more of the part of your code that contains the Property groups containing paths for compiler for Mac and Linux OS? I'm very new to the fsharp stuck due to not able to figure out the path to be set for my linux machine.
@avminus you shouldn't need to do that in most cases (if any). What issue are you having?
Most helpful comment
Just had the same issue, on Linux with .NET Core 2.2.203
But for me setting only
was enough.
https://github.com/dam5s/somanyfeeds.fs/commit/af8ee29dec7ddbf9561e790b849da6129c778b0b