crd2pulumi
crd2pulumi copied to clipboard
Pulumi version in generated csproj file incorrect
What happened?
Reproducing this issue: https://github.com/pulumi/crd2pulumi/issues/43
In the csproj file, the following is the package reference for the Pulumi SDK:
<PackageReference Include="Pulumi" Version="(3.54.1.0,4)" />
Running dotnet build causes this error:
MSBuild version 17.9.4+90725d08d for .NET
Determining projects to restore...
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : warning NU1604: Project dependency Pulumi (> 3.54.1 && < 4.0.0) does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Warning As Error: Detected package downgrade: Pulumi from 3.55.1 to 3.55.0. Reference the package directly from the project to select a different version.
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Pulumi.Crds -> Pulumi.Kubernetes 3.30.2 -> Pulumi (>= 3.55.1)
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Pulumi.Crds -> Pulumi (> 3.54.1 && < 4.0.0)
Failed to restore /Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj (in 1.24 sec).
Build FAILED.
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : warning NU1604: Project dependency Pulumi (> 3.54.1 && < 4.0.0) does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Warning As Error: Detected package downgrade: Pulumi from 3.55.1 to 3.55.0. Reference the package directly from the project to select a different version.
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Pulumi.Crds -> Pulumi.Kubernetes 3.30.2 -> Pulumi (>= 3.55.1)
/Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/crd-csharp/dotnet/Pulumi.Crds.csproj : error NU1605: Pulumi.Crds -> Pulumi (> 3.54.1 && < 4.0.0)
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.46
Example
To reproduce:
- Create new folder and change to it:
mkdir crdtest && cd cdrtest - Run crd2pulumi pointing at this gist (yaml taken from this comment):
crd2pulumi --dotnetPath dotnet --dotnet https://gist.githubusercontent.com/pierskarsenbarg/707236cbfd649025494aa010d95ffb93/raw/f5adab7fccd3007ecf21d675033a3c257c42b4fb/crd.yaml - Change to
dotnetfolder:cd dotnet - Run
dotnet build(which will produce an error) - Change this line (47?):
<PackageReference Include="Pulumi" Version="(3.54.1.0,4)" />to<PackageReference Include="Pulumi" Version="3.*" />
Output of pulumi about
CLI
Version 3.111.1
Go Version go1.22.1
Go Compiler gc
Host
OS darwin
Version 14.4.1
Arch arm64
Backend
Name pulumi.com
URL https://app.pulumi.com/pierskarsenbarg
User pierskarsenbarg
Organizations pierskarsenbarg, karsenbarg, team-ce, demo
Token type personal
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
I believe we'd need to add Pulumi as another dependency here: https://github.com/pulumi/crd2pulumi/blob/5a4913e091e15051d5bb46673ab0cb2da8f41813/pkg/codegen/dotnet.go#L62-L68