Ignore Directory in MSDeploy and MSBuild

跟風遠走 提交于 2020-01-15 20:17:23

问题


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.

There is a directory within the website that needs to be ignored by both WebDeploy and MSBuild because it breaks the site.

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.

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?

Update

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.

回答1:


You want to apply a skip rule so that the directory is ignored by the synchronisation process completely.

Add this to your .pubxml file:

<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>


来源:https://stackoverflow.com/questions/32728732/ignore-directory-in-msdeploy-and-msbuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!