Search code examples
c#.net-corepublish

.NET Core publish folders in wrong location


My project is split up in several smaller libraries each doing it's own part (one for the views, one for some logic, ...)

This all gets loaded and initialized in main-project.csproj.

When debugging, every screen is loaded correctly.

However when I publish the folder is not generated as expected. I'm using the following publish command:

dotnet publish ..\..\main-project.csproj -r win10-x64 -c Release -o publish\

Release folder main-project:

win10-x64/
├─ Properties/
│  ├─ launchSettings.json
├─ Views/
│  ├─ _ViewStart.cshtml
│  ├─ ...
├─ wwwroot/
│  ├─ favicon.ico
│  ├─ ...
├─ some.service.exe
├─ some.service.dll
├─ ...

Published folder

publish/

├─ wwwroot/
│  ├─ _content/
│  │  ├─ ClientService/
│  │  │  ├─ favicon.ico
│  │  │  ├─ ...
├─ some.service.dll
├─ some.service.exe
├─ ...

As you can see, the Views and Properties folders are missing, and my wwwroot folder has several subfolders generated.

I have no idea on how to resolve this. So any suggestions are more than welcome


Solution

  • Problem was resolved by including the following in the library project:

    <PropertyGroup>
        <StaticWebAssetBasePath Condition="$(StaticWebAssetBasePath) == ''">/</StaticWebAssetBasePath>
    </PropertyGroup>
    

    https://stackoverflow.com/a/59574845/1229158