Base solution for your next web application
Open Closed

*.Migrator project - provide environment flag at run time #9165


User avatar
0
sneddo created

I am building the project in release mode. when I run it I want to be able to specify which environment to run against. What is the best way to achieve this?

Im not sure where the project pick up the current environment, perhaps within the AbpBootstrapper.Create method?

Guidance welcome. Ideally I will just pass an argument to the programe, environment or something like that.


2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    The framework is using net core environment. Web and console projects. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1

    Can you explain your use case in detail?

  • User Avatar
    0
    sneddo created

    I found the issue in the end.

    I am setting the env before starting the app, the issue I had was the migrator app never picked up the connection string from my appsettings.{environment}.json file.

    I had to make a small modification to the {Application}MigratorModule.

    In the constructor I added: string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

    and amended the call to AppConfigurations.Get to include the environment as per above as the second parameter.

    Once this was done the migrator app would use the appsettings files I was expecting / wanting it to use.