1

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.
Bill Heitstuman
  • 979
  • 1
  • 8
  • 23
  • What do you mean by "when called from WebDeplay"? Are you referring to msdeploy.exe? – Richard Szalay Sep 22 '15 at 23:38
  • I click "Publish Web Site" from the Solution Explorer, it launches Publishing dialog box. When I click publish, it calls MSDeploy which calls MSBuild. – Bill Heitstuman Sep 22 '15 at 23:55
  • Gotcha. For the record, it's actually the other way around: MSBuild calls MSDeploy - MSDeploy has no dependency on MSBuild. – Richard Szalay Sep 23 '15 at 01:38
  • Ah, ok, good to know. So why does MSBuild work when I click "Build Solution" and fail when I click "Publish Web Site"? – Bill Heitstuman Sep 23 '15 at 16:38
  • Because building the project doesn't try to copy the files anywhere. Publishing your project copies the files to a temporary location before packaging/deploying them. – Richard Szalay Sep 24 '15 at 01:38

1 Answers1

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>
Community
  • 1
  • 1
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237