FSharpLint
FSharpLint copied to clipboard
Lint Not Working For .NET Framework Projects
Description
Linting a .NET Framework project throws an error:
Lint failed while analysing project C:\Users\luke\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.fsproj.
Failed with: error getting msbuild info: internal error, more info returned than expected MSBuildFailed
Repro steps
- Create a new .NET Framework F# project (e.g. in Visual Studio 2017: file -> new -> project -> Visual F# -> Console Application (.NET Framework))
- Run fsharplint against the newly created project, e.g:
> dotnet fsharplint -f "C:\Users\luke\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.fsproj"
Expected behavior
Lint should run successfully, as is the case when repeating the above steps but creating a .NET Core project instead:
> dotnet fsharplint -f "C:\Users\luke\source\repos\ConsoleApp1\ConsoleApp1\ConsoleApp1.fsproj"
========== Linting C:\Users\luke\source\repos\ConsoleApp1\ConsoleApp1\obj\Debug\netcoreapp2.1\ConsoleApp1.AssemblyInfo.fs ==========
========== Finished: 0 warnings ==========
========== Linting C:\Users\luke\source\repos\ConsoleApp1\ConsoleApp1\Program.fs ==========
========== Finished: 0 warnings ==========
========== Summary: 0 warnings ==========
Actual behavior
The following error is displayed:
Lint failed while analysing project C:\Users\luke\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.fsproj.
Failed with: error getting msbuild info: internal error, more info returned than expected MSBuildFailed
(1,
("C:\Users\luke\source\repos\ConsoleApplication1\ConsoleApplication1",
"dotnet",
"msbuild C:\Users\luke\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.fsproj /p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true /p:CopyBuildOutputToOutputDirectory=false /p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs /p:_Inspect_FscArgs_OutFile=C:\Users\luke\AppData\Local\Temp\tmpCDE5.tmp.FscArgs.txt /p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences /p:_Inspect_GetResolvedProjectReferences_OutFile=C:\Users\luke\AppData\Local\Temp\tmpCDE6.tmp.GetResolvedProjectReferences.txt /p:CustomAfterMicrosoftCommonTargets=C:\Users\luke\AppData\Local\Temp\tmpCDE7.tmp.proj-info.hook.targets /p:CustomAfterMicrosoftCommonCrossTargetingTargets=C:\Users\luke\AppData\Local\Temp\tmpCDE7.tmp.proj-info.hook.targets /nologo /verbosity:quiet"))
Stack trace: at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1645.Invoke(String message)
at FSharpLint.Application.Lint.lintProject(OptionalLintParameters optionalParams, String projectFilePath) in C:\projects\fsharplint-231\src\FSharpLint.Core\Application\Lint.fs:line 470
at [email protected](Argument arg) in C:\projects\fsharplint-231\src\FSharpLint.Console\Program.fs:line 130
Known workarounds
Using .NET Core instead of .NET Framework.
Related information
- Windows 10
- .NET Framework v4.5.2
The same issue seems to apply on netstandard2.0
projects using dotnet 2.2.107:
Lint failed while analysing project D:\_2\8\s\source\MyProject\MyProject.fsproj.
Failed with: error getting msbuild info: internal error, more info returned than expected MSBuildFailed
(1,
("D:\_2\8\s\source\MyProject", "dotnet",
with project file starting
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProjectGuid>{D5352B43-C4CA-47E4-BD10-0D51629BDC22}</ProjectGuid>
Same here for netcoreapp2.2
project using dotnet 2.2.301
Lint failed while analysing project src/Server/Server.fsproj.
Failed with: error getting msbuild info: internal error, more info returned than expected MSBuildFailed
(1,
("src/Server", "dotnet",
"msbuild src/Server/Server.fsproj /p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true /p:CopyBuildOutputToOutputDirectory=false /p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs /p:_Inspect_FscArgs_OutFile=/var/folders/1s/xcd08g7x06z1glmqw3d922lr0000gn/T/tmpIqi1vr.tmp.FscArgs.txt /p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences /p:_Inspect_GetResolvedProjectReferences_OutFile=/var/folders/1s/xcd08g7x06z1glmqw3d922lr0000gn/T/tmpdTBy1K.tmp.GetResolvedProjectReferences.txt /p:CustomAfterMicrosoftCommonTargets=/var/folders/1s/xcd08g7x06z1glmqw3d922lr0000gn/T/tmphRJyYW.tmp.proj-info.hook.targets /p:CustomAfterMicrosoftCommonCrossTargetingTargets=/var/folders/1s/xcd08g7x06z1glmqw3d922lr0000gn/T/tmphRJyYW.tmp.proj-info.hook.targets /nologo /verbosity:quiet"))
Stack trace: at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1647.Invoke(String message)
at FSharpLint.Application.Lint.lintProject(OptionalLintParameters optionalParams, String projectFilePath) in C:\projects\fsharplint-231\src\FSharpLint.Core\Application\Lint.fs:line 547
at [email protected](Argument arg) in C:\projects\fsharplint-231\src\FSharpLint.Console\Program.fs:line 179
Would be good to have it fixed on dotnet 2.2.1xx series which is compatible with VisualStudio 2017 (in contract to 2.2.3XX)
Do we have any workaround for netcoreapp2.2
projects?
Came here searching for a solution to this. Wanted to find ways to improve my code because I'm still learning, and I guess I can't because it's a Framework project? Should I have inferred from the use of the dotnet
tool that this is for Core projects only?
Edit: If this linter won't work, is there a specific source list of the things it's looking for somewhere?
@jmhickman, it used to work, in fact, there was even a VS extension before Core projects even existed. But that project wasn't ported to newer VS versions (but the command line version still worked). Now there's apparently a bug that stops us from using it with the classic project style.
Linter is great, it would be awesome to be able to enable it again for all my F# projects.
I've added this to the v1 release milestone. I believe the issue is with our usage of dotnet-projinfo to get the source files from the project and the project options to use when parsing those files.
But I think the linter should still work for the old project format; as the recommended way to run the linter is as a dotnet tool, I suppose you would need to have .NET core installed, but should still be able to run it against your old-style projects. Possibly the work done to support multi-targeted projects in #435 would also relate to this.
I believe this should be fixed with #442. @abelbraaksma or @jmhickman could you try running version 0.16.1 on some of your projects and see if it works?
@jgardella, it definitely works better now! Running it on a sln
file, part of the projects work correctly, until it errors out with
"Invalid URI: The format of the URI could not be determined."
The good part shows this though, which is pretty nice:
It also appears to go over only a handful of files in the first project before it continues onto the next.
I tried a dozen or so other projects and almost all give me:
MSBuild could not load the project file D:\Path\To\Projects\Tests.Common.fsproj because: InvalidProjectFileMessage
"GenericError
("D:\Path\To\Projects\Tests.Common.fsproj",
"Invalid URI: The format of the URI could not be determined.")"
Sorry everyone for taking so long to fix this bug! It was initially fixed in an upstream PR of our ProjInfo dependency: https://github.com/ionide/proj-info/pull/131 but then adopting that was not easy because it required us to upgrade FCS. Thank @su8898 for his ProjInfo fix and @webwarrior-ws for upgrading FCS. And if you want to test this, you can already grab a pre-release from nuget: https://www.nuget.org/packages/dotnet-fsharplint/0.23.7--date20240108-0751.git-6636fb2
Any feedback appreciated.
Funnily enough, by now I rarely, if ever, use .NET Framework projects anymore 😄. Maybe someone else can test it that still use Framework?