忽略MSDeploy和MSBuild中的目录 [英] Ignore Directory in MSDeploy and MSBuild
问题描述
我有一个使用Visual Studio中的发布网站"功能部署的网站项目.我了解此功能使用WebDeploy(MSDeploy)来调用MSBuild来编译站点.
I have a Web Site project that is deployed using "Publish Web Site" feature in Visual Studio. I understand this feature uses WebDeploy (MSDeploy) which calls MSBuild to compile the site.
网站中有一个目录,WebDeploy和MSBuild都需要忽略该目录,因为它会破坏站点.
There is a directory within the website that needs to be ignored by both WebDeploy and MSBuild because it breaks the site.
我能够配置部署配置文件(.pubxml),以使WebDeploy忽略目录:
I was able to configure the deployment configuration file (.pubxml) to make WebDeploy ignore directory:
<PropertyGroup>
...
<ExcludeFoldersFromDeployment>node_modules</ExcludeFoldersFromDeployment>
</PropertyGroup>
通过将目录隐藏在文件系统中,我还能够使网站得以编译.
I was also able to get the site to compile by making the directory hidden in the file system.
但是,当从WebDeploy调用时,我无法使MSBuild忽略该目录.
However, I am unable to get MSBuild to ignore the directory when called from WebDeploy.
在网站被编译后,如何忽略目录?
How do I ignore the directory anytime the site is compiled?
更新
编译器在失败时将其记录在输出"窗口中:
The compiler logs this in the Output Window when it fails:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.WebSite.Publishing.targets(172,5): Error MSB4018: The "CollectFilesinFolder" task failed unexpectedly.
推荐答案
您要应用跳过规则,以便同步过程完全忽略目录.
You want to apply a skip rule so that the directory is ignored by the synchronisation process completely.
将此添加到您的.pubxml
文件:
<ItemGroup>
<MsDeploySkipRules Include="SkipNodeModules">
<AbsolutePath>node_modules</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
If you run into problems with it not working, you may be seeing this problem. If so, just add:
<PropertyGroup>
<UseMsDeployExe>true</UseMsDeployExe>
</PropertyGroup>
这篇关于忽略MSDeploy和MSBuild中的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!