This is the standard copyzipfiles.target in our modules.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\contentFiles\any\any\modules\_protected\**\*.zip"/>
</ItemGroup>
<Target Name="CopyZipFiles" BeforeTargets="Build">
<Copy
SourceFiles="@(SourceScripts)"
DestinationFolder="$(MSBuildProjectDirectory)\modules\_protected\%(RecursiveDir)"
/>
</Target>
</Project>
If you restructure your project as a Razor Class Library, then you don't need to worry about build scripts for creating zip files and defining where files go. The compiled DLL is all that is needed and that packages up so easily.
Feel free to look at the solution for my package: https://github.com/GeekInTheNorth/Stott.Optimizely.RobotsHandler
Thanks Mark Hall, but that's almost exactly what I had.
I changed my target-file to exactly what you suggested, and it still only works locally. The file does not get added to the published artifact when I build using Azure Devops.
Thanks Mark Stott!
My project were already a Razor Class Library, and the contents of my zip file weren't used. I used it to generate the URL to my module, and I was under the misconception that it was neccessary to get the correct routes to embedded views and recourses. Even if I tried to remove it earlier, but did not succeed. It turned out I did not need it at all!
Now I were able to delete and simplify some code - and get rid of all the copying magic.
Thanks a lot!
I like to start out small, and work from there. So first I upgraded one add-on without UI and without any settings - it worked out great. Then I upgraded another add-on, still without any UI, and still no problems.
The problems
The problems started when I tried to upgrade this addon with UI to CMS 12. It works on my machinetm, but when I deploy my site with the addon to Azure, it does not. Locally it works on an Alloy site (both .NET5 and .NET6 and my personal blog .NET6)
The current code: https://github.com/tomahg/Gulla.Episerver.SqlStudio
The NuGet: https://www.nuget.org/packages/Gulla.Episerver.SqlStudio/2.0.10
After a while, I reallized that I need this zip-file with the same name as my module, containing nothing but module.config
This is needed for the controller and view to be recognized, and for this part of the
MenuProvider
...and maybe also the embedded resouces.
If I do nothing special, the module folder will not be created. In order to fix this I added the file
msbuild/CopyModule.targets
After build, it will copy the zip-file (and a license file) to the module directory. This works fine locallly (on my machine).
When I build&deploy using Azure DevOps, and deploys my site (with the addon) to an Azure WebApp (.NET 6 running on Linux) the zip-file is NOT included. My yaml definition that does not include the zip file (but strangely includes zip files for other modules).
In order to include the zip-file in the deploy, when I deploy the site using the addon I am currently including this in my prosject file, as mentioned in my readme file.
This should not be neccessary - but how can I fix it? Any suggestions?
I have read this blog post by Valdis, I have looked at the Geta notfoundhandler aand Geta sitemaps - but I cannot understand what I'm doing wrong.