Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include custom folders when publishing a MVC application?

I have an "Uploads" folder with logos within in. I would like the VS2012 one-click publish to include this folder. Currently it is not.

How can I achieve this?

like image 750
SamJolly Avatar asked Sep 03 '13 21:09

SamJolly


People also ask

How can add area folder in MVC?

Add MVC Area with Visual StudioIn Solution Explorer, right click the project and select ADD > New Scaffolded Item, then select MVC Area. Areas are an ASP.NET feature used to organize related functionality into a group as a separate namespace (for routing) and folder structure (for views).

Which folder in an MVC application contains the style definition files?

This folder contains all the static files, such as css, images, icons, etc. The Site. css file inside this folder is the default styling that the application applies.


3 Answers

I did this for a web api project (not dot net core) which had Angular 6 as a front end. My visual studio version was 2017.

I had created a wwwroot folder where I was compiling angular files via custom build action & this folder was not included in my project.

I edited the project file & added these lines.

<PropertyGroup>
    <PipelineCollectFilesPhaseDependsOn>
    CustomCollectFiles;
    $(PipelineCollectFilesPhaseDependsOn);
  </PipelineCollectFilesPhaseDependsOn>
  </PropertyGroup>

  <Target Name="CustomCollectFiles">
    <Message Text="Inside of CustomCollectFiles" Importance="high" />
    <ItemGroup>
      <_CustomFiles Include="wwwroot\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>wwwroot\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
like image 133
Abdul Rehman Sayed Avatar answered Oct 26 '22 00:10

Abdul Rehman Sayed


I believe you need to set the folder's "Build Action" to "Content":

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

like image 24
Cloud SME Avatar answered Oct 25 '22 23:10

Cloud SME


I tried all solutions above, but none of them worked. I'm using VS2017 and wasn't able to folder publish some help files. I edited the project file (.csproj) and added the following lines somewhere in de file.

<ItemGroup>
    <Content Include="HelpFiles\**\*" />
</ItemGroup>

When I push the publish button all my help files are copied to the publish directory.

like image 28
DaanH Avatar answered Oct 25 '22 23:10

DaanH