-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aspire.Hosting.Testing should populate DOTNET_LAUNCH_PROFILE #5093
Comments
Interested in the outcome of this. I'm looking to feed in some configuration from test host to the underlying Aspire host as we have various options that are controlled via launchProfile environment vars when running the host directly. Being able to set the launch profile (it appears no launch profile is used when using As a workaround we've used the command line args directly and ensured that they've loaded into the ambient configuration in the Aspire host. As long as we use the .Net configuration stuff and not environment variables directly this works in all scenarios. Test project: //xunit IAsyncLifetime
public async Task InitializeAsync()
{
string[] args =
[
"USE_EMULATORS=False",
"USE_USER_SECRETS=True",
"PROVISION_DATABASES_BEFORE_START=False"
];
var builder = await DistributedApplicationTestingBuilder
.CreateAsync<Projects.Membership_Aspire_Host>(args, (options, builderSettings) => { });
AspireHost = await builder.BuildAsync();
await AspireHost.StartAsync();
} Aspire host: //Aspire.AppHost/Program.cs
private static async Task Main(string[] args)
{
var options = new DistributedApplicationOptions() { Args = args }; //Passing args here does not seem to init builder.Configuration
var builder = DistributedApplication.CreateBuilder(options);
builder.Configuration.AddCommandLine(args); //This does work and make the args passed from the text fixture available
...
var useEmulators = builder.Configuration["USE_EMULATORS"] == "True"; |
PR here #7363 |
Reopening since we reverted #7371 (due to unrelated test infra issues) |
When
Aspire.Hosting.Testing
'sDistributedApplicationTestingBuilder
creates and builds a DistributedApplicationBuider, it should pass in theDOTNET_LAUNCH_PROFILE
configuration setting so AppHost code can switch off the launch profile, like documented in https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_launch_profile.We use this in our samples here:
https://github.com/dotnet/aspire-samples/blob/08c14cdc112c74811c44976064b8d85e39e8bd93/samples/AspireWithNode/AspireWithNode.AppHost/Program.cs#L16-L20
But that check doesn't work when running in an Aspire.Hosting.Testing test because that configuration setting isn't being populated by the testing infrastructure.
cc @ReubenBond @mitchdenny @radical
The text was updated successfully, but these errors were encountered: