将文件夹添加或复制到Windows Docker容器 [英] Add or copy folder to windows docker container

查看:1025
本文介绍了将文件夹添加或复制到Windows Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文件夹复制到Windows容器特定的目录.我无法添加它.

I want to copy a folder to a windows container specific directory. I am not able to add it.

我尝试过

ADD VC  C:\TEMP\VC

这有效,并将我的VC文件夹放入Windows容器文件夹C:\TEMP\VC.

This works and put my VC folder into windows container folder C:\TEMP\VC.

但是当我尝试:

ADD VC  C:\Program Files (x86)\Microsoft Visual Studio\2019\buildtools\MSBuild\Microsoft\VC

我得到了错误:

Step 4/6 : ADD VC  C:\Program Files (x86)\Microsoft Visual Studio\2019\buildtools\MSBuild\Microsoft\VC
ADD failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder462071631\Program: The system cannot find the file specified.

我也尝试过:

ADD VC  "C:\Program Files (x86)\Microsoft Visual Studio\2019\buildtools\MSBuild\Microsoft\VC"
failed to process "\"C:\\Program": unexpected end of statement while looking for matching double-quote

Step 4/6 : ADD VC  C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\buildtools\\MSBuild\\Microsoft\\VC
ADD failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder633588211\Program: The system cannot find the file specified.

什么都没有.

Dokcerfile

Dokcerfile

# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
ADD VC  C:\TEMP\VC   
#ADD /ConsoleApplication2\Debug\ConsoleApplication2.exe   C:\
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --installPath C:\BuildTools `
    --add Microsoft.Component.MSBuild `
    --add Microsoft.VisualStudio.Component.WinXP`
    --add Microsoft.VisualStudio.Component.VC.14.20.x86.x64 `
    --add Microsoft.VisualStudio.Component.VC.140`
    --add Microsoft.VisualStudio.Component.VC.Redist.MSM`
    --add Microsoft.VisualStudio.Component.VC.14.25.CLI.Support`
    --add Microsoft.VisualStudio.Component.NuGet.BuildTools`
    --add Microsoft.VisualStudio.Component.Roslyn.Compiler`
    -add Microsoft.VisualStudio.ComponentGroup.VisualStudioExtensionBuildTools.Prerequisites`
    -add Microsoft.VisualStudio.Component.VSSDKBuildTools`
    --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended \ `
     --add Microsoft.VisualStudio.Component.Static.Analysis.Tools \`
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \`
    --add Microsoft.VisualStudio.Component.VC.CMake.Project \`
    --add Microsoft.VisualStudio.Component.VC.CoreBuildTools \`
    --add Microsoft.VisualStudio.Component.VC.ATLMFC \`
    --add Microsoft.VisualStudio.Component.VC.ATL \`
    --add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop \`
    --add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP \`
    --add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP.Native \`
    --add Microsoft.VisualStudio.Component.Windows10SDK \`
    --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 \`
    --add Microsoft.VisualStudio.Component.VC.Redist.14.Latest \`
    --add Microsoft.Component.VC.Runtime.UCRTSDK \`
    --add Microsoft.VisualStudio.Component.WinXP \`
    --add Microsoft.Component.MSBuild `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
    --remove Microsoft.VisualStudio.Component.Windows81SDK `
 || IF "%ERRORLEVEL%"=="3010" EXIT 0

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&","powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

推荐答案

尝试在您进行的第三次尝试中转义空格:

Try escaping whitespace in the third attempt you made:

ADD VC  C:\Program\ Files\ (x86)\Microsoft\ Visual\ Studio\2019\buildtools\MSBuild\Microsoft\VC

或者尝试使用^转义:

ADD VC  C:\Program^ Files^ (x86)\Microsoft^ Visual^ Studio\2019\buildtools\MSBuild\Microsoft\VC

您还可以尝试使用 short path 作为路径,这也避免了任何空格问题.

You could also try using the short path for the path, which avoids any whitespace issues too.

这篇关于将文件夹添加或复制到Windows Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆