Search code examples
.net.net-corevisual-studio-mac

.Net Core - Building to release does not copy NUGET dependencies


I have a console .net core app.
It references a few nuget packages.
Now that it's ready to deploy, when i'm building to release, the nuget references are not coming along so i'm getting a bunch of file not found...

how can i fix this?


Solution

  • It's the difference between building (for testing) and publishing (for deployment to production). dotnet build will build your application for local testing and usage. It will assume that nuget dependencies are present on the machine. If you want to build for deployment, use dotnet publish instead:

    dotnet publish -c Release
    

    Then look into the ./bin/Release/netcoreapp2.0/publish directory. It should contain all your dependencies too.

    See https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli for more details.