Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volume mapping visual studio 2019 to nuget package cache

I don't use the inbuilt docker build inside of visual studio 2019 because it is too buggy. Instead I build my own container and then attach VS2019 to it for debugging.

If I make a change to a single dependency (or a previous layer) then it will re-download all dependencies in order to rebuild the needed layers.

This is bandwidth/time intensive and the packages are already cached in local machine.

I have read: https://learn.microsoft.com/en-us/visualstudio/containers/container-build?view=vs-2019

It has interesting table explaining how the inbuilt feature maps folders:

enter image description here

How do I see what that mapping looks like? I think If I add that volume mapping to my own compose file then it would greatly increase speed as it wouldn't have to re-download on each build.

like image 238
Guerrilla Avatar asked Jun 08 '20 17:06

Guerrilla


1 Answers

In order to see what exactly your docker container is mapped to, you can list docker containers via

docker ps

and then grab your containers id, and inspect it via

docker inspect <id>

I have a container running right now which does use the inbuilt VS toolset, so let's see what that one says about mounts:

...
        {
            "Type": "bind",
            "Source": "/host_mnt/c/Users/<name>/.nuget/packages",
            "Destination": "/root/.nuget/packages",
            "Mode": "ro",
            "RW": false,
            "Propagation": "rprivate"
        },
...

Okay, so this is the mount you're probably looking for.

In order to take a look at what VS does exactly, you can go to the 'obj' folder of your project, and then head to 'Docker'.

In here you will find the actually interesting file VS will use for the docker-compose up call, which is e.g. the docker-compose.vs.debug.g.yml file. Here you will also find the release config, which does not contain the NuGet mount as it is actually building with dotnet publish.

So in the docker-compose.vs.debug.g.yml file you can finally find the required path for the mount, which looks like this for my application:

    volumes:
  - ...
  - C:\Users\<name>\.nuget\packages\:/root/.nuget/packages:ro

Which is exactly what we found in the docker inspect.

I hope this helps.

Also, take a look at this article which goes into detail on how the whole docker setup VS uses works exactly:

https://www.scrum-tips.com/2017/12/27/understanding-docker-with-visual-studio-2017-part-2/

like image 54
Sossenbinder Avatar answered Nov 20 '22 06:11

Sossenbinder