42p1iw
Last Updated: February 25, 2016
·
2.31K
· iondrimba
178548

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--

<CopyAllFilesToSingleFolderForPackageDependsOn>
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>

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

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

Say Thanks
Respond