Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folder not being copied to Output directory

I have the following on an ASP.NET Core 3.1 csproj file:

  <ItemGroup> 
    <Content Include="webroot\**"> 
      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
    </Content> 
  </ItemGroup>

  <Target Name="Approot" BeforeTargets="BeforeBuild;BeforePublish">
    <Exec WorkingDirectory="approot" Command="npm install" />
    <Exec WorkingDirectory="approot" Command="npm run build --prod" />
  </Target>

I am building a Client application in approot folder and saving the result to webroot folder.

I need the webfoot folder to be copied to the Output directory ...

Problem

When I build it files are placed on webfoot folder but it is not copied to the Output.

So I need to rebuild it again so that webroot folder is copied to the Output ...

It seems that the 2 npm commands are being ran after the Build but I am using BeforeBuild.

like image 788
Miguel Moura Avatar asked Mar 04 '23 01:03

Miguel Moura


1 Answers

Try this

  <ItemGroup>
    <None Include="wwwroot\**">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
like image 71
Ramana Reddy Avatar answered Mar 10 '23 12:03

Ramana Reddy