0

I am trying to build a flutter windows application inside a windows docker container (mcr.microsoft.com/windows/servercore:ltsc2019), which is running on a windows host. The problem is that when I am running the build command (flutter build windows) I get an error that the windows developer mode needs to be enabled:

Building with plugins requires symlink support.

Please enable Developer Mode in your system settings. Run
  start ms-settings:developers
to open settings.

My Dockerfile looks like this:

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Use admin
USER ContainerAdministrator

# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/17/release/vs_buildtools.exe vs_buildtools.exe
# Install Build Tools with the Microsoft.VisualStudio.Workload.VCTools workload
RUN (start /w vs_buildtools.exe --quiet --wait --norestart --nocache \
    --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" \
    --add Microsoft.VisualStudio.Workload.VCTools \
    --add Microsoft.VisualStudio.Component.VC.CMake.Project \
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
    --add Microsoft.VisualStudio.Component.Windows11SDK.22621 \
    --add Microsoft.VisualStudio.Component.Windows10SDK.20348 \
    || IF "%ERRORLEVEL%"=="3010" EXIT 0)
# Cleanup
RUN del /q vs_buildtools.exe

# Install ninja-Build
ADD https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip ninja.zip
RUN powershell Expand-Archive C:\ninja.zip -DestinationPath C:\ninja; \
    && setx path "%path%;C:\ninja" \
    && del /q ninja.zip

# Install mariadb-connector-c
ADD https://dlm.mariadb.com/2862619/Connectors/c/connector-c-3.3.4/mariadb-connector-c-3.3.4-win64.msi mariadb-connector-c.msi
RUN msiexec.exe /i "mariadb-connector-c.msi" /qn /norestart \
    && del /q mariadb-connector-c.msi

# Install git
ADD https://github.com/git-for-windows/git/releases/download/v2.40.1.windows.1/MinGit-2.40.1-64-bit.zip MinGit.zip
RUN powershell Expand-Archive C:\MinGit.zip -DestinationPath C:\MinGit; \
    && setx /m PATH "%PATH%;C:\MinGit\cmd" \
    && del /q MinGit.zip
# Fix flutter "Error: Unable to find git in your PATH."
RUN git config --system --add safe.directory "*" \
    && git config --system http.sslcainfo 'C:\MinGit\mingw64\etc\ssl\certs\ca-bundle.crt' \
# RUN git config --system http.sslcainfo 'C:\MinGit\mingw64\ssl\certs\ca-bundle.crt'
    && git config --system http.sslverify false

# Install Google Root R1 cert so pub.dartlang.org stays working
ADD https://pki.goog/repo/certs/gtsr1.pem C:/TEMP/gtsr1.pem
RUN powershell.exe -Command \
        Import-Certificate -FilePath C:\TEMP\gtsr1.pem -CertStoreLocation Cert:\LocalMachine\Root

# Install Flutter
ADD https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.10.0-stable.zip flutter.zip
RUN powershell Expand-Archive C:\flutter.zip -DestinationPath C:\; \
    && setx /m path "%PATH%;C:\flutter\bin;C:\flutter\bin\cache\dart-sdk\bin;" \
    && del /q flutter.zip

# Restore default user
USER ContainerUser

# Enable developer mode
RUN REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
RUN REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1"

# Setup flutter
RUN flutter config --no-analytics
RUN flutter --disable-telemetry
RUN dart --disable-analytics
RUN flutter config --enable-windows-desktop
RUN flutter doctor

ENTRYPOINT [ "cmd" ]
CMD [ "cmd" ]

As you can see from the Dockerfile I already tried modifying the registry entries HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock\AllowDevelopmentWithoutDevLicense and HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock\AllowAllTrustedApps to enable the developer mode as described here without any luck.

What needs to be done differently to get this working? Thanks in advance :)

enwi
  • 67
  • 1
  • 2
  • 8

0 Answers0