问题
I am deploying .net core app to Docker.
My docker file is as follows, which is added in my .net core application:
FROM microsoft/dotnet:1.1-sdk-projectjson
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
Its not able to resolve .net standard class libraries, which are added to my .net core application.
My project structure is as follows:
Core folder
-Logging.Interfaces .net std project
-Logging.Entities .net std project
Infrastructure folder
-Infrastructure.Logging .net std project
Services folder
-Services .net std project
Web folder
-Web .net core application
Dependencies section of project.json of Web application is as follows:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Services": "1.0.0-*",
"DomainInterfaces": "1.0.0-*",
"Core.Logging.Interfaces": "1.0.0-*",
"Core.Logging.Entities": "1.0.0-*",
"Infrastructure.Logging": "1.0.0-*"
},
When I run following command, for creating image, it gives me error:
user@machine_name MINGW64 path to solution
$ docker build -t helloWorld:core .
Unable to resolve 'Core.Logging.Interfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'Core.Logging.Entities (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'Services (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'Infrastructure.Logging (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'DomainInterfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Can someone please guide, what is going wrong over here, as I am completely new to Docker.
回答1:
I think you should be tried to create a Dockerfile on solution level as following structure:
/YourProject
- src
- Core
- Infrastructure
- Services
- WebApp
- Dockerfile
And changes content of Dockerfile to:
FROM microsoft/dotnet:1.1-sdk-projectjson
COPY . /app
WORKDIR /app/src/WebApp
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
Hope this help!
回答2:
My dot net core application does not have a project.json file either. I fixed my problem with the follow: FROM microsoft/dotnet:1.1-sdk
instead of FROM microsoft/dotnet:1.1-sdk-projectjson
来源:https://stackoverflow.com/questions/42198968/docker-unable-to-resolve-net-standard-class-libraries-on-deploying-net-core-a