aspire
aspire copied to clipboard
Update `WithArgs` to accept object array
I'd like to be able to do the following
builder
.AddExecutable(...)
.WithEndpoint(name: "endpoint")
.WithArgs("-p", builder.Resource.GetEndpoint("endpoint").Property(EndpointProperty.Port));
But this doesn't work as the WithArgs
callback only accepts string array params - https://github.com/dotnet/aspire/blob/d4acce5704b8f086cd38c2e29b2766669d8a1277/src/Aspire.Hosting/ResourceBuilderExtensions.cs#L162-L165
For now, can work around this with the callback overload that does accept objects
return builder
.AddExecutable(...)
.WithArgs(context =>{
context.Args.Add("-p");
context.Args.Add(builder.Resource.GetEndpoint(endpointName).Property(EndpointProperty.TargetPort));
});