我正在将.net核心应用程序部署到Docker。
我的docker文件如下所示,它在我的.net核心应用程序中添加:
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"]
它无法解析.net标准类库,它们被添加到我的.net核心应用程序中。
我的项目结构如下:
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
Web应用程序的project.json的依赖关系部分如下:
{
"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-*"
},
当我运行以下命令时,为了创建图像,它给了我错误:
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'.
有人可以指导,这里出了什么问题,因为我对Docker来说是全新的。
答案 0 :(得分:0)
我认为您应该尝试在解决方案级别创建一个Dockerfile,如下所示:
/ YourProject
并将Dockerfile的内容更改为:
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"]
希望这有帮助!
答案 1 :(得分:0)
我的dot net core应用程序也没有project.json文件。我通过以下操作解决了问题:var installer = require('electron-winstaller');
var path = require('path');
console.log("packaging into a exe...");
resultPromise = installer.createWindowsInstaller({
appDirectory: './AppName-win32-ia32',
outputDirectory: './installers',
exe: 'AppName.exe',
setupExe: 'FinalExeName.exe',
noMsi: true,
iconUrl: 'IconUrl',
setupIcon: 'IconPath'
});
resultPromise.then(function () {
console.log("Installer created");
require('electron').app.quit();
});
而不是FROM microsoft/dotnet:1.1-sdk