sdk icon indicating copy to clipboard operation
sdk copied to clipboard

.NET Core From Windows Volume and Running in Docker

Open cbeall opened this issue 9 years ago • 1 comments

I'm not sure if this is the correct place to ask this question, but for the last nine months or so, I've been using Visual Studio to work on my project.json based web applications running in Docker.

My Dockerfile adds all required packages to my NuGet Packages folder, but instead of copying the code to image, I mount the volume with the code on my windows drive. This has allowed me work with Visual Studio to write code, but also leverage dotnet watch so that as soon as I save a file, the application in my docker container restarts and has my changes. My Dockerfile would work as follows (/app being the mounted directory).

FROM microsoft/dotnet:1.1.0-sdk-projectjson

ENV DOTNET_USE_POLLING_FILE_WATCHER 1

# Preloads the packages
COPY ./src/myapp/project.json /tmp/project.json
WORKDIR /tmp
RUN dotnet restore

RUN mkdir /app
WORKDIR /app

ENTRYPOINT dotnet watch run

I've had a lot of success with this approach. What allowed this to work is that the project.lock.json didn't care if it was running in Docker or Windows. Now that I'm trying to migrate to use csproj with MSBuild, I'm unable to make this work. When I run dotnet restore, instead of a project.lock.json, there are two files created

  • obj\myapp.csproj.nuget.g.props.
  • obj\project.assets.json

Both of these files contain with absolute paths. Depending on if I run the restore on docker or windows, the values of those paths change. This prevents me from being able to run files in docker and use Visual Studio at the same time. If running in windows, the docker container will not start. If the docker container is running, Visual Studio gives me a who mess of "The type or namespace 'System' cannot be found" errors.

Is there a way I can pass arguments to MSBuild when restoring or configure .csproj to make this not happen? Or is this the new normal?

cbeall avatar Mar 22 '17 20:03 cbeall

This issue was moved to NuGet/Home#4872

livarcocc avatar Mar 22 '17 21:03 livarcocc