我已经为此苦苦挣扎了一段时间了,我觉得我肯定想念一些明显的东西...
我们正在使用Visual Studio 2015,Typescript,angular,bower,grunt等编写Web应用程序。该项目将所有HTML,SASS和Typescript文件构建到目录www
,该目录可部署到Web服务器。
生成的项目结构如下所示(在括号中生成/复制的文件):
OurProject/
bower_components/
node_modules/
typings/
source/
index.html
...lots of .ts, .sass and .html files
www/
js/
(...javascript libraries...)
(index.html)
(app.min.js)
(app.min.css)
当我们这个项目部署到Azure的我们的网站,我想看到的结构如下:
OurProject.azurewebsites.net/
js/
...various libraries...
index.html
app.min.js
app.min.css
但是我们实际上得到的是-即整个项目树,包括源代码,构建工具等:
OurProject.azurewebsites.net/
bower_components/
node_modules/
typings/
source/
index.html
...lots of .ts, .sass and .html files
www/
(index.html)
(app.min.js)
(app.min.css)
这样做的缺点是
必须有一种方法可以告诉Visual Studio 2015发布引擎“仅发布www子目录”-但是有人可以告诉我如何做吗?
我尝试遵循Sayed Hashimis博客上的食谱,描述了如何在部署中包括和排除选定的文件和目录。
除了需要手动编辑未记录的pubxml功能外,这仍不能解决“尴尬的登录页面”问题。
并且,每当您向项目添加新目录时,都必须更新排除列表。
一种解决方案是添加一个引用OurProject / www /目录的网站项目(“添加现有网站...”):
OurSolution/
OurProject/
bower_components/
node_modules/
typings/
source/
index.html
...lots of .ts, .sass and .html files
www/
js/
...various libraries...
(index.html)
(app.min.js)
(app.min.css)
WebSiteProject (references existing web site ..\OurProject\www)/
js/
...various libraries...
index.html
app.min.js
app.min.css
然后可以将该项目(WebSiteProject)部署到Azure,以产生所需的结果。
但这似乎是实现简单目标的一种非常round回的方式...
根据您的要求,我做了一些测试。 我可以将subdir中的内容部署到Azure Web App的根目录,请按照以下步骤操作:
编辑您的发布配置文件,添加一些MSBuild任务,然后再部署到Azure。 您可以使用RemoveDir定义目标,移动在CopyAllFilesToSingleFolderForMsdeploy之后执行的任务,然后将其放置在发布配置文件中的PropertyGroup之后。 以下是详细的代码,您可以将其复制并粘贴到您的发布配置文件中。
<Target Name="DeploySubFolder" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
<!--1.Deleting Folders except www-->
<ItemGroup>
<_FolderToDelete Include="$(_PackageTempDir)\bower_components" />
<_FolderToDelete Include="$(_PackageTempDir)\node_modules" />
<_FolderToDelete Include="$(_PackageTempDir)\source" />
<_FolderToDelete Include="$(_PackageTempDir)\typings" />
</ItemGroup>
<RemoveDir Directories="@(_FolderToDelete)" />
<!--2.Copying files,folders from www to root directory-->
<ItemGroup>
<_FileToMove Include="$(_PackageTempDir)\www\**" />
</ItemGroup>
<Move SourceFiles="%(_FileToMove.Identity)" DestinationFolder="$(_PackageTempDir)\%(RecursiveDir)" />
<!--3.Deleting the empty folder www-->
<RemoveDir Directories="$(_PackageTempDir)\www" />
</Target>
使用修改后的发布配置文件将Web应用程序部署到Azure。
通过KUDU在Azure Web App中检查Web应用程序的结构