Can I install MVC 3 into a windows container during the Docker build?


I am attempting to "Lift and Shift" a legacy web service (and the website used to administer it) that was written using MVC 3. I have used the visual studio "add -> docker support" feature and I am getting my website in a container and the website will run properly if I manually connect to the running container and install MVC 3. I would much rather have MVC 3 installed when the container is built.

The dockerfile looks like this:

# escape=` (backtick)

FROM microsoft/aspnet:4.7.1-windowsservercore-1709
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
RUN  C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q

The last line of the dockerfile is the thing that does not work. I have tried several variations but the result is always some type of path not found error.

Examples of other attempted syntax:

RUN ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
RUN ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
RUN ["powershell.exe", ".\AspNetMVC3Setup.exe", "/q"]
RUN [".\AspNetMVC3Setup.exe", "/q"]
RUN AspNetMVC3Setup.exe /q

The paths and file names are correct when I connect to the running container but is it possible that during the build the files aren't really there yet?

How might I run the MVC install as part of the container build?

Error examples:

13>Step 5/5 : RUN  C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q
13> ---> Running in 3b7e8c30f2e0
13>[91mC:\inetpub\wwwroot\AspNetMVC3Setup.exe : The term
13>[0m[91m'C:\inetpub\wwwroot\AspNetMVC3Setup.exe' is not recognized as the name of a
13>cmdlet, function, script file, or operable program. Check the spelling of the
13>[0m[91mname, or if a path was included, verify that the path is correct and try again.
13>[0m[91mAt line:1 char:76
13>[0m[91m+ ... rence = 'SilentlyContinue'; C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q
13>[0m[91m+                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13>    + CategoryInfo          : ObjectNotFound: (C:\inetpub\wwwroot\AspNetMVC3Se
13>   tup.exe:String) [], ParentContainsErrorRecordException
13>    + FullyQualifiedErrorId : CommandNotFoundException

13>Step 5/5 : RUN ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
13> ---> Running in 7322410daf93
13>[91mAt line:1 char:77
13>[0m[91m+ ... ference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; [C:\inetp ...
13>+                                                                  ~
13>[0m[91mMissing ] at end of attribute or type literal.
13>[0m[91mAt line:1 char:78
13>+ ... ce = 'SilentlyContinue'; [C:\inetpub\wwwroot\AspNetMVC3Setup.exe, /q]
13>Unexpected token ':\inetpub\wwwroot\AspNetMVC3Setup.exe' in expression or
13>At line:1 char:115
13>+ ... ce = 'SilentlyContinue'; [C:\inetpub\wwwroot\AspNetMVC3Setup.exe, /q]
13>+                                                                     ~
13>Missing argument in parameter list.
13>    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
13>   ception
13>[0m[91m    + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfAttribute
13>Service 'adminmanagement' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ["C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]' returned a non-zero code: 1

13>Step 5/5 : RUN ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]
13> ---> Running in 44113a1005d2
13>[91mUnable to find type [powershell.exe,C:\inetpub\wwwroot\AspNetMVC3Setup.exe,
13>/q]. Details: The given assembly name or codebase was invalid. (Exception from
13>HRESULT: 0x80131047)
13>At line:1 char:76
13>[0m[91m+ ... yContinue'; [powershell.exe, C:\inetpub\wwwroot\AspNetMVC3Setup.exe,  ...
13>[0m[91m+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13>    + CategoryInfo          : InvalidOperation: (powershell.exe,...C3Setup.exe
13>   , /q:TypeName) [], ParentContainsErrorRecordException
13>[0m[91m    + FullyQualifiedErrorId : TypeNotFoundWithMessage
13>Service 'adminmanagement' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ["powershell.exe", "C:\inetpub\wwwroot\AspNetMVC3Setup.exe", "/q"]' returned a non-zero code: 1
asked on Stack Overflow Jun 5, 2018 by S.Quid • edited Jun 5, 2018 by S.Quid

1 Answer


I could not get this to work within Visual Studio but by using a very similar dockerfile, a change to the .dockerignore and by invoking docker directly from PowerShell, I was able to have MVC 3 installed during the container build.


# escape=` (backtick)

FROM microsoft/aspnet:4.7.1-windowsservercore-1709
COPY ./bin/Release/Publish/ /inetpub/wwwroot
RUN C:\inetpub\wwwroot\AspNetMVC3Setup.exe /q

.dockerignore file:


The change to the .dockerignore was to add the following:


Docker commands:

docker build -t [imagename] .
docker run -d --name [containername] [imagename]
answered on Stack Overflow Jun 6, 2018 by S.Quid

User contributions licensed under CC BY-SA 3.0