CDKTF C# how to include providers that do not have a pre-built provider - namespace confusion

273 Views Asked by At

I am new to C# and I've been able to build out an application for a client using the pre-built providers for CDKTF and Azure. My question is when there is not a pre-built provider, how do I include the bindings in my code? I see that with typescript it's as simple as import { YourProvider } from './gen/providers/<yourprovider>/provider'; (referenced from here).

The problem is that in C#, it's not so straightforward it seems. I have been searching for the answer but haven't found anything yet. I think that it might be such a basic question that it's difficult to find someone asking the question, or I don't know the proper terminology to be able to find it. I also tried ChatGPT but it's explanations weren't on point (implying the issue is my lack of understanding/proper vocabulary)

I see that the provider exists at .gen/azuredevops/azuredevops/Provider/AzuredevopsProvider.cs and it has a namespace of azuredevops.Provider but when I try to do

using azuredevops.Provider

it can't find it. Does this have something to do with the .csproj file?

Any help in understanding how to include this would be appreciated.

1

There are 1 best solutions below

3
On BEST ANSWER

You need to add a reference to your .csproj file, e.g.:

<ItemGroup>
    <ProjectReference Include=".gen\azuredevops\azuredevops.csproj" />
</ItemGroup>

See this example for reference.