pulumi / pulumi-dotnet

.NET support for Pulumi
Apache License 2.0
27 stars 25 forks source link

Unable to use Automation API to install a version of Pulumi #392

Closed JasonWhall closed 4 days ago

JasonWhall commented 1 week ago

What happened?

When using the Automation API to install a version of Pulumi, we're currently seeing an error occuring when running the install command to install the Pulumi cli.

Unhandled exception. System.FormatException: Empty string is not a valid version.
   at Semver.SemVersion.Parse(String version, SemVersionStyles style, Int32 maxLength)
   at Pulumi.Automation.PulumiSdkVersionAttribute..ctor(String value)
   at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at Pulumi.Automation.Commands.LocalPulumiCommand.Install(LocalPulumiCommandOptions options, CancellationToken cancellationToken)

Example

Given the following Pulumi program

using Pulumi.Automation.Commands;

await LocalPulumiCommand.Install(new LocalPulumiCommandOptions
{
    Version = new Semver.SemVersion(3, 129, 0),
    Root = "./"
});

Running dotnet run returns the above exception. I would expect this to install version 3.129.0 of the Pulumi cli.

Output of pulumi about

N/A

Additional context

I believe this is because the published binaries do not include an expected Assembly Attribute.

https://github.com/pulumi/pulumi-dotnet/pull/226 introduced a required Assembly Attributed called PulumiSdkVersion which is obtained during build from the go.mod in the project. However this was only added to the build target and not the publish. Publish runs it's own build step but excludes the required property to set the attribute value - https://github.com/pulumi/pulumi-dotnet/blob/e105d3278fea40be1f3008e36642756b0085e981/build/Publish.fs#L38

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).

justinvp commented 5 days ago

Thanks for the issue and PR!

pulumi-bot commented 4 days ago

This issue has been addressed in PR #393 and shipped in release v3.69.0.