Building ROS2 workspace in Windows Docker image leads to error

54 Views Asked by At

I am trying to build a ROS2 Workspace inside a docker container. I followed these two manuals to install Visual Studio in the docker container:

https://learn.microsoft.com/de-de/visualstudio/install/build-tools-container?view=vs-2019

https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2019

https://docs.ros.org/en/crystal/Installation/Windows-Install-Binary.html#install-visual-studio

This is the Dockerfile content I came up with:

RUN wget --no-verbose https://aka.ms/vs/16/release/vs_buildtools.exe
RUN start /w vs_buildtools.exe --quiet --wait --norestart --nocache \
        --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" \
        --add Microsoft.VisualStudio.Workload.NativeDesktop \
        --add Microsoft.VisualStudio.Component.Debugger.JustInTime \
        --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 \
        --add Microsoft.VisualStudio.Component.VC.DiagnosticTools \
        --add Microsoft.VisualStudio.Component.Windows10SDK.17134 \
        --add Microsoft.VisualStudio.Component.VC.ATL \
        --add Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest \
        --add Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest \
        --add Microsoft.VisualStudio.Component.VC.Llvm.Clang \
        || IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN del /q vs_buildtools.exe
RUN setx /m PATH "%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64"

...

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY entrypoint.cmd entrypoint.cmd
ENTRYPOINT ["entrypoint.cmd"]

The installation produces no log output at all.

entrypoint.cmd:

...
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat"

%*

However I keep getting an error when running the colcon command:

colcon build --cmake-args -G "Visual Studio 16 2019" -A x64 -T v141

The following error is produced:

Starting >>> my_project
--- stderr: my_project
CMake Warning (dev) at CMakeLists.txt:4 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:4 (project):
  Failed to run MSBuild command:
    C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe
  to get the value of VCTargetsPath:
    
  Exit code: 1
---
Failed   <<< my_project [3.00s, exited with code 1]
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)
Summary: 0 packages finished [5.03s]
  1 package failed: my_project
  1 package had stderr output: my_project

Quick remark: I am trying to build a Nvidia Cuda application. However I also want to compile the workspace without Cuda, which is not yet possible because of another problem:

Same entrypoint in windows docker produces different behavior in gitlab runner

0

There are 0 best solutions below