X
Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.
Discussing a small limitation found in Docker projects in Visual Studio and ClearPeople's solution to it

Working in a new demo project called “CMCDSample”, with Visual Studio 2017, I have found a small limitation in “Docker” projects (“docker-compose”) in VS2017, and below I document both the limitation and its solution. 


Limitation of original “docker-compose” projects in VS217 


When VS2017 builds (or runs with F5) an original “docker-compose” project of VS2017, it checks if the selected configuration is “Debug”, in which case it searches for a file, inside the project, called “docker-compose.vs.debug.yml” to use it in the build process. If the actual configuration it is not called literally “Debug”, then VS2017 assumes that it is a “Release” and tries to use (if exists), the file “docker-compose.vs.release.yml”. 

 

The project “CMCDSample” shows how to manage two Sitecore servers with different roles (“Content Delivery” and “Content Manager”) inside a development environment. This solution of Visual Studio needs a configuration for each role server of Sitecore. At the same time, each one of those roles needs a “Debug” and “Release” version. In conclusion, we need the following configurations: 

  • DebugCD 
  • DebugCM 
  • ReleaseCD 
  • ReleaseCM 

The behaviour of VS2017 previously described conflicts with the needed of having several configurations of “Debug” for the different roles of the Sitecore server. The logic applied to the build process, makes the configurations “DebugCD” and “DebugCM” build like if they were “Release”, disabling all the functionality needed in a development environment to debug the code. 


Solution

 

Fortunately, there is an easy fix that allow us to indicate for each custom configuration, if the build logic “Debug” or “Release” must be applied.

The steps detailed below describe how to fix it:

  1. Open the VS2017 solution that contains the project “docker-compose” with custom configurations.
  2. In the “Solution Explorer” panel, right-click on the project “docker-compose” and select “Unload Project”. The project will show up in the “Solution Explorer” panel as “docker-compose (unavailable)”
  3. Again, in the “Solution Explorer” panel, right-click on the project “docker-compose (unavailable)” and select “Edit docker-compose.dcproj”. The file “docker-compose.dcproj” will open in VS2017.
  4. Inside the file “docker-compose.dcproj” search the element <PropertyGroup Label=”Globals”> and then from its last label (</PropertyGroup>) add the following element “PropertyGroup”:
    <PropertyGroup Label=”Custom”> 
    <DockerDevelopmentMode Condition=” ‘$(Configuration)’ == ‘DebugCD‘ 
    “>Fast</DockerDevelopmentMode> 
    <DockerDevelopmentMode Condition=” ‘$(Configuration)’ == ‘DebugCM‘ 
    “>Fast</DockerDevelopmentMode> 
    <DockerDevelopmentMode Condition=” ‘$(Configuration)’ == ‘ReleaseCD‘ 
    “>Regular</DockerDevelopmentMode> 
    <DockerDevelopmentMode Condition=” ‘$(Configuration)’ == ‘ReleaseCM‘ 
    “>Regular</DockerDevelopmentMode> 
    </PropertyGroup>
  5. Note that there is a sub-element “DockerDevelopmentMode” for each configuration of the solution. The names used in the attribute “Condition” must match each configuration. There must be an element “DockerDevelopmentMode” for each configuration of the solution.
  6. The values of the nodes “DockerDevelopmentMode” indicate how each configuration must be treated:
    1. Fast: Debug
    2. Regular:Release
  7. Once modified, the file “docker-compose.dcproj” must be saved and  closed in VS2017.
  8. Finally, in the “Solution Explorer” panel, right-click on the project “docker-compose (unavailable) and select “Reload Project”. 

My previous blogs about Sitecore and Docker can be found here and here.

 

Hope this can help someone else. If yes, please let me know by leaving a comment. Thanks! 

Author bio

Benjamin Moles
Benjamin Moles
.NET Developer
I'm a passionate .NET and SQL developer. I've worked with a broad variety of technologies and I am currently contributing to the success of ClearPeople's Sitecore projects. Beside IT stuff, I love to spend time with family and play with remote-controlled helicopters.

Comments


comments powered by Disqus

Related Articles

Sign up to our Newsletter

Every now and then, we'd like to send you information that delivers, develops and promotes our products and services that are relevant to you. Submitting your details tells us that you're OK with this and you also agree to our Privacy & Cookies policy. You can, of course, opt out of these communications at any time.