Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint Not Working For .NET Framework Projects #336

Closed
LukeBurgessYeo opened this issue May 16, 2019 · 12 comments · Fixed by #657
Closed

Lint Not Working For .NET Framework Projects #336

LukeBurgessYeo opened this issue May 16, 2019 · 12 comments · Fixed by #657
Labels
Milestone

Comments

@LukeBurgessYeo
Copy link

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

  1. Create a new .NET Framework F# project (e.g. in Visual Studio 2017: file -> new -> project -> Visual F# -> Console Application (.NET Framework))
  2. 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 FSharpLint.Console.Program.startWithArguments@129.Invoke(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
@jgardella jgardella added the bug label May 23, 2019
@milbrandt
Copy link
Contributor

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>

@christoph-feb22
Copy link

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 FSharpLint.Console.Program.startWithArguments@171.Invoke(Argument arg) in C:\projects\fsharplint-231\src\FSharpLint.Console\Program.fs:line 179

@milbrandt
Copy link
Contributor

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)

@lpeixotoo
Copy link

Do we have any workaround for netcoreapp2.2 projects?

@jmhickman
Copy link

jmhickman commented Jun 5, 2020

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?

@abelbraaksma
Copy link
Member

abelbraaksma commented Jun 5, 2020

@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.

@jgardella jgardella added this to the Version 1.0.0 milestone Jun 7, 2020
@jgardella
Copy link
Contributor

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.

@jgardella
Copy link
Contributor

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?

@abelbraaksma
Copy link
Member

abelbraaksma commented Jul 5, 2020

@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:

image

It also appears to go over only a handful of files in the first project before it continues onto the next.

@abelbraaksma
Copy link
Member

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.")"

su8898 added a commit to su8898/proj-info that referenced this issue Dec 21, 2021
This will open the doors to fixing this FSharpLint's bug:
fsprojects/FSharpLint#336

(which is important for our FSharpLint v1.0 release milestone)
su8898 added a commit to su8898/proj-info that referenced this issue Dec 21, 2021
This will open the doors to fixing this FSharpLint's bug:
fsprojects/FSharpLint#336

(which is important for our FSharpLint v1.0 release milestone)
baronfel pushed a commit to ionide/proj-info that referenced this issue Mar 21, 2022
This will open the doors to fixing this FSharpLint's bug:
fsprojects/FSharpLint#336

(which is important for our FSharpLint v1.0 release milestone)
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 12, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 13, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
webwarrior-ws added a commit to webwarrior-ws/FSharpLint that referenced this issue Dec 28, 2023
Upgrade Ionide.ProjInfo package version to 0.58.0.

Fixes fsprojects#336.
knocte added a commit that referenced this issue Jan 8, 2024
* Upgrade Ionide.ProjInfo to 0.58.0 (needed to bring the fix for parsing legacy projects, upstream PR: ionide/proj-info#131 , upstream commit: ionide/proj-info@3542cee ).
* Upgrade FSharp.Compiler.Service to version 41 (needed because the new Ionide.ProjInfo version, depends on a higher version of F.C.S.).
* Made changes to framework, rules and test framework code necessary to accomodate API changes in this version 41.x of FCS compared to version 40.

Fixes #336
@knocte
Copy link
Collaborator

knocte commented Jan 8, 2024

Sorry everyone for taking so long to fix this bug! It was initially fixed in an upstream PR of our ProjInfo dependency: ionide/proj-info#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.

@abelbraaksma
Copy link
Member

Funnily enough, by now I rarely, if ever, use .NET Framework projects anymore 😄. Maybe someone else can test it that still use Framework?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants