richardszalay / helix-publishing-pipeline

Unified publishing for Sitecore Helix solutions that extends existing Visual Studio and command line workflows
MIT License
68 stars 18 forks source link

AdditionalFilesToRemoveFromTarget feature doesn't work when publishing from VS #61

Closed rkeitel closed 5 years ago

rkeitel commented 5 years ago

This feature doesn't appear to remove any files from the web root. See issue 52.

I'm using version 1.5.4 of HPP. The publishing target is the local file system. The VS project uses package references. DeleteExistingFiles is set to false. EnablePackageProcessLoggingAndAssert is set to true, but the log file AdditionalFilesToRemoveFromPublish.txt is not created in obj\Release\Package\Logs.

richardszalay commented 5 years ago

Is your profile's publishUrl a file path or a web address? The feature is implicitly only supported if it's a file path

rkeitel commented 5 years ago

The publishUrl is a file path.

richardszalay commented 5 years ago

Argh, you're killing me 🤣

I'll try to take a look, but if you could create a small repro and email it to me (richard@richardszalay.com) it will make diagnosing/fixing it quicker.

rkeitel commented 5 years ago

I can't create a repo because it is a customer project. But here you have the relevant configuration files: Testsite.zip

richardszalay commented 5 years ago

@rkeitel Thanks for raising this, I can reproduce. For what it's worth, if you enable autopublish you won't hit this problem (which is why I've never seen it before)

For now you can use the following workaround at the end of your Local.pubxml:

<!-- Temporary workaround for https://github.com/richardszalay/helix-publishing-pipeline/issues/62 -->
<Target Name="_CollectAdditionalFilesToRemoveFromTarget"
        Condition="'$(BuildingInsideVisualStudio)' == 'true'"
        DependsOnTargets="CollectAdditionalFilesToRemoveFromTarget"
        BeforeTargets="_CopyWebApplication" />
richardszalay commented 5 years ago

Summary:

When expicitly publishing within VS the IDE's internal optimisations mean that a number of targets don't get run. Since appears to include WebFileSystemPublish, CollectAdditionalFilesToRemoveFromTarget never runs.

I think this hasn't been raised before because autopublish is not affected by it since it runs the targets by name. Still, we should create a new ticket that verifies each of the features when publishing from within VS.

rkeitel commented 5 years ago

Cool, the workaround works great. Thank you very much :-)

richardszalay commented 5 years ago

Excellent. I'll keep this issue open until I release a new version with the fix.

rkeitel commented 5 years ago

I noted another problem. Deleting additional assemblies is working (e.g. <TargetPath>bin\Testsite.Feature.*</TargetPath>), but removing additional configs is still not working (e.g. <TargetPath>App_Config\Include\Feature\**</TargetPath>).

richardszalay commented 5 years ago

I'm not sure if that glob is valid. Have you tried App_Config\Include\Feature\**\*.config?

rkeitel commented 5 years ago

Yes, I tried App_Config\Include\Feature\*.config, but it is not working.

richardszalay commented 5 years ago

App_Config\Include\Feature\*.config won't work unless the files aren't in any subfolders

App_Config\Include\Feature\** won't work because it will only match directories.

Can you try App_Config\Include\Feature\**\*.config ?

rkeitel commented 5 years ago

All files are in App_Config\Include\Feature without subfolders, so App_Config\Include\Feature\*.config should be the right one.

richardszalay commented 5 years ago

Interesting. Ok, let try to reproduce.

richardszalay commented 5 years ago

Even using your original config of App_Config\Include\Feature\** (+ the workaround I posted above), I can't actually reproduce this problem. For me, the extra config files go away when I publish via the VS dialog. I comment out the lines in Local.pubxml and reload the project (which is required, btw) then it stops doing it.

I've attached the sample project I used (which is just Helixbase with your config). Can you try it and see if you can reproduce it?

working.zip

rkeitel commented 5 years ago

You are right. The problem was that my App_Config folder had wrong security permissions. So all problems are solved. Thank you very much :-)

richardszalay commented 5 years ago

Ah good news. I'll close this issue once I've published a new version with the first fix.

richardszalay commented 5 years ago

Included in the v1.5.5 release