cirruslabs / docker-images-windows

Base Windows Docker images for Cirrus CI
MIT License
6 stars 6 forks source link

Building vcpkg.exe failed suddenly in Windows Server Core 2019 #16

Closed ericoporto closed 3 years ago

ericoporto commented 3 years ago

Hey, I don't know if it's on your image or vcpkg the problem, but I suddenly can't build vcpkg anymore.

Details here: https://github.com/microsoft/vcpkg/issues/14883

It worked fine until sunday 29/12/2020, but I didn't use the docker again until yesterday, right when I picked the error I opened the issue on MS repository.

ericoporto commented 3 years ago

This pipeline code on Cirrus CI needs a huge update because there is a switch of backend going in AGS, but I suddenly can't seem to be able to build new Windows Docker images because I can't build vcpkg anymore.

ericoporto commented 3 years ago

Here's a Dockerfile for testing

# base will already have Chocolatey installed
FROM cirrusci/windowsservercore:2019

# no temp folder exists by default
RUN mkdir %TEMP%

ARG VISUALCPP_BUILD_TOOLS_VERSION=14.0.25420.1
RUN cinst visualcpp-build-tools --version %VISUALCPP_BUILD_TOOLS_VERSION% -y

# Windows 8.0 SDK (but only install the .NET 4.5 SDK)
RUN cd %TEMP% && \
  curl -fLO http://download.microsoft.com/download/F/1/3/F1300C9C-A120-4341-90DF-8A52509B23AC/standalonesdk/sdksetup.exe && \
  start /wait sdksetup /ceip off /features OptionID.NetFxSoftwareDevelopmentKit /quiet /norestart

ARG NUGET_VERSION=5.7.0
RUN cinst nuget.commandline --version %NUGET_VERSION% -y

ARG INNO_SETUP_VERSION=6.0.5
RUN cinst innosetup --version %INNO_SETUP_VERSION% -y

ARG CMAKE_VERSION=3.18.4
RUN cinst cmake --version %CMAKE_VERSION% --installargs ADD_CMAKE_TO_PATH=System -y

RUN pushd %TEMP% && \
  git clone https://github.com/Microsoft/vcpkg.git && \
  pushd vcpkg && \
  if not exist vcpkg.exe call bootstrap-vcpkg.bat 
k0ekk0ek commented 3 years ago

The existing image was rather broken and there was only a severely outdated one on the Docker hosts. I'm guessing it has to do with VISUALCPP_BUILD_TOOLS_VERSION=14.0.25420.1, but I could be wrong. Then again, it could be the replacement of visualstudio2019community. Maybe try installing that in the docker?

ericoporto commented 3 years ago

Can you tell me what line I have to add for visualstudio2019community ?

I will try cinst -y --no-progress visualstudio2019community line, and will assume it works

Why it was removed from the image? Having some visual studio on a Docker would be helpful for Windows projects targeting desktop. Is it available in other Cirrus-CI Windows Docker image I should use as base?

k0ekk0ek commented 3 years ago

It wasn't in originally (it contains the IDE) and I think someone added it in the hope to add the C++ toolkit. However, Microsoft has a specific installer target for the build tools. Chocolatey package visualstudio2019buildtools and users should install the chocolatey package visualstudio2019-workload-vctools for the C++ toolkit. There's a couple of other workloads too.

If you update the above Dockerfile and add visualstudio2019 and it works, then the visualstudio2019 Chocolatey package contains something your build needs. I'm sure they'll add it back if that's the case, I just thought having the IDE itself included didn't make much sense. If adding the package doesn't solve the issue, you could try adding visualstudio2019-workload-nativedesktop, I think I saw it mentioned in the errorlog you posted.

ericoporto commented 3 years ago

Thanks, I will try that. Adding the visualstudio2019community breaks the docker build because the machine requires a restart and then it simply errors.

visualstudio2019-workload-nativedesktop package files install completed. Performing other installation steps.
ERROR: Unable to detect any supported Visual Studio product. You may try passing --installPath or both --productId and --channelId parameters.
The install of visualstudio2019-workload-nativedesktop was NOT successful.
ericoporto commented 3 years ago

I tried adding

RUN cinst -y --no-progress visualstudio2019-workload-vctools
RUN cinst -y --no-progress visualstudio2019-workload-nativedesktop

But unfortunately this requires a restart which breaks the build of the Dockerfile on Cirrus-CI.

k0ekk0ek commented 3 years ago

The vctools one is already available in the base, so that one shouldn't be necessary (contrib/cmake/Dockerfile contains the details). You could try adding || echo "ignore reboot request" to the nativedesktop workload, it has been done before :slightly_smiling_face:

ericoporto commented 3 years ago

I managed to get the following Dockerfile to run!

FROM cirrusci/windowsservercore:2019

# Microsoft .NET Framework 4.8 4.8.0.20190930 is broken and causes the
# installation of visualstudio2019-workload-vctools to fail. To workaround
# the issue request Microsoft .NET Framework 4.7.2.20180712 instead, which
# is already installed and thus speeds up installation as well.
# this is just to prevent visualstudio2019 to force a reset in the machine
RUN cinst -y --no-progress dotnetfx --version=4.7.2.20180712

RUN cinst -y --no-progress --version=16.8.2.0 visualstudio2019buildtools 

RUN cinst -y --no-progress --version=1.0.0 visualstudio2019-workload-vctools 

RUN cinst -y --no-progress --version=1.0.0 visualstudio2019-workload-nativedesktop || echo "ignore reboot request"

But it takes a long time to complete. Like an hour. Is it possible for me to create another docker that uses this docker listed above as starting point in Cirrus-CI? Essentially other that I will do something like FROM cirrusci/mywindowsenv at the top. I don't want to waste time doing tasks that don't need update. I looked docker pipe in the docs but I don't think it would work like this.

I don't want this packages to have undefined versions - and I want to do my own install of cmake, which is another reason why I don't want to use the provided image.

I predict the rest of my environment to have more changes so by cutting the docker in two I get to have the things that change less and the things that change often separated.

k0ekk0ek commented 3 years ago

@ericoporto, yeah it takes quite a long time. This is a guess, but I think sure the Cirrus people will be happy to add this to the CMake image. I'll issue a PR with the visualstudio2019-workload-nativedesktop package added. I want to see if I can add the 2017 runtime workload for 2019 in anyway. Glad to see it worked!