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

查看:93
本文介绍了如何仅将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 Task.这是我的测试,您可以参考.

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定义目标,移动任务,然后将其放置在发布配置文件中的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天全站免登陆