Geta / geta-notfoundhandler

The popular NotFound handler for ASP.NET Core and Optimizely, enabling better control over your 404 page in addition to allowing redirects for old URLs that no longer works.
Apache License 2.0
19 stars 16 forks source link

Problem with copying zip file on build #91

Open karl-sjogren opened 1 year ago

karl-sjogren commented 1 year ago

I'm very often seeing problems like this when running my site and for example trying to run a quick unit test at the same time (starting the site takes forever so I like to keep it running in the background).

/Users/karl/.nuget/packages/geta.notfoundhandler.optimizely/5.0.6/build/net6.0/Geta.NotFoundHandler.Optimizely.targets(9,9): warning MSB3026: Could not copy "/Users/karl/.nuget/packages/geta.optimizely.contenttypeicons/2.0.2/build/net5.0/../../contentFiles/any/any/modules/_protected/Geta.Optimizely.ContentTypeIcons/Geta.Optimizely.ContentTypeIcons.zip" to "/Users/karl/src/projectname/projectname.web/src/projectname.Web.Optimizely/modules/_protected/Geta.Optimizely.ContentTypeIcons/Geta.Optimizely.ContentTypeIcons.zip". Beginning retry 1 in 1000ms. The process cannot access the file '/Users/karl/src/projectname/projectname.web/src/projectname.Web.Optimizely/modules/_protected/Geta.Optimizely.ContentTypeIcons/Geta.Optimizely.ContentTypeIcons.zip' because it is being used by another process.

It then retries a few times and then fails the build.

This is at the bottom a problem with Optimizely locking the module zip files during runtime but getting that changed seems lika huge task.

I think that an easy workaround could be implemented here: https://github.com/Geta/geta-notfoundhandler/blob/ca1f3730af6cdbdd797cc2c0d541143216e1acc5/src/Geta.NotFoundHandler.Optimizely/msbuild/CopyModule.targets#L9-L12

If the Copy task had SkipUnchangedFiles specified it would hopefully just to a quick check and see that the files are unchanged and skip copying the file each and every time.

I could try this out and submit a PR if it sounds interesting.