Last Updated: February 25, 2016
· iondrimba

Include a folder for deploy in Visual Studio

Suppose you have a build folder for all of your js files. That folder is not part of the solution because its generated via some task runner (grunt/gulp) but you want to publish it.

Go to you YourProject.csproj and edit the file.

Inside the first PropertyGroup node add this tag at the end:

(dont add this)<PropertyGroup>
--content ommited--

JSCustomCollectFiles;        $(CopyAllFilesToSingleFolderForPackageDependsOn);      </CopyAllFilesToSingleFolderForPackageDependsOn>

(dont add this)</PropertyGroup>

Next search for <Target Name="MvcBuildViews" and add this Target node after the MvcBuildViews node.

(dont add this)<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />


<Target Name="JSCustomCollectFiles">
      <_CustomFilesJS Include=".\scripts\build\**\*" />
      <FilesForPackagingFromProject Include="%    (_CustomFilesJS.Identity)">
        <DestinationRelativePath>scripts\build\%    (RecursiveDir)%(Filename)%(Extension)    </DestinationRelativePath>

You could do the same for a CSS build folder by creating a CSSCustomCollectFiles following the steps above.

Have a fresh tip? Share with Coderwall community!

Post a tip