Docker Entrypoint overridden causing command to be unavailable

Hi

We have a docker image. It contains the VS2019 build tools. If we run interactively, it uses the entrypoint in the dockerfile and can run 'msbuild'.  Our entrypoint is:

ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

 

When our TC build task runs this docker image with a custom script, the script including an 'msbuild' line, it cannot resolve msbuild.

If I use 'SET', it shows that the environment variables for VS are not set, and is actually running as a generic command line, not even using the entrypoint.

Looking at the build output shows that TC is indeed creating it's own entrypoint

[Step 1/4] Starting: cmd /c "docker run --rm -w "C:\BuildAgent\work\cf3bf0200a465dcb" 
--label jetbrains.teamcity.buildId=197357 --isolation=process
-v ""C:\Users\user\Desktop\Sign:C:\BuildAgent\work\cf3bf0200a465dcb\Sign""
-v "C:\BuildAgent\work\cf3bf0200a465dcb:C:\BuildAgent\work\cf3bf0200a465dcb"
-v "C:\BuildAgent\temp\agentTmp:C:\BuildAgent\temp\agentTmp"
-v "C:\BuildAgent\temp\buildTmp:C:\BuildAgent\temp\buildTmp"
-v "C:\BuildAgent\system:C:\BuildAgent\system"
-v "C:\BuildAgent\lib:C:\BuildAgent\lib:ro"
-v "C:\BuildAgent\tools:C:\BuildAgent\tools:ro"
-v "C:\BuildAgent\plugins:C:\BuildAgent\plugins:ro"
--env-file "C:\BuildAgent\temp\agentTmp\docker-wrapper-6499200819641050018.env"
--entrypoint cmd "fsi-sw-docker-dev-local.ha-us.dev.dso.net/oak/buildtools2019tools:3" /c "C:\BuildAgent\temp\agentTmp\docker-shell-script-6229852712614038753.cmd""

See last line above.

I guess this is so it can run the build commands in the cmd file.  This makes sense.  What doesn't make sense is that we previously build this same docker image and msbuild worked ok. But now I don't understand how that could be given the entrypoint being overridden then and now.

Here is our dockerfile

# escape=`

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

# 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

# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe modify --quiet --wait --norestart --nocache `
--installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" `
--add Microsoft.VisualStudio.Workload.WebBuildTools `
--add Microsoft.Net.Component.4.8.TargetingPack `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.Component.ClickOnce.MSBuild `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.UniversalBuildTools `
--add Microsoft.VisualStudio.Component.VC.v141.x86.x64 `
--add Microsoft.Component.VC.Runtime.UCRTSDK `
|| 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:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

 

Do you have any idea how this might have been working but isn't now?

Thanks

0
1 comment

Note also, if we try and run the vsdevcmd.bat batch file from the TC custom script, the TC build exits at that point rather than just setting the VS2019 environment variables.  Also, adding another 'Run' line into the script to set the variables inline doesn't appear to work, as when the image is run up with a fresh cmd prompt, the VS2019 environment variables are not present.

 

0

Please sign in to leave a comment.