【发布时间】:2019-05-20 08:59:24
【问题描述】:
如果我在文件路径中使用 env var "TEMP_DIR",如下所示:
"RUN $env:TEMP_DIR\BuildTools2017\vs_buildtools_2017.exe..."
或
"RUN $TEMP_DIR\BuildTools2017\vs_buildtools_2017.exe..."
那么,构建就会出错:
“系统找不到指定的路径。”
为什么?我应该如何避免在文件路径中使用硬编码的"C:\temp",谢谢。
为 VS 2017 安装构建工具的 Dockerfile:
FROM openjdk:8-jdk-windowsservercore
ARG version
ENV TEMP_DIR="c:/temp"
SHELL ["powershell","-NoProfile","-Command","$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; "]
# Create temp file for installers
RUN New-Item -ItemType Directory -Force -Path $env:TEMP_DIR;
# Install Visual Studio ultimate 2012
COPY ./VS2012_ultimate "c:/temp/VS2012_ultimate"
RUN \
Start-Process -FilePath "$env:TEMP_DIR/VS2012_ultimate/vs_ultimate.exe" - ArgumentList '/passive', '/q', '/s', '/norestart', '/noweb', '/full', -PassThru | Wait-Process;
# Install Blend.Sdk.WPF 4.0 & 4.5
COPY ./BlendSdk "$TEMP_DIR/BlendSdk"
RUN \
Start-Process -FilePath "$env:TEMP_DIR/BlendSdk/BlendWPFSDK_en.msi" -ArgumentList '/passive', '/norestart' -PassThru | Wait-Process; \
Start-Process -FilePath "$env:TEMP_DIR/BlendSdk/BlendWPFSDK.msi" -ArgumentList '/passive', '/norestart' -PassThru | Wait-Process;
# Install build tool for VS 2017
SHELL ["cmd", "/S", "/C"]
COPY ./BuildTools2017 "$TEMP_DIR/BuildTools2017"
RUN C:\temp\BuildTools2017\vs_buildtools_2017.exe --quiet --wait --norestart --nocache --noWeb --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.VCTools
--add Microsoft.Net.Component.3.5.DeveloperTools --add Microsoft.VisualStudio.Component.Windows10SDK.17763
SHELL ["powershell", "-NoProfile", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; "]
【问题讨论】:
-
错误是什么?
-
"系统找不到指定的路径。"
-
抱歉,我现在不在 Windows 机器上,所以我无法测试这个,但您是否尝试过写
%TEMP_DIR%而不是$TEMP_DIR?这应该是在 cmd.exe 中使用环境变量的正确语法。
标签: docker docker-compose dockerfile visual-studio-2017-build-tools