Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not validate variable substitutions in RUN instructions #60

Closed
rcjsuen opened this issue May 22, 2019 · 0 comments
Closed

Do not validate variable substitutions in RUN instructions #60

rcjsuen opened this issue May 22, 2019 · 0 comments
Assignees
Labels

Comments

@rcjsuen
Copy link
Owner

rcjsuen commented May 22, 2019

In #56 we added support for the ? modifier in RUN instructions. However, from a report in microsoft/vscode-docker#952 we can see that PowerShell (unsurprisingly) works quite different than Bash (and presumably other shells in the *nix world).

Hence, we should instead skip the validation of variable substitutions if they are found within a RUN instruction.

$ dockerfile-utils lint Dockerfile.1.1 
Line: 42
    Remove-Item -Force -Recurse \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\"; `
                                        ^
Error: failed to process "${Env:ProgramFiles(x86)}": unsupported modifier (P) in substitution

Line: 43
    Remove-Item -Force -Recurse ${Env:TEMP}\*; `
                                      ^
Error: failed to process "${Env:TEMP}": unsupported modifier (T) in substitution

Line: 44
    Remove-Item -Force -Recurse \"${Env:ProgramData}\Package Cache\"
                                        ^
Error: failed to process "${Env:ProgramData}": unsupported modifier (P) in substitution
# escape=`

ARG REPO=mcr.microsoft.com/dotnet/framework/runtime
FROM $REPO:4.8-windowsservercore-ltsc2016

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install NuGet CLI
ENV NUGET_VERSION 4.4.1
RUN New-Item -Type Directory $Env:ProgramFiles\NuGet; `
    Invoke-WebRequest -UseBasicParsing "https://dist.nuget.org/win-x86-commandline/v$Env:NUGET_VERSION/nuget.exe" -OutFile $Env:ProgramFiles\NuGet\nuget.exe

# Install VS Test Agent
RUN Invoke-WebRequest -UseBasicParsing "https://download.visualstudio.microsoft.com/download/pr/446c5efe-9162-41a1-b380-704c82d13afa/8c6c6f404ed99e477007f16a336f99a6/vs_testagent.exe" -OutFile vs_TestAgent.exe; `
    Start-Process vs_TestAgent.exe -ArgumentList '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait; `
    Remove-Item -Force vs_TestAgent.exe; `
    # Install VS Build Tools
    Invoke-WebRequest -UseBasicParsing "https://download.visualstudio.microsoft.com/download/pr/df649173-11e9-4af2-8eb7-0eb02ba8958a/cadb5bdac41e55bb8f6a6b7c45273370/vs_buildtools.exe" -OutFile vs_BuildTools.exe; `
    # Installer won't detect DOTNET_SKIP_FIRST_TIME_EXPERIENCE if ENV is used, must use setx /M
    setx /M DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1; `
    Start-Process vs_BuildTools.exe `
    -ArgumentList `
    '--add', 'Microsoft.VisualStudio.Workload.MSBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.NetCoreBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.VCTools', `
    '--add', 'Microsoft.VisualStudio.Workload.NodeBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.MSBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.WebBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.AzureBuildTools', `
    '--add', 'Microsoft.VisualStudio.Workload.VisualStudioExtensionBuildTools', `
    '--add', 'Microsoft.Net.ComponentGroup.4.7.DeveloperTools', `
    '--add', 'Microsoft.Net.ComponentGroup.4.7.1.DeveloperTools', `
    '--add', 'Microsoft.VisualStudio.Workload.NetCoreBuildTools', `
    '--add', 'Microsoft.Component.ClickOnce.MSBuild', `
    '--add', 'Microsoft.VisualStudio.Component.VC.v141.MFC', `
    '--add', 'Microsoft.VisualStudio.Component.VC.v141.ATL', `
    '--remove', 'Microsoft.VisualStudio.Component.Windows81SDK', `
    '--quiet','--includeRecommended','--includeOptional', '--norestart', '--nocache' `
    -NoNewWindow -Wait; `
    Remove-Item -Force vs_buildtools.exe; `
    Remove-Item -Force -Recurse \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\"; `
    Remove-Item -Force -Recurse ${Env:TEMP}\*; `
    Remove-Item -Force -Recurse \"${Env:ProgramData}\Package Cache\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant