1

I've launched my first APS.NET Core app (Visual Studio for Mac) inside Docker (for Linux), but for some reason CSS is not applied and also JS is not firing.

Looks like it it's not finding wwwroot folder?

Any help is appreciated!

Dockerfile contents:

FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY ./MyWealth.csproj MyWealth/
RUN dotnet restore MyWealth/MyWealth.csproj
WORKDIR /src/MyWealth
COPY . .
RUN dotnet build MyWealth.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish MyWealth.csproj -c Release -o /app

RUN cp ./MyWealth.sqlite /app/MyWealth.sqlite

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyWealth.dll"]
1
  • 2
    Can you please add your Dockerfile Commented Feb 5, 2019 at 6:38

1 Answer 1

2

Mention wwwroot in the csproj file to include the folder to output directory.

<ItemGroup>
  <Content Include="wwwroot\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Sign up to request clarification or add additional context in comments.

1 Comment

You should be CAREFUL with that. If you edit csproj like this, you can mess up file & folder structures. First of all, you don't need ".json" configuration files from wwwroot. Second, some projects have "node_modules" - you don't need them too for production environment ( only bundled css and js files will be needed. ). An IDE analyzer will be slow down if you want to add all files from wwwroot. So, backup your whole solution ( just zip it to another folder ) before edit csproj. Don't "copy-paste" everthing what you see. You can just include your needs like Include="wwwroot\bundles*" etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.