我正在创建一个Dockerfile来构建和部署ASP.NET 4应用程序。我有这段代码:
#Use the add-msbuild image that has msbuild.exe installed. This image inherits from microsoft/iis.
FROM add-msbuild
#Make a folder in the container that will contain the application.
RUN mkdir "C:\site"
RUN mkdir "C:\site\packages"
RUN mkdir "C:\build"
#Copy the application source code to the build folder.
COPY . "C:\build"
WORKDIR "C:\build"
#Build the application.
RUN ["nuget.exe", "restore"]
RUN ["C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\msbuild.exe", "C:\\build\\*.csproj"]
我创建了另一个名为add-msbuild的图像,它继承自microsoft / iis。这样,我有一个安装了msbuild和nuget的映像,这样我就可以构建我的代码了。此dockerfile从包含源代码的文件夹运行。
问题:我无法使RUN ["nuget.exe", "restore"]
行生效。 CLI给出了这个错误:Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
好的,好的。我将添加此参数。我尝试了以下方法:
RUN ["nuget.exe", "restore", "PackagesDirectory"]
RUN ["nuget.exe", "restore", "-PackagesDirectory 'C:\site\packages'"]
RUN ["nuget.exe", "restore", "PackagesDirectory 'C:\site\packages'"]
RUN ["nuget.exe", "restore", "PackagesDirectory", "C:\site\packages"]
RUN ["nuget.exe", "restore", "-PackagesDirectory", "C:\site\packages"]
但是所有方式都会给出错误信息。我究竟做错了什么?如果有任何不同,我会使用docker build -t myproject .
开始构建。
编辑:从C:\build
文件夹运行ls命令会返回:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/1/2017 1:41 PM App_Data
d----- 5/1/2017 11:55 AM App_Start
d----- 9/12/2017 3:28 PM bin
d----- 9/15/2017 10:03 AM Content
d----- 8/16/2017 1:50 PM Controllers
d----- 9/1/2017 3:45 PM DockerImage
d----- 9/15/2017 10:03 AM fonts
d----- 5/1/2017 11:55 AM Helpers
d----- 9/4/2017 4:32 PM Models
d----- 9/1/2017 3:27 PM obj
d----- 5/1/2017 11:55 AM Properties
d----- 9/15/2017 10:03 AM Scripts
d----- 8/16/2017 1:50 PM Views
-a---- 9/15/2017 10:10 AM 953 Dockerfile
-a---- 5/1/2017 11:55 AM 32038 favicon.ico
-a---- 5/1/2017 11:55 AM 111 Global.asax
-a---- 5/1/2017 11:55 AM 601 Global.asax.cs
-a---- 9/15/2017 10:03 AM 21422 myproject.csproj
-a---- 9/15/2017 10:03 AM 2141 myproject.csproj.use
r
-a---- 5/1/2017 1:41 PM 257 myproject.csproj.vsp
scc
-a---- 5/30/2017 8:51 AM 148 myproject.v3.ncrunch
project
-a---- 9/4/2017 4:32 PM 174 local-deploy.ps1
-a---- 9/15/2017 10:03 AM 3006 packages.config
-a---- 5/1/2017 11:55 AM 5277 Project_Readme.html
-a---- 5/1/2017 11:55 AM 276 Startup.cs
-a---- 9/15/2017 10:03 AM 8546 Web.config
-a---- 5/12/2017 8:32 AM 442 Web.Debug.config
-a---- 5/1/2017 11:55 AM 1168 Web.Release.config
-a---- 5/12/2017 8:32 AM 1332 Web.Test.config