title: dotnet watch run in container with multi-project solution
body: <p>I'm trying to create a Dockerfile along with a docker-compose.yml file to run <code>dotnet watch run</code> on a multi project ASP.Net Core solution. The goal is to have a container watching for changes in all of the three projects.</p>
  
  <p>My solution structure is this:</p>
  
  <pre><code>Nc.Application
  Nc.Domain
  Nc.Infrastructure
  docker-compose.yml
  </code></pre>
  
  <p><code>Nc.Application</code> contains the main project to run, and the other two folders are .Net standard projects referenced by the main project. Inside <code>Nc.Application</code> i have a folder, <code>Docker</code>, with my dockerfile.</p>
  
  <pre><code>Controllers
  Docker
    Development.Dockerfile
  Properties
  Program.cs
  Startup.cs
  ...
  </code></pre>
  
  <p>My Dockerfile and compose file contains the following:</p>
  
  <p><strong>Development.Dockerfile</strong></p>
  
  <pre><code>FROM microsoft/dotnet:2.1-sdk AS build
  ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3'
  
  services:
  
    nc.api:
      container_name: ncapi_dev
      image: ncapi:dev
      build:
        context: ./Nc.Application
        dockerfile: Docker/Development.Dockerfile
      volumes:
        - ncapi.volume:.
      ports:
        - "5000:5000"
        - "5001:5001"
  
  volumes:
    ncapi.volume:
  </code></pre>
  
  <p>When i try to run <code>docker-compose up</code> i get the following error:</p>
  
  <pre><code>ERROR: for f6d811109779_ncapi_dev  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path
  must be absolute
  
  ERROR: for nc.api  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path must be absolute
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  
  <p>I don't know what the path for the volume should be, as the idea is to create 
  a container not directly containing files, but watching files in a folder on my system.</p>
  
  <p>Does anyone have any suggestions as to how to go about this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I updated <code>WORKDIR</code> in Dockerfile to <code>/app/Nc.Application</code>, updated the volume path to be <code>./:/app</code> and removed the named volume <code>volumes: ncapi.volume</code>. However, i now receive the following error:</p>
  
  <pre><code>ncapi_dev | watch : Polling file watcher is enabled
  ncapi_dev | watch : Started
  ncapi_dev | /usr/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/app/Nc.Application/c:/Users/Christian/Documents/source/nc/Nc.Application/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Nc.Application/Nc.Application.csproj]
  ncapi_dev |
  ncapi_dev | The build failed. Please fix the build errors and run again.
  ncapi_dev | watch : Exited with error code 1
  ncapi_dev | watch : Waiting for a file to change before restarting dotnet...
  </code></pre>