我有一个基于microsoft/dotnet-framework:4.7.2-sdk镜像的dotnet构建过程在docker中运行。
恢复、构建和发布工作正常,但我的集成测试要求在计算机上安装SQL Server。
我想使用多阶段构建在基于microsoft/mssql-server-windows-developer:2017-latest的容器中运行dotnet test (或者更具体地说,在我的例子中是dotnet xunit)命令。
但是这样我就不能再访问dotnet sdk了。如何从构建的第二阶段运行dotnet test。
如下所示(不起作用,最后一步失败,因为无法识别dotnet命令):
FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app
# # Copy csproj and restore as distinct layers
COPY ./*.sln ./NuGet.config ./
COPY ./libs ./libs
COPY ./src ./src
WORKDIR /app/src/Tests/
RUN dotnet build
FROM microsoft/mssql-server-windows-developer:2017-latest
WORKDIR /app/
COPY --from=build /app/src/Tests/ .
RUN dotnet xunit发布于 2018-10-26 22:05:15
在几次尝试安装dotnet构建工具和在“microsoft/mssql- Server -windows-developer”镜像上运行测试的先决条件失败后,我发现在“microsoft/dotnet-framework:4.7.2-sdk”镜像上安装Sql Server可能更容易。实际上要容易得多。
尽管我遵循了这个指南,但https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/build-tools-container.md在实际运行测试时遇到了各种各样的问题。
但反之亦然。构建需要一些时间,但它是有效的。我的Dockerfile的开头是:
# The 'docker build' command must be run with '-m 4g' argument for sql server.
FROM microsoft/dotnet-framework:4.7.2-sdk
SHELL [ "powershell.exe", "-Command" ]
RUN curl.exe -L -o sql.box https://go.microsoft.com/fwlink/?linkid=840944
RUN curl.exe -L -o sql.exe https://go.microsoft.com/fwlink/?linkid=840945
RUN Start-Process -Wait -FilePath .\sql.exe -ArgumentList /qs, /x:setup
RUN .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS
ENV MSSQL_IS_RUNNING_IN_DOCKER true剩下的只是标准的复制/dotnet构建/dotnet测试内容。
https://stackoverflow.com/questions/52929546
复制相似问题