microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
173 stars 26 forks source link

Set multiple docker compose overrides with solution configuration #365

Closed tomfanara closed 1 year ago

tomfanara commented 1 year ago

I want to create 2-3 docker compose overrides as in

Dev, QA and Test. I would like to add these as Visual Studio Profile Configurations as in Debug or Release but add Dev, QA and Test and have VS switch out my overrides accordingly.

I followed a prior post in stackoverflow Setup multiple docker-compose envs in Visual Studio but it does not seem to recognize my PropertyGroup Condition="'$(Configuration)' == 'Dev'"

Any help appreciated!

NCarlsonMSFT commented 1 year ago

In which project is the configuration not being recognized?

Have you confirmed in the solution configuration manger that the configuration is being applied to that project (a solution configuration can apply different project configurations to different projects)? To open the UI and check: image Which opens: image This will show you a list of the individual project configurations being used for each solution configuration.

tomfanara commented 1 year ago

Hello thanks see below

image

The below is my docker-compose.dcproj file

image

below is my docker folder setup

image

tomfanara commented 1 year ago

Its not recognizing the Dev configuration

tomfanara commented 1 year ago

updated docker-compose.dcproj

image

tomfanara commented 1 year ago

Hello this fixed it for me!

https://stackoverflow.com/questions/72852490/current-solution-contains-incorrect-configuration-mappings

NCarlsonMSFT commented 1 year ago

Glad you were able to get unblocked! One comment as long as I've read your .dcproj: if you name your compose files: docker-compose.dev.yml and docker-compose.dev.override.yml then you can just set DockerComposeBaseFilePath to docker-compose.dev, no need for AdditionalComposeFilePaths.

You also don't need to set any property in the second PropertyGroup that has the same value as the first PropertyGroup, it doesn't hurt anything, but you don't need to maintain two copies.

dbreshears commented 1 year ago

Closed, since this appears to be fixed for you.