Reputation: 11
I am trying to build an ASP.net MVC project in a dockerfile in order to run in a container.
I tried using both the dotnet image and the servercore image in different dockerfiles whilst then using chocolately to install the other missing package and trying to build with msbuild but I'm stuck.
FROM microsoft/windowsservercore:10.0.14393.1480
SHELL ["powershell", "-Command", "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue';"]
WORKDIR /appdir
EXPOSE 80
EXPOSE 443
COPY . /appdir/
COPY /ExFin.Web/packages.config /appdir/
ENV chocolateyUseWindowsCompression 'true'
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
RUN choco install visualstudio2019buildtools -y;
RUN choco install dotnet4.5.2 -Force -y;
RUN choco install nuget.commandline --pre
ENV NUGET_PATH "C:\Chocolatey\lib\NuGet.CommandLine.3.5.0\tools"
ENV MSBUILD_PATH "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin"
RUN $env:PATH = $env:NUGET_PATH + ';' + $env:MSBUILD_PATH + ';' + $env:PATH; `
RUN [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
RUN nuget.exe restore packages.config -PackagesDirectory /appdir/packages/
RUN ["C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\msbuild.exe", "C:/appdir/ExFin.Web/ExFin.Web.csproj"]
The error: Failures
Could this mean that a restart is required??
Upvotes: 1
Views: 11649
Reputation: 8813
You can use Chocolatey to install MSBuild tools 2022.
choco install visualstudio2022buildtools
Also, Microsoft has an example Dockerfile which manually installs build tools 2022.
# escape=`
# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
RUN `
# Download the Build Tools bootstrapper.
curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
`
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Workload.AzureBuildTools `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
`
# Cleanup
&& del /q vs_buildtools.exe
# 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\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Upvotes: 0
Reputation: 3661
Use Microsoft's .NET Framework SDK (Dockerfile) image based on .NET Framework Runtime based on Windows Server Core.
The image includes:
Upvotes: 3