Search code examples
docker.net-corevisual-studio-2022

Adding Docker Support - "solution file must be located in the same folder or a higher folder..."


I'm investigating adding Docker support to two of our applications that we just retargeted to .NET 6 to investigate the possibility of ephemeral environments. I ran into the following exception when trying to add Docker support in VS2022:

An error occurred while adding Docker File support to this project.

In order to add Docker support, the solution file (.sln) must be located in the same folder or a higher folder than the target project file and all referenced project files (.csproj, .vbproj).

I know the project that is causing the issue - it is a project called "MyCompany.FeatureManagement" that contains feature flags used across our codebase in various solutions. It exists in a common folder in Git in a different part of the directory tree than the solution I'm trying to put in Docker. I have two questions:

  • Is having a common feature file assembly considered an anti-pattern in general, or is it a common/semi-common that is just not compatible with Docker?
  • If I want to make this solution Docker File compatible does it make more sense to add the necessary feature file logic within this solution specifically and break the dependency on the shared assembly and its appsettings files, or would it make more sense to share that project as an internal NuGet package?

Longer term we are investigating Launch Darkly to standardize our feature flag usage across the codebase so the point becomes hopefully moot, but I'm looking for an interim solution.


Solution

  • I faced the same issue. I had two project (prj1 and prj2) in my solution. My mistake was that my sln file was in prj1 folder. I carried my sln file and edit it (with notepad or somethingelse) and it worked. Editing is must because sln can't find your project. example:

        Microsoft Visual Studio Solution File, Format Version 12.00
        # Visual Studio Version 17
        VisualStudioVersion = 17.5.33627.172
        MinimumVisualStudioVersion = 10.0.40219.1
        Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prj1", "prj1\prj1.csproj", "{9D840551-911E-4E07-9C46-6B37E4A3C19C}"
        EndProject
        Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prj2", "prj2\prj2.csproj", "{CDF29B88-1C83-4B05-BE11-45EFCBA1F68B}"
        EndProject