Lion
Lion

Reputation: 17898

"The directory name /app/Views/ is invalid" on ASP.NET Core deployment using docker

I followed this article to setup a performant ASP.NET Core deployment using Docker. This works until I try to start the container using docker run which calls dotnet MyAppName.dll There I got an exception, that the View path is not existing:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The directory name /app/Views/ is invalid.

And thats true, cause in the folder created by dotnet publish area only dll files and no View folder:

user@server:/etc/jenkins/workspace/App# ll publish-output | grep View
-rwxr--r-- 1 root root 237K Aug 31 19:26 Microsoft.AspNetCore.Mvc.ViewFeatures.dll

I cant understand this, cause the View folder is included in the publishOptions like wwwroot too, which is also missing:

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views/**/*.cshtml",
      "Areas/**/*.cshtml"
    ]
  },

I also tried "Views" instead of "Views/**/*.cshtml" but not working. In my understanding, those publishOptions should result in copying those folders to the publishing-directory when using dotnet publish.

What am I doing wrong?

I'm using the microsoft/aspnetcore-build:1.0.1 image for building and microsoft/aspnetcore:1.0.1 for starting the app like recommended as best practice in the article.

UPDATE Seems to be a problem on linux only. My Win10 development machine works fine, there I get any view-folders published from the main app and areas as expected.

UPDATE #2 Using the examples on the aspnetcore-build repo on the docker hub, its not working too.

UPDATE #3 I created a new ASP.NET Core MVC project on my Windows 10 development machine using Visual Studio, then transferred it to the linux box: Not working, the views are missing.

UPDATE #4 Created a new app using dotnet new -t web directly on the linux box: Works like expected!

UPDATE #5 I ran dotnet new -t web on the Windows machine, moved the created folder to the linux server: Not working - Strange...

Upvotes: 0

Views: 933

Answers (1)

Lion
Lion

Reputation: 17898

The problem was a missing space in the documentation before the dot, which should refer the current folder.

Wrong (1:1 copy from the description of the docker image)

RUN dotnet publish --output /out/. --configuration Release

Correct

RUN dotnet publish --output /out/ . --configuration Release

Here is the space missing: --output /out/{Space}.

Upvotes: 1

Related Questions