0

如果我在文件路径中使用 env var "TEMP_DIR",如下所示:

"RUN $env:TEMP_DIR\BuildTools2017\vs_buildtools_2017.exe..."

或者

 "RUN $TEMP_DIR\BuildTools2017\vs_buildtools_2017.exe..."

然后,构建将遇到错误:

“该系统找不到指定的路径。”

为什么?我应该如何避免"C:\temp"在文件路径中使用硬编码,谢谢。

Dockerfile 为 VS 2017 安装构建工具:

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'; "]
4

1 回答 1

0

Windows 公开%TEMP%环境变量:

RUN %TEMP%\BuildTools2017\vs_buildtools_2017.exe --quiet --wait --norestart --nocache --noWeb --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.VCTools
于 2019-05-20T13:45:30.217 回答