0

I have three ASP.NET Core 7 projects:

  • Common: library project. Other projects depend upon it.
  • Web: razor pages project. Depends on Common.
  • Migrator: console project. Depends on Common, and Web (via ProjectReference) for db contexts, etc. It is used internally only, for migrations and other tasks.
  • All are published as "self-contained" and "single-file".

dotnet publish Migrator.csproj produces:

Pages/                   <-----
  Foo/
    Page1.cshtml
    Page2.cshtml
  Bar/
    Page1.cshtml
  etc...
appsettings.json
Migrator
Web                      <-----
Web.runtimeconfig.json   <-----

The Web project's assets are included in the Migrator project's published output. Note the same does not apply for the Common project's assets (which are contained within the Migrator executable).

I tried to exclude those extra assets in Migrator.csproj:

<ItemGroup>
  <Content Update="Web*.*" CopyToPublishDirectory="Never" />
  <Content Update="wwwroot/**" CopyToPublishDirectory="Never" />
</ItemGroup>

But that does nothing.

How can I exclude those unnecessary assets?

lonix
  • 14,255
  • 23
  • 85
  • 176

0 Answers0