Docker Community Forums

Share and learn in the Docker community.

How to install Build Tools for creating .NET artefacts in a container

There should be an easy way, or even a rebuild image to compile and deploy .NET artefacts using VS tools. Installing VS itself should not be needed since it brings a load of stuff that is not really needed.

Furthermore it seems to be impossible to have VS installed without rebooting.

What we want to achieve is to have a Windows Container that can be spawned in our Jenkins/Swarm Environment (working so far) to build the artefacts.

1 Like

I’m hoping to use Windows containers for a similar use case… We’re building C++/C# projects.


Anthony Chu shows an example of using Chocolatey to install msbuild here: and compile a .Net 4.6 web app.

FROM microsoft/iis

Install Chocolatey

RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command “$env:ChocolateyUseWindowsCompression=‘false’; iex ((New-Object System.Net.WebClient).DownloadString(‘’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

Install build tools

RUN powershell add-windowsfeature web-asp-net45
&& choco install microsoft-build-tools -y --allow-empty-checksums -version 14.0.23107.10
&& choco install dotnet4.6-targetpack --allow-empty-checksums -y
&& choco install nuget.commandline --allow-empty-checksums -y
&& nuget install MSBuild.Microsoft.VisualStudio.Web.targets -Version
&& nuget install WebConfigTransformRunner -Version

Delete existing files in wwwroot

RUN powershell remove-item C:\inetpub\wwwroot\iisstart.*

Copy files

RUN md c:\build
WORKDIR c:/build
COPY . c:/build

Restore packages, build, copy

RUN nuget restore
&& “c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe” /p:Platform=“Any CPU” /p:VisualStudioVersion=12.0 /p:VSToolsPath=c:\MSBuild.Microsoft.VisualStudio.Web.targets.\tools\VSToolsPath DockerDemo.sln
&& xcopy c:\build\DockerDemo* c:\inetpub\wwwroot /s

Ensure container doesn’t exit

CMD powershell
Write-Host IIS Started… ;
while ($true) { Start-Sleep -Seconds 3600 }

Thanks for sharing. What we’re looking for (in addition) is how to build mobile and desktop applications using Docker … do you have any hints for this direction as well?

Sorry, no real tips.Using a Server 2016 VM as a sandbox to find out what you need installed further would be a good idea, rather than doing it all in a container. Once you have worked that all out, then try repeating it from powershell in the containter, then once that is working you can code your dockerfile.

I was able to get vs2015 to install in a docker container on Server2016 it just took about 8 hours. Here is the docker file I used The base image is not yet on docker hub but you can build it on your own from this file and tag it appropriately.

This will give you a container that is running the VSTS build agent that seems to build ASP.NET 4 and Windows Desktop apps fine. I have not yet tried mobile.

1 Like