Skip to content

ASP Net Core don't follow project build rules when running Publish on a web project #19212

@Sausbolle

Description

@Sausbolle

Describe the bug

When using the following build rule in the .csproj file

  <ItemGroup>
    <None Include="wwwroot\test\**\*.placeholder" CopyToOutputDirectory="PreserveNewest" />
    <None Include="test\**\*.placeholder" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

When building normal (dotnet build -c Debug) the rule is adhered to and only includes the ‘.placeholder’ files from those directories.

But when doing an Publish (dotnet publish -c Release) the wwwroot\test\**\*.placeholder rule is ignored and treated as wwwroot\test\** instead. The test\**\*.placeholder rule is adhered to as it is suppose to when running Publish, so it seams like this is something that only affects rules set on the wwwroot directory (not that I have explored it too much).

To Reproduce

  • Create an ASP NET Core Web app and create the directories
    ./wwwroot/test
    ./test
  • In these two directories add some subdirectories with a blak file named .placeholder and a random other file.
  • Edit the project file adding the above <ItemGroup>
  • Compile debug (dotnet build -c Debug)
  • Compile release (dotnet publish -c Release)
  • In the /bin/Debug/netcoreapp3.1/wwwroot/test/subdir you will only find the .placeholder
  • In the /bin/Release/netcoreapp3.1/publish/wwwroot/test/subdir you will find all the files that were in ./wwroot/test/subdir

Further technical details

  • ASP.NET Core version 3.1.101
  • Include the output of dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.101
 Commit:    b377529961

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version
    Microsoft Visual Studio Community 2019 Version 16.4.5

  • Test project
    BugTest_Publish_Web.zip

Note: I initially created a bugreport in the Developer Community, but thought this perhaps were more appropriate place

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions