【问题标题】:How to extend the Visual Studio web publish pipeline?如何扩展 Visual Studio Web 发布管道?
【发布时间】:2015-02-02 22:25:09
【问题描述】:
我想调整 Visual Studio 如何将网站发布到包,通常包是通过在 中提取整个文件列表来创建的>根目录,编译,优化等等。
就我而言,问题是我正在使用 angular.js 和 Grunt 开发 SPA 以 build(优化)app,任务被配置为将站点的“优化”版本放入位于根文件夹下方的“dist”,这是使用 grunt 的此工作流的典型场景。
这些是场景的详细信息,
文件夹结构如下:
- /根
- bower_components
- 模块1
- 指令
- 部分
- /page1
- page1.html
- page1.js
- page1.less
- page1.spec.js
- 模块2
- 模块3
- 等等等等等等
在 Grunt build 之后,我得到了这样的优化版本
- /根
- bower_components
- 模块1
- 模块2
- 模块3
-
dist
- bower_components
- app.min.js
- app.min.css
- index.html
我想要包进行如下部署:
- /根
- 库(dll)
- bower_components
- app.min.js
- app.min.css
- index.html
我知道有一个.pubxml文件配置,是否可以通过修改这个文件来实现?
【问题讨论】:
标签:
visual-studio-2013
gruntjs
publishing
webdeploy
【解决方案1】:
我刚刚做了自己的研究,我找到了一种方法。
您需要在您的根目录中创建一个 wpp.targets 文件,例如名称应该是 [projectName].wpp.targets。
然后在文件中,您需要使用以下说明设置 msdeploy:
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildDependsOn Condition="'$(Configuration)' == 'Release'">
gruntBuild
</BuildDependsOn>
<ExcludeFoldersFromDeployment>
foldername1, foldername2
</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>
filename.extension, filename2, filename3, etc
</ExcludeFilesFromDeployment>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<!--
you can try to run the grunt build for me it takes too long and the visual studio just gets freeze so I run the grunt task before doing the deploy, but it's up to you
<Target Name="gruntBuild">
<Message Text="=== buil on publish ===" Importance="high" />
<ItemGroup>
<Binaries Include="*.dll;*.exe"/>
</ItemGroup>
<Exec Command="bower install" />
<Exec Command="grunt build" />
</Target>-->
<Target Name="CustomCollectFiles">
<Message Text="=== CustomCollectFiles ===" Importance="high" />
<ItemGroup>
<CustomFiles Include="dist\**\*.*" />
<FilesForPackagingFromProject Include="%(CustomFiles.Identity)">
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>