.NET 8 Core "unresolved symbol" when running with docker-compose

46 Views Asked by At

In my .NET 8 Core API app, when I run dotnet run, everything is working. But Im using a docker-compose, and there come the problems.

When I run my app with docker-compose up --build, my IDE stops to resolve the NuGet packages installed in all the projects of my solution. And, important point : it builds well, I never meet build issues.

So let's say I have imported 2 packages :

using AutoMapper;
using Microsoft.EntityFrameworkCore;

before building with docker-compose, no issue at all. After building, I would have this issue : Cannot resolve symbol 'EntityFrameworkCore'. And so on for all NuGet packages.

I've tried lots of things to try to fix the issue :

  • Invalidate IDE cache
  • change from Rider to VS
  • Clone solution in another computer

But it has never fixed the issue. When I do dotnet resolve, it works, but only temporarily: after a new rebuilt, the error appears again.


SOLUTION

After many hours I finally find out a solution. In docker-compose.yml, add those lines the web config:

volumes:
    - /app/obj/
    - /app/bin/
    - /app/out/

Then add those lines in the .dockerignore file :

bin/
obj/
out/
1

There are 1 best solutions below

0
Qunther On

SOLUTION

After many hours I finally find out a solution. In docker-compose.yml, add those lines the web config:

volumes:
    - /app/obj/
    - /app/bin/
    - /app/out/

Then add those lines in the .dockerignore file :

bin/
obj/
out/