How to deploy a specific folder as a package

Viewed 1439

I have an asp.net MVC project and front-end which build via npm command.

and provide app folder after the build. enter image description here

This folder does not include to my csproj file.

When i deploy from teamcity, im use 2 steps.

  1. publish application
  2. FTP deployment for /app folder (each file separately)

But ftp deployment very very slow. How can I deploy this folder as 'package'?

Perhaps I can dynamically include it to csproj file, or something else?

1 Answers

But ftp deployment very very slow. How can I deploy this folder as 'package' ?

Indeed, FTP deploy a folder with many files will be slower. Because it only open a single thread, and only uploads a single file at a time. You can consider zip that folder by a MSBuild target:

  <ItemGroup>
    <Content Include="app\**\*.*" />
  </ItemGroup>

  <Import Project="..\.build\MSBuild.Community.Tasks.Targets" />

  <Target Name="AfterBuild">
    <PropertyGroup>
      <ZipPackagePath>bin</ZipPackagePath>
    </PropertyGroup>
    <Zip Files="@(Link)" WorkingDirectory="$(ZipPackagePath)" ZipFileName="output\ZipName.zip" ZipLevel="9" />
  </Target>

Note: You need add the nuget package "MSBuildTasks" and you can change the ReleasePath to other folder.

But you still need to unzip that zip file after FTP deploy.

Perhaps I can dynamically include it to csproj file, or something else?

Alternatively, you can dynamically include it to your project file and it is what we recommendation.

To accomplish this, unload your project. Then at the very end of the project, just before the end-tag, place below scripts:

  <Target Name="AddAppFiles" AfterTargets="Build">
    <ItemGroup>
      <Content Include="app\**\*.*" />
    </ItemGroup>
  </Target>

After publishing, the app folder is included in the target location:

enter image description here

Note:

  1. With this target, the folder app does not appear in the Solution Explorer(dynamically include).

  2. If the app folder is generated after building complete, you can change the AfterTargets="Build" to BeforeTargets="_CheckForInvalidConfigurationAndPlatform", like:

<Target Name="AddAppFiles" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">

Related