Collin Barrett
Collin Barrett

Reputation: 2569

'dotnet publish' error referencing dependencies in non-existent lib directory

I am trying to deploy a dotnet core web app via Travis CI to a Ubuntu VPS. I am using dotnet restore && dotnet publish -c release -r ubuntu.16.04-x64 to build before scp-ing over to the server. The build and deploy completes fine on Travis, but when I restart the application service on my server I get errors such as the one below.

Error: assembly specified in the dependencies manifest was not found -- package: 'microsoft.aspnetcore.antiforgery', version: '1.1.1', path: 'lib/netstandard1.3/Microsoft.AspNetCore.Antiforgery.dll'

The *.deps.json file that gets created as a part of the publish has lines such as those below.

"microsoft.aspnetcore.antiforgery/1.1.1": {
    "dependencies": {
      "Microsoft.AspNetCore.DataProtection": "1.1.1",
      "Microsoft.AspNetCore.Http.Abstractions": "1.1.1",
      "Microsoft.AspNetCore.Http.Extensions": "1.1.1",
      "Microsoft.AspNetCore.WebUtilities": "1.1.1",
      "Microsoft.Extensions.ObjectPool": "1.1.0",
      "NETStandard.Library": "1.6.1"
    },
    "compile": {
      "lib/netstandard1.3/Microsoft.AspNetCore.Antiforgery.dll": {}
    }
  },
  "microsoft.aspnetcore.authorization/1.1.1": {
    "dependencies": {
      "Microsoft.Extensions.Logging.Abstractions": "1.1.1",
      "Microsoft.Extensions.Options": "1.1.1",
      "NETStandard.Library": "1.6.1",
      "System.Security.Claims": "4.3.0"
    },
    "compile": {
      "lib/netstandard1.3/Microsoft.AspNetCore.Authorization.dll": {}
    }
},

Those "compile" attributes are what is causing the issue, because if I manually remove the compile attribute for lib/netstandard1.3/Microsoft.AspNetCore.Antiforgery.dll, the error now becomes:

Error: assembly specified in the dependencies manifest was not found -- package: 'microsoft.aspnetcore.authorization', version: '1.1.1', path: 'lib/netstandard1.3/Microsoft.AspNetCore.Authorization.dll'

Why do these compile attributes get created in the *.deps.json file? Are they needed? If so, why is the lib directory not created when I dotnet publish? If not, how can I remove them so that my app runs?

Thanks.

Upvotes: 1

Views: 1637

Answers (1)

Collin Barrett
Collin Barrett

Reputation: 2569

So, I re-read the docs again and noticed one little detail I had been neglecting. I had been deploying all of the contents of netcoreapp1.1 rather than just the contents of netcoreapp1.1/publish. So, my server was executing the .dll in netcoreapp1.1 rather than the one in netcoreapp1.1/publish. That resolved all of my issues.

Upvotes: 5

Related Questions