如何仅将 dist 文件夹部署到 azure 网站? [英] How to only deploy dist folder to azure web site?

查看:19
本文介绍了如何仅将 dist 文件夹部署到 azure 网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 azure 网站项目中有 src 文件和 dist/文件夹.

I have src files and dist/ folder in my azure website project.

project
 |- src/
 |- dist/

默认行为会上传项目内的所有文件,即 src 和 dist.

The default behavior uploads all the files inside of the project, i.e. both src and dist.

website
|- src/
|- dist/

我想保持网站干净,只包含 dist 文件.

I want to keep the website clean, only with dist files in it.

website
|- dist/

如果我能把 dist 文件夹映射到网站上就更好了.

It would be even better if I can map the dist folder to the website.

website
|- all the files
|- in dist folder

我该怎么办?

我知道我只能通过右键单击文件夹然后发布"来发布一个特定的文件夹.但该网站还包含一些需要部署的 bin/文件夹中的 dll.

I know I can only publish one specific folder by right-clicking on the folder and then "publish". But the website also consists of some dlls in bin/ folder which need to be deployed.

我尝试创建一个单独的 azure 网站项目,该项目仅包含 dist 文件夹,但我不知道如何在部署中包含来自 src 项目的 dll.

I tried to create a separate azure website project which only holds the dist folder but I have no idea how to include the dlls from src project in deployment.

推荐答案

根据您的要求,我假设您可以在将网站部署到 Azure 之前修改发布配置文件并添加一些 MSBuild 任务.这是我的测试,你可以参考一下.

According to your requirement, I assumed that you could modify your publish profile and add some MSBuild Task before you deploying your website to Azure. Here is my test, you could refer to it.

项目结构

修改您的发布配置文件

您可以使用 RemoveDir、Move 任务定义一个 Target 并将其放在您的发布配置文件中 PropertyGroup 之后,如下所示:

You could define a Target with RemoveDir, Move tasks and put it after PropertyGroup in your publish profile as follows:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="MoveDistToRoot" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
    <!--1.Deleting Folders except dist-->
    <ItemGroup>
      <_FolderToDelete Include="$(_PackageTempDir)src" />
      <!--you could add more folder paths as follows:-->
      <!--<_FolderToDelete Include="$(_PackageTempDir)folderName" />-->
    </ItemGroup>
    <RemoveDir Directories="@(_FolderToDelete)" />

    <!--2.Copying files,folders from dist to root directory-->
    <ItemGroup>
      <_FileToMove Include="$(_PackageTempDir)dist**" />
    </ItemGroup>
    <Move SourceFiles="%(_FileToMove.Identity)" DestinationFolder="$(_PackageTempDir)\%(RecursiveDir)" />

    <!--3.Deleting the empty folder dist-->
    <RemoveDir Directories="$(_PackageTempDir)dist" />
  </Target>

</Project>

更改后,您可以使用修改后的发布配置文件将您的网站部署到 Azure Web App,并尝试通过 KUDU 检查您在 Azure 上的 Web 应用程序的结构.

Upon the changes, you could deploy your website to Azure Web App with the modified publish profile and try to check the structure of your web app on Azure via KUDU.

这篇关于如何仅将 dist 文件夹部署到 azure 网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆