pulumi / pulumi-dotnet

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

ImportAsync requires dotnet build to run #323

Open JasonWhall opened 3 weeks ago

JasonWhall commented 3 weeks ago

What happened?

When using the WorkspaceStack.ImportAsync Method, it currently requires building a .NET project which may not be available if the running program is an executable. The following error message is returned:

Error Message ``` Importing (SecondStack): pulumi:pulumi:Stack MyProject-SecondStack running 'dotnet build -nologo .' pulumi:pulumi:Stack MyProject-SecondStack MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. pulumi:pulumi:Stack MyProject-SecondStack MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. pulumi:pulumi:Stack MyProject-SecondStack 1 message Diagnostics: pulumi:pulumi:Stack (MyProject-SecondStack): MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. error: failed to discover plugin requirements: 'dotnet build -nologo .' exited with non-zero exit code: 1 Unhandled exception. Pulumi.Automation.Commands.Exceptions.CommandException: code: -1 stdout: Importing (SecondStack): pulumi:pulumi:Stack MyProject-SecondStack running 'dotnet build -nologo .' pulumi:pulumi:Stack MyProject-SecondStack MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. pulumi:pulumi:Stack MyProject-SecondStack MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. pulumi:pulumi:Stack MyProject-SecondStack 1 message Diagnostics: pulumi:pulumi:Stack (MyProject-SecondStack): MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. stderr: error: failed to discover plugin requirements: 'dotnet build -nologo .' exited with non-zero exit code: 1 at Pulumi.Automation.Commands.LocalPulumiCommand.RunAsyncInner(IList`1 args, String workingDir, IDictionary`2 additionalEnv, Action`1 onStandardOutput, Action`1 onStandardError, EventLogFile eventLogFile, CancellationToken cancellationToken) at Pulumi.Automation.Commands.LocalPulumiCommand.RunAsync(IList`1 args, String workingDir, IDictionary`2 additionalEnv, Action`1 onStandardOutput, Action`1 onStandardError, Action`1 onEngineEvent, CancellationToken cancellationToken) at Pulumi.Automation.Workspace.RunStackCommandAsync(String stackName, IList`1 args, Action`1 onStandardOutput, Action`1 onStandardError, Action`1 onEngineEvent, CancellationToken cancellationToken) at Pulumi.Automation.WorkspaceStack.RunCommandAsync(IList`1 args, Action`1 onStandardOutput, Action`1 onStandardError, Action`1 onEngineEvent, CancellationToken cancellationToken) ```

The expectation is that it should not need to build the .NET project if it is being executed through the automation API. Speculation from the error message suggests that to import it needs to discover the plugins to use which is obtained by building the project.

Example

Example to re-produce published here - https://github.com/JasonWhall/pulumi-import-bug-sample

Output of pulumi about

CLI Version 3.129.0 Go Version go1.22.6 Go Compiler gc

Host OS Microsoft Windows 10 Enterprise Version 10.0.19045 Build 19045 Arch x86_64

Backend Name
URL file://~ User
Organizations 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).

justinvp commented 3 weeks ago

Thanks for the repro.