0

I am using Visual Studio Community:

Microsoft Visual Studio Community 2019
Version 16.4.5
VisualStudio.16.Release/16.4.5+29806.167
Microsoft .NET Framework
Version 4.8.03752

I have a very simple ASP.Net Core website / app project, with the following directory structure:

website
 /bin
 /www
     /about
     /images

NOTE: The webroot directory is NOT wwwroot, but instead just www

The project file (.csproj) contains the following (to copy all sub-directories/files to the output directory):

   <ItemGroup>
      <Content Update="www\**\*">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </Content> 
   </ItemGroup>

Using Visual Studio (Config = Debug)

   BUILD -> Rebuild Solution

Result:

/bin
    /Debug
          /netcoreapp3.0
                        /Properties
                        /runtimes

(missing /www and all sub-directories and files!) - WHY???

The same results are obtained if I use msbuild.exe from the developer command prompt; makes no difference with regard to configuration (Debug vs Release).

I assumed that the www directory (and all sub-directories) and files would be copied to the output directory -- but clearly, this is not happening. I do not understand why the CopyToOutputDirectory is being ignored; I am missing something, but a search of the documentation did not yield any answers.

Any ideas / advice would be appreciated.

Thanks in advance.

bdcoder
  • 3,280
  • 8
  • 35
  • 55

1 Answers1

0

Update:

Just changed the following in the project (.csproj) file:

   <ItemGroup>
      <Content Update="www\**\*">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </Content> 
   </ItemGroup>

To:

   <ItemGroup>
      <None Update="www\**\*">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </None> 
   </ItemGroup>

Using Visual Studio: BUILD -> Rebuild Solution (success)

Also tried with msbuild.exe (success)

Now the www directory and all sub-directories / files are present in the output -- why? I suspect because I am not using the default "wwwroot" as the content directory, using <Content> does not work whereas <None> does; but that is only a theory; all I know is it works.

Also found this SO link useful in describing the differences between <Content> and <None>, for those who are curious:

What are the various "Build action" settings in Visual Studio project properties and what do they do?

bdcoder
  • 3,280
  • 8
  • 35
  • 55