yoheimuta / protolint

A pluggable linter and fixer to enforce Protocol Buffer style and conventions.
MIT License
576 stars 52 forks source link

Possible regression - fix implemented in 0.39 is broken in 0.40 and 0.41 #291

Closed jplumhoff closed 2 years ago

jplumhoff commented 2 years ago

A few months back, issue #264 was addressed in 0.39.0, allowing us to lint files in Visual Studio that had a protoroot folder specified. I just tried upgrading to 0.40 and then 0.41. I'm guessing there is some kind of regression... The same csproj file that works perfectly on 0.39 is failing on both 0.40 and 0.41. This is the debug output I get with version 0.40 and 0.41:

PM> dotnet build -v:n
MSBuild version 17.3.2+561848881 for .NET
Build started 10/31/2022 3:19:42 PM.
     1>Project "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET.
     1>C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
     1>C:\gitcode\PS\PS.Domain\PS.Domain.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source. [C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj]
         Assets file has not changed. Skipping assets file writing. Path: C:\gitcode\PS\PS.Domain\obj\project.assets.json
         Assets file has not changed. Skipping assets file writing. Path: C:\gitcode\PS\PS.ProtobufClassLibrary\obj\project.assets.json
         Restored C:\gitcode\PS\PS.Domain\PS.Domain.csproj (in 49 ms).
         Restored C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj (in 49 ms).

         NuGet Config files used:
             C:\Users\jplumhoff\AppData\Roaming\NuGet\NuGet.Config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

         Feeds used:
             https://nuget.telerik.com/nuget
             https://api.nuget.org/v3/index.json
             http://my.nuget.source.com
             C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
             C:\Program Files\dotnet\library-packs
         All projects are up-to-date for restore.
     1>Done Building Project "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (Restore target(s)).
   1:7>Project "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" on node 1 (default targets).
     1>C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
   1:7>Project "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (1:7) is building "C:\gitcode\PS\PS.Domain\PS.Domain.csproj" (2:6) on node 1 (default targets).
     2>C:\gitcode\PS\PS.Domain\PS.Domain.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
     2>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreGenerateAssemblyInfo:
       Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
       CoreCompile:
       Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
       GenerateBuildDependencyFile:
       Skipping target "GenerateBuildDependencyFile" because all output files are up-to-date with respect to the input files.
       CopyFilesToOutputDirectory:
         PS.Domain -> C:\gitcode\PS\PS.Domain\bin\Debug\net6.0\PS.Domain.dll
     2>Done Building Project "C:\gitcode\PS\PS.Domain\PS.Domain.csproj" (default targets).
     1>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       _Protobuf_CoreCompile:
         C:\Users\jplumhoff\.nuget\packages\grpc.tools\2.46.1\tools\windows_x64\protoc.exe --csharp_out=obj\Debug\net6.0\com\my_company\protobuf\common\entity --plugin=protoc-gen-grpc=C:\Users\jplumhoff\.nuget\packages\grpc.tools\2.46.1\tools\windows_x64\grpc_csharp_plugin.exe --grpc_out=obj\Debug\net6.0\com\my_company\protobuf\common\entity --proto_path=C:\Users\jplumhoff\.nuget\packages\grpc.tools\2.46.1\build\native\include --proto_path=protos --dependency_out=obj\Debug\net6.0\7fbd8785a2007adb_product.protodep --error_format=msvs --protolint_out=. --protolint_opt=proto_root=protos protos\com\my_company\protobuf\common\entity\product.proto
         'protoc-gen-protolint' is not recognized as an internal or external command,
         operable program or batch file.
     1>--protolint_out : error : protoc-gen-protolint: Plugin failed with status code 1. [C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj]
     1>Done Building Project "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (default targets) -- FAILED.

Build FAILED.

       "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (Restore target) (1) ->
       (Restore target) -> 
         C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
         C:\gitcode\PS\PS.Domain\PS.Domain.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source. [C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj]

       "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (default target) (1:7) ->
       (ResolvePackageAssets target) -> 
         C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.

       "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (default target) (1:7) ->
       "C:\gitcode\PS\PS.Domain\PS.Domain.csproj" (default target) (2:6) ->
         C:\gitcode\PS\PS.Domain\PS.Domain.csproj : warning NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://my.nuget.source.com'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.

       "C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj" (default target) (1:7) ->
       (_Protobuf_CoreCompile target) -> 
         --protolint_out : error : protoc-gen-protolint: Plugin failed with status code 1. [C:\gitcode\PS\PS.ProtobufClassLibrary\PS.ProtobufClassLibrary.csproj]

    4 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.09

This is my csproj file:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
        <Protobuf Include="protos/**/*.proto" 
                  AdditionalProtocArguments="--protolint_out=.;--protolint_opt=proto_root=protos" 
                  ProtoRoot="protos"  />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Grpc.AspNetCore" Version="2.46.0" />
    </ItemGroup>
    <ItemGroup>
        <ProjectReference Include="..\PS.Domain\PS.Domain.csproj" />
    </ItemGroup>

</Project>
yoheimuta commented 2 years ago

@jplumhoff Thank you for reaching out.

As I looked over your error message, I suspected the following message as a root cause.

         'protoc-gen-protolint' is not recognized as an internal or external command,
         operable program or batch file.

This error is common when you don't put a binary in the appropriate path. Did your latest protoc-gen-protolint put in the same place as before?

jplumhoff commented 2 years ago

I apologize for wasting your time with something so trivial! I really should have seen that error...

I was switching between versions by changing my PATH variable. Apparently I had v0.39.0 in a folder like "protolint 0.39.0", while the other versions had an underscore like "protolint_0.41.0". When I'd update my path, I missed the underscore. Once I used the correct paths, the problem was resolved. Both 0.40.0 and 0.41.0 work perfectly.

yoheimuta commented 2 years ago

Good to hear that. No biggie 😸