问题
I have src files and dist/ folder in my azure website project.
project
|- src/
|- dist/
The default behavior uploads all the files inside of the project, i.e. both src and dist.
website
|- src/
|- dist/
I want to keep the website clean, only with dist files in it.
website
|- dist/
It would be even better if I can map the dist folder to the website.
website
|- all the files
|- in dist folder
What should I do?
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.
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.
回答1:
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.
Project structure
Modify your publish profile
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>
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.
来源:https://stackoverflow.com/questions/40901842/how-to-only-deploy-dist-folder-to-azure-web-site