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

OperatorSDK not generating CS files for MSBUILD? #7

Closed
jefflill opened this issue Sep 23, 2023 · 3 comments
Closed

OperatorSDK not generating CS files for MSBUILD? #7

jefflill opened this issue Sep 23, 2023 · 3 comments
Assignees
Labels
analyzer bug Something isn't working

Comments

@jefflill
Copy link
Contributor

It appears that the OperatorSDK is not generating when building using MSBUILD:

C:\src\neonKUBE\Services\neon-cluster-operator\OperatorStartup.cs(91,18): error CS1061: 'IServiceCollection' does not contain a definition for 'AddKubernetesOperator' and no accessible extension method 'AddKubernetesOperator' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) [C:\src\neonKUBE\Services\neon-cluster-operator\neon-cluster-operator.csproj]
C:\src\neonKUBE\Services\neon-cluster-operator\OperatorStartup.cs(105,17): error CS1061: 'IApplicationBuilder' does not contain a definition for 'UseKubernetesOperator' and no accessible extension method 'UseKubernetesOperator' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) [C:\src\neonKUBE\Services\neon-cluster-operator\neon-cluster-operator.csproj]

I've noticed that when I open the NEONCLOUD solution with :\src\neonKUBE\Services\neon-cluster-operator\OperatorStartup.cs open that it takes sometime for the call to UseKubernetesOperator() there turns blue, indicating that the method has been generated and is actually valid. I also notice that the code is generated in a user temp directory and not in a git folder, so we can't rely on source files generated previously in a VS session that gets committed to GitHub.

I wonder if there's a way to have MSBUILD run all analyzers before building?

@jefflill jefflill added bug Something isn't working analyzer labels Sep 23, 2023
@jefflill
Copy link
Contributor Author

jefflill commented Sep 23, 2023

I upgraded the Roslyn nuget analyzer references last week during my Reno vacation so all of the referenced versions would be the same and I was working after that on upgrading 80+ other nuget packages and then working on fixing unit tests, so I didn't actually try rebuilding the NEONKUBE release until yesterday, and then ran into this.

This issue is interesting:

Version mismatch between Roslyn in MSBuild and CodeStyle analyzers in the SDK

TLDR: MSFT has a fundamental conflict between Rosyln compiler and SDK versions that can cause analyzer version dependency versions. Apparently, this wasn't a huge problem in the past when mostly only MSFT was shipping analyzers but is a bigger problem now that other folks are doing this (like us).

MSFT claims to have fixed this (after .NET CORE SDK v17.4?). We're not seeing any version conflicts though, so I'm not sure this is relevant.

@jefflill
Copy link
Contributor Author

I see that there's a compiler warning that I've updated the Roslyn package references to v.4.7.0 where as the current compiler is only at v4.5.0. I'm going to revert our references to v4.5.0 and see what happens.

What's interesting about this is that build script is able to complete the full build but fails when building the container images. The container image builds, build the service csproj files individually (not as part of the solution).

@jefflill
Copy link
Contributor Author

FIXED: downgrading the nugets to v4.5.0 seemed to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants