Skip to content

[bug]: kubeops generate operator fails with FileNotFoundException for Microsoft.CodeAnalysis during CRD generation on .NET 10 #1246

Closed

Description

@ChrisRichner

Describe the bug

kubeops generate operator fails during CRD generation with a System.IO.FileNotFoundException for Microsoft.CodeAnalysis, Version=5.9.0.0.

The project itself compiles successfully. The failure happens inside KubeOps.Cli.Transpilation.AssemblyLoader while KubeOps is generating operator resources.

As a workaround, adding a direct package reference to Microsoft.CodeAnalysis.CSharp to the operator project makes the build succeed.

To reproduce

Project setup:

  • KubeOps.Operator = 13.2.0
  • KubeOps.Operator.Web = 13.2.0
  • local tool kubeops.cli = 13.2.0
  • target framework = net10.0

Operator project contains:

<PropertyGroup>
  <OperatorName>loadtest</OperatorName>
</PropertyGroup>

<PropertyGroup>
  <KubeOpsCli>dotnet tool run kubeops</KubeOpsCli>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="KubeOps.Operator" Version="13.2.0" />
  <PackageReference Include="KubeOps.Operator.Web" Version="13.2.0" />
</ItemGroup>

Run:
dotnet build src/MyOperator/MyOperator.csproj --configuration Release
This triggers the KubeOps MSBuild target from KubeOps.Operator.targets, which runs:
dotnet tool run kubeops generate operator ...

Expected behavior

The operator resources should be generated successfully, including CRDs, without requiring an explicit Roslyn package reference in the operator project.

Actual behavior

Build output includes:
Generate RBAC rules.
Generate Dockerfile.
The operator contains webhooks of some sort, generating webhook operator specific resources.
Generate CA and Server certificates.
Generate Deployment and Service.
Generate Validation Webhooks.
Generate Mutation Webhooks.
Generate CRDs.
Unhandled exception: System.IO.FileNotFoundException: Could not find assembly 'Microsoft.CodeAnalysis, Version=5.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.
   at System.Reflection.TypeLoading.Ecma.EcmaResolver.ResolveAssembly(AssemblyReferenceHandle handle, EcmaModule module)
   ...
   at KubeOps.Cli.Transpilation.AssemblyLoader.<>c.<GetConvertedEntities>b__11_0(TypeInfo t) in /_/src/KubeOps.Cli/Transpilation/AssemblyLoader.cs:line 225
   ...
   at KubeOps.Cli.Generators.CrdGenerator.Generate(ResultOutput output) in /_/src/KubeOps.Cli/Generators/CrdGenerator.cs:line 20

The project DLL is built successfully before this step; the failure only occurs in resource generation.

Workaround

Adding this package reference to the operator project avoids the failure:

After adding it, dotnet build --configuration Release completes successfully and KubeOps writes the generated config output.

Environment

• OS: Linux
• SDK used in CI: .NET 10
• KubeOps.Operator: 13.2.0
• KubeOps.Operator.Web: 13.2.0
• kubeops.cli: 13.2.0

Expected behavior

The operator resources should be generated successfully, including CRDs, without requiring an explicit Roslyn package reference in the operator project.

Screenshots

No response

Additional Context

This looks like a CLI/runtime assembly resolution issue in KubeOps resource generation rather than a project compilation issue, because:
•
the operator project compiles successfully
•
the exception originates in KubeOps.Cli.Transpilation.AssemblyLoader
•
the failure occurs specifically during CRD generation
•
adding a Roslyn package to the consuming project makes the CLI succeed
It would be helpful if KubeOps CLI either:
1.
carried the required Roslyn dependencies itself, or
2.
resolved them in a way that does not require the consuming operator project to add explicit Microsoft.CodeAnalysis references.

Activity

  1. added
    bug
    on Sep 14, 2026
  2. kimpenhaus commented on Sep 14, 2026

    @kimpenhaus
    Collaborator

    Hey @ChrisRichner

    thanks for reporting - that issues should be already fixed with pull request #1237

    You could either use v13.2.1-prerelease.5 or wait until tomorrow when the next stable release will be created.

    Thanks again,
    Marcus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions