<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hans Léautaud on Medium]]></title>
        <description><![CDATA[Stories by Hans Léautaud on Medium]]></description>
        <link>https://medium.com/@HLeautaud?source=rss-a3a5f6042e61------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*3bIn99C7aaFIU76Rkl5VHw.png</url>
            <title>Stories by Hans Léautaud on Medium</title>
            <link>https://medium.com/@HLeautaud?source=rss-a3a5f6042e61------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:03:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HLeautaud/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your team should have clearing meetings]]></title>
            <link>https://medium.com/@HLeautaud/your-team-should-have-clearing-meetings-aac430d4713d?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/aac430d4713d</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[team-building]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Tue, 22 Sep 2015 11:10:13 GMT</pubDate>
            <atom:updated>2016-08-15T18:55:42.958Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_F1XFp6Ox3MwBOlu3FqLg.jpeg" /></figure><p>Clearing meetings are all about team building, <em>clearing the air</em> and let team members speak their mind. It is a tool to increase self-organization within your team and to strengthen the relationship between the team members and the team lead.</p><p>I first learned about clearing meetings when I read <a href="https://leanpub.com/teamleader">Notes to a Software Team Leader</a> by <a href="https://twitter.com/RoyOsherove">Roy Oshrove</a>. In this very insightful book Oshrove talks about the different phases teams can live through: from the survival phase, to the learning phase and eventually the self-organizing phase. The underlying goal of the clearing meeting is enabling the team to move to the last stage.</p><h4>What is a clearing meeting?</h4><p>A clearing meeting is a 30 minute weekly meeting with your expertise team (or “chapter”, if you use the <a href="https://vimeo.com/85490944">Spotify terminology</a>). I say expertise team because it is important that all the members have the same lead, which is probably not the case in a result/scrum team (or “squad”).</p><p>The meeting is led by the team lead. A secretary is assigned at the beginning of the meeting and takes notes. Go over last weeks action points briefly and discuss their outcomes to make sure that action points are being tackled.</p><p>After that all attendees should answer the following question:</p><blockquote>“What <em>has not</em> been working for you this past week?”</blockquote><p>Nothing is out of scope and all attendees are obligated to answer this question. There is always something which could’ve gone better. In most cases you’ll probably have some discussion regarding the topic, which is fine. Right after that you ask:</p><blockquote>“What are you going to do about it?”</blockquote><p>It is really important to use <a href="http://www.informit.com/articles/article.aspx?p=1715058">commitment language</a> here. So no “We should look into fixing the build” but “I will sit with John on how to fix the build by next Tuesday”. The idea is to train the team to come up with their own action points and follow up on them before the meeting starts. Handling and fixing your own challenges when they appear is an important part of self-organization.</p><p>After everybody shared their negative experiences of last week and all action points are discussed, the team lead asks all attendees:</p><blockquote>“What <em>has</em> been working for you the past week?”</blockquote><p>Again, everyone has to answer this one. Sharing positive experiences will end the meeting on a positive note and all attendees will leave the room motivated and satisfied instead of irritated and indifferent.</p><p>The team lead will close the meeting and the meeting minutes are shared within a day. It is important that the meeting minutes are confidential, concise and rapidly communicated so that the team can take action as soon as possible.</p><h4>Why should we do these meetings?</h4><p>Oshrove’s book talks about several possible goals:</p><ul><li>To introduce important issues everyone should know about.</li><li>To give everyone the chance to air issues that bother them.</li><li>To create more trust within the team. The team will learn that it is healthy and okay to share frustrations with the rest of the team.</li><li>Increase self-organization. The team will learn to identify things that are not going the way they’re supposed to and act on it.</li></ul><p>While this list is focused on the efficiency and effectiveness of the team I discovered an extra value in these meetings. During the clearing meetings my team and I had for about a year I discovered that the team started to compliment each other on the work done.</p><p>In <a href="https://twitter.com/jurgenappelo">Jurgen Appelo</a>’s <a href="https://management30.com/product/workouts/">#workout</a> and recently published <a href="https://medium.com/@jurgenappelo/the-6-rules-for-rewards-dd989716b744">The 6 Rules for Rewards</a> he reveals what motivates employees the most and three out of six points are related to the clearing meetings my team and I were having:</p><p><strong>Reward publicly, not privately<br></strong>By discussing these matters in group, appreciation is made known for the whole team.</p><p><strong>Reward behavior, not outcome<br></strong>Frequently, someone thanks a team member on their behavior, support or assistance. This might take some encouragement from the team lead.</p><p><strong>Reward peers, not subordinates<br></strong>Team members are giving constructive criticism and compliments to other members.</p><h4>Isn’t that what retrospectives are for?</h4><p>Of course the clearing meeting, as well as the retrospective, is aiming for continuous improvement. However, there are a couple of big differences between clearing meetings and sprint retrospectives.</p><p>First of all the scope of the meeting is different. A sprint retrospective is solely focused on the project at hand while nothing is out of scope in the clearing meeting. As a matter of fact I tried focusing on project unrelated issues to eliminate the overlap completely.</p><p>The goal is also different. A clearing meeting is focused on team building and morale. With a high morale, <a href="https://books.google.nl/books?id=ExAMaApWphcC&amp;lpg=PP1&amp;ots=JeCsuoVItx&amp;dq=employee+morale+and+performance&amp;lr=&amp;hl=nl&amp;pg=PA59&amp;redir_esc=y#v=onepage&amp;q=employee%20morale%20and%20performance&amp;f=false">team members are performing better</a> and they are more productive and innovative. The goal of a retrospective is of course also to increase productivity and velocity but this is approached from a team perspective. It fosters the team performance. The clearing meeting fosters personal performance, which is inherent to a better performance within the team.</p><p>Finally, retrospectives are held by the scrum team. Clearing meetings are held by the expertise team. Talking about issues with fellow backend developers or fellow product owners is different than in a multidisciplinary group. It is in our nature to find pleasure in being around individuals who share the same passion, mind set, opinions or mentality, regardless of the type of <a href="http://www.medicaldaily.com/do-opposites-attract-or-does-attract-relationships-understanding-science-love-276918">relationship</a>. It is okay to embrace that once in a while. Other than that, expertise peers can share knowledge and experiences about true tech-stuff which is hard to share with laymen.</p><p>So at least in my opinion, clearing meetings are a valuable addition to the meeting cycle with your team and it serves a different purpose than the meetings you have in your scrum team. The one does not exclude the other.</p><p>I am curious about your experiences and thoughts on this topic. Please let me know below or let me know on <a href="https://twitter.com/HLeautaud">Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aac430d4713d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up an Azure TeamCity buildagent with Chocolatey]]></title>
            <link>https://medium.com/efocus-collection/setting-up-an-azure-teamcity-buildagent-with-chocolatey-b13e5132ced2?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/b13e5132ced2</guid>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Sat, 15 Nov 2014 11:27:54 GMT</pubDate>
            <atom:updated>2014-11-15T16:34:08.304Z</atom:updated>
            <content:encoded><![CDATA[<p>Adding some Chemical X to the mix</p><p>Yay! TeamCity now supports Azure! The <a href="https://youtrack.jetbrains.com/issue/TW-22119">ticket</a> I submitted two years ago finally got the <em>Fixed</em> status. At <a href="https://twitter.com/eFocus">eFocus</a>, we worked with a virtual machine in the cloud which we configured manually for a few years. A major drawback is that the buildagent is inactive for long periods of time which is costing us money. One A2 VM monthly costs are $110. With an average use of 15%, we’re losing $1122 per year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*VlQLah8KnOloFSFQxU1IGw.png" /><figcaption>Buildagent idle for more than 70 hours</figcaption></figure><p>So yeah, we’re pretty excited. But after reading the documentation of the TeamCity Azure plugin I thought it could be automated a bit more.</p><h3>Chocolatey</h3><p>Have you heard about <a href="https://chocolatey.org/">Chocolatey</a>? If you love NuGet, you’ll love Chocolatey. Their website describes it as:</p><blockquote>“Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind.”</blockquote><p>Let me tell you what it can do for you without reciting the documentation on their website: After installing Chocolatey (which takes about 1 minute) you can, for instance, install skype on your machine with just one line of code:</p><pre>choco install skype</pre><p>Check out the website to see which software and commands are available.</p><p>Chocolatey is therefore a very handy tool for situation where you have to install a lot of software. This is mostly done by hand until now, but this will not be the case for long. <a href="https://github.com/OneGet/oneget#what-is-oneget">PowerShell OneGet</a> is on its way.<br>Because it is still in development, I am going to focus on just Chocolatey for now but eventually it should be possible to switch to OneGet all together.</p><p>So how can Chocolatey help us with using TeamCity with Azure build agents?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Hz04fzUcdIP1GRCETRbDdQ.jpeg" /></figure><p>The <a href="http://blog.jetbrains.com/teamcity/2014/11/introducing-teamcity-azure-plugin-run-builds-in-the-cloud/">blog post</a> announcing this long awaited plugin states that everything should be installed on the Azure VM before you can use it. This is something you could automate! And fortunately among the available Chocolatey packages there is a <a href="http://chocolatey.org/packages/TeamCityAgent">TeamCity buildagent</a>.</p><h3>How does it work?</h3><p>I’ve created a simple PowerShell script which installs Chocolatey first and after that all the software you need to make it possible to run your builds.</p><h4>The script</h4><pre>#install Chocolatey<br>iex ((new-object net.webclient).DownloadString(&#39;<a href="https://chocolatey.org/install.ps1&#39;">https://chocolatey.org/install.ps1&#39;</a>))</pre><p>TeamCity is built on Java, so the buildagent software won’t run without it</p><pre>#without Java, the TeamCity agent can not be started<br>choco install javaruntime -force</pre><p>After Java, the build agent application can be installed. The installer will be fetched from the TeamCity server so it is necessary that the build agent can access it via the <em>serverUrl</em> variable you specified.</p><pre>#building parameters<br>$params = &quot;serverUrl=$serverUrl&quot; #serverUrl is mandatory<br>if($agentDir){<br>    $params = [string]::Concat($params, &quot; agentDir=&quot;, $agentDir)<br>}<br>if($agentName){<br>    $params = [string]::Concat($params, &quot; agentName=&quot;, $agentName)<br>}<br>if($ownPort -ne $null -and $ownPort -gt 0){<br>    $params = [string]::Concat($params, &quot; ownPort=&quot;, $ownPort)<br>}</pre><pre>#install TeamCity build agent<br>choco install TeamCityAgent -force -params &quot;$params&quot;</pre><p>Now you can install all the other software that is required for your buildagent:</p><pre>#install .NET framework<br>choco install DotNet4.5</pre><pre>#install … and so on</pre><p>You can download the PowerShell script <a href="https://www.dropbox.com/s/l0aclblg4hezcnl/startup.ps1?dl=0">here</a>.</p><h4>Running the script</h4><p>Windows offers the ability to run PowerShell scripts on startup.</p><ul><li>Open mmc.exe</li><li>Add/Remove Snap-In: <em>Group Policy Object</em> - <em>Local Computer</em></li><li>Go to <em>Computer Configuration/Windows Settings/Scripts</em></li><li>Open <em>Startup</em> by double clicking</li><li>Place the ps1 file in C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup (just use the <em>Show Files…</em> button)</li><li>Add the script in the Startup Properties window with the following parameters: <em>-NoProfile -ExecutionPolicy Unrestricted -serverUrl “url” -agentDir “folder” -agentName “name” -ownPort 9090</em></li><li>Choose to run the Windows PowerShell scripts first</li></ul><p>Everytime the machine starts, the PowerShell script will run. When software is already installed, Chocolatey will not install it again by default. However I would recommend to only use this solution when you want to create/destroy VM instances in Azure.</p><h3>Future steps</h3><p>Adding a startup PowerShell script to a Azure VM would be awesome. After some research I did not find a solution for that. At this moment you still need to execute a few steps manually and create a VM template. I think the following two options could be a solution for that ‘problem’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*9VFQ8Okh6J18jkuK9NQdqQ.png" /><figcaption>TeamCity buildagent in a Azure Worker Role</figcaption></figure><ul><li>Ability to add a PowerShell startup script when creating a new VM in Azure</li><li>Worker Role support in the TeamCity Azure plugin. You could add the PowerShell script as a <a href="http://msdn.microsoft.com/en-us/library/azure/jj130675.aspx">startup task</a>. There a few more perks with this one, such as auto scaling and costs.</li></ul><p>Nonetheless I think this is a nice solution. Be sure to read the Chocolatey documentation for all features such as installing by packages.config file. Oh, and don’t forget to fund Chocolatey’s <a href="https://www.kickstarter.com/projects/ferventcoder/chocolatey-the-alternative-windows-store-like-yum">kickstarter</a> project if you like it.</p><p>If you have any comments or suggestions, please feel free to leave a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b13e5132ced2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/efocus-collection/setting-up-an-azure-teamcity-buildagent-with-chocolatey-b13e5132ced2">Setting up an Azure TeamCity buildagent with Chocolatey</a> was originally published in <a href="https://medium.com/efocus-collection">eFocus Collection</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating large amounts of content in Sitecore]]></title>
            <link>https://medium.com/sitecore-tips-tricks/migrating-large-amounts-of-content-in-sitecore-fb35a488cba?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb35a488cba</guid>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Fri, 10 Oct 2014 14:37:17 GMT</pubDate>
            <atom:updated>2014-10-10T15:42:13.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Sitecore PowerShell Extensions to migrate 3900 unique content items and their linked media</p><p>Migrating to a new website is never easy. This was also the case for a client of our team at <a href="https://twitter.com/eFocus">eFocus</a>. The previous website was outdated on all facets and had to be drastically updated. New design, new content structure, new Sitecore, new solution architecture. Everything was going to be renewed, except a large portion of the content. The website consists of serveral segments and each segment consists of approximately 3900 content items. Each release one segment is being migrated, preferably fully automated.</p><p>With some help of my colleague <a href="https://twitter.com/Wesz">@Wesz</a> I think I found a pretty cool solution for the challenge.</p><h3>The scenario</h3><p>The old Sitecore instance (let’s call it instance A) and the new one (instance B) do not have a lot of similarities:</p><ul><li>Instance A has a page based structure while instance B has a content based structure. This means that some pages should be transformed into generic content blocks which can be placed on several different pages. This also means that not every template in A exists in B and vice versa</li><li>The content of instance A should not be placed on the exact same location in instance B. The content tree structure in Sitecore is completely different</li><li>Fields from instance A do not have the same name as the fields in instance B</li><li>Instance A has a lot of broken links and missing media items which ideally should be removed from instance B</li><li>Some pages should be excluded from the content migration because they are deprecated</li></ul><p>Some conditions and requirements were:</p><ul><li>A lot of rich text fields have links to other Sitecore items. These links should be fixed when migration to instance B. For example: sitecore/content/site/a/b/c moved to sitecore/content/site/x/y/c. Then all links should point to sitecore/content/site/x/y/c</li><li>News articles are divided by month and year, these folders should be created automatically when a news article is being migrated</li><li>An item can be renamed during migration. For example: sitecore/content/site/a/b/c in instance A will be sitecore/content/site/a/b/d in instance B</li></ul><h3>The approach</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c418lDo5EJcUXQxKXk5Eiw.png" /></figure><p>So… how are we going to achieve that? Creating a package and installing it is obviously not an option. After some brainstorming and sketching up ideas I came to the following approach:</p><p>We use a CSV as input for the script. This CSV contains all the pages that need to be migrated. We load that CSV, get the old serialized Sitecore item from instance A matching the CSV row and import it in instance B. After the item is created we’ll fill in all the fields and fix all the links in the RTE- and link fields.</p><h3>The tools</h3><p>The following tools were needed to help me realizing the approach described before:</p><ul><li><a href="http://sdn.sitecore.net/upload/sitecore6/64/serialization_guide_sc60-64-a4.pdf">Sitecore item serialization</a></li><li><a href="https://marketplace.sitecore.net/en/Modules/Sitecore_PowerShell_console.aspx">Sitecore PowerShell Extensions</a></li><li><a href="http://msdn.microsoft.com/en-us/library/system.management.automation.pscmdlet(v=vs.85).aspx">Custom PowerShell Cmdlets</a></li></ul><p>The script relies mostly on the Sitecore PowerShell Extensions which is a great set of tools. It is built on top of PowerShell so you can use almost everything you already know plus a lot of cool stuff specially made for Sitecore. It also provides developers with a couple of applications in Sitecore such as PowerShell ISE. The ISE gives you the ability to open, save, write and run PowerShell scripts within the Sitecore context.</p><h3>The CSV</h3><p>The script has to have some kind of input to know what to do. It needs to know which page needs to go where and which template it was and needs to be. The file therefore contained the following 4 columns:</p><ul><li>Old URL</li><li>New URL</li><li>Old template GUID</li><li>New template GUID</li></ul><p>We’ll load the CSV using <a href="http://joshclose.github.io/CsvHelper/">CsvHelper</a> and sort the results on the amount of forward slashes in the New URL. Why? Because I can not add an item if I do not have its parent. By sorting the new URL on the amount of forward slashes I can reduce the possibility of trying to import an item without having its parent. We’ll also filter out all duplicates because an item can only be added once.</p><p>As mentioned before, I used PowerShell CmdLets to structure my script. I wanted a clear and readable PowerShell script in Sitecore. Therefore I created CmdLets in c# which could be called from my PowerShell script.</p><pre>$csv = Load-Csv -Path “D:\folder\file.csv”</pre><p>The Load-Csv CmdLet returns a sorted <em>IEnumerable</em> of <em>ContentListCsvModel</em>, which is a custom model containing properties for all columns in the CSV file.</p><pre>for ($i=0; $i&lt;($csv).Count; $i++)<br>{<br>    [ContentListCsvModel]$row = $csv[$i];<br>    if($row -eq $null)<br>    {<br>        Write-Warning &quot;Row is null&quot;<br>        continue;<br>    }<br>}</pre><blockquote>Note: please see <a href="https://medium.com/@adamnaj/thoughts-about-the-gaps-in-either-sitecore-powershell-extensions-or-our-advocacy-of-the-existing-6542374ff39f">adamnaj’s response</a> on this post. You could probably also use <em>Import-Csv</em> or <em>ConvertFrom-Csv</em>.</blockquote><h3>Getting old items</h3><p>When serializing Sitecore items, Sitecore will place them in the exact same hierarchy on your filesystem as they are in Sitecore. Also, the Sitecore tree is almost the same as the construction of the websites URL. So from the old URL I can find the serialized item on my disk.</p><blockquote>Note: I’m using <em>Directory.GetFiles(path, searchpattern)</em> to locate the files. I noticed that sometimes the item was called “item name” and it was saved as “item-name”. With the <em>Directory.GetFiles()</em> method you can use a wildcard and with it you have a better chance of finding your item file.<br>Please also see <a href="https://medium.com/@adamnaj/thoughts-about-the-gaps-in-either-sitecore-powershell-extensions-or-our-advocacy-of-the-existing-6542374ff39f">adamnaj’s response</a> on this post. You could probably also use Get-ChildItem.</blockquote><p>After finding it I can load the item into memory using default Sitecore functionality.</p><pre>var file = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);<br>using (TextReader reader = new StreamReader(file))<br>{<br>    return SyncItem.ReadItem(new Tokenizer(reader));<br>}</pre><p>Deserializing the Sitecore item will result in a <em>SyncItem </em>object, which is a more low level object than the <em>Item </em>object. However, it does what it should in this case: I can get the template id, versions, shared fields, id and name.</p><h3>Creating the items</h3><p>To create an item, Youshould know where to create it (parent), as what to create it (template) and how I should name it. All these parameters are defined in the CSV. I created a <em>Get-ItemPath</em>, <em>Get-ParentPath</em> and <em>Get-ItemName</em> CmdLet to extract the information from the CSV’s new URL.</p><p>I also added functionality that if <em>Get-ItemPath</em> returned <em>null</em> for the new URL, the item would be placed under the old name and new template in a receptacle. This would make it possible for our client to sort those items out manually.</p><pre>if(!$newitempath)<br>{<br>    [string]$newparentitempath = ($receptacle).Paths.FullPath<br>    [string]$newitemname = $fromitem.Name<br>}</pre><p>After all the information is collected, the item can be created.</p><pre>[Sitecore.Data.Item.Item]$toitem = Create-Item —Parent $newparentitempath -Name $newitemname -Template $newitemtemplate -Database $fromitem.DatabaseName</pre><p>Because the PowerShell script runs within Sitecore, you do not have to worry about not having a Sitecore context. Creating an item can therefore be done in the same way you’ve always done it as you can see in this snippet of the <em>Create-Item</em> CmdLet:</p><pre>var db = Factory.GetDatabase(String.IsNullOrWhiteSpace(this.Database) ? &quot;master&quot; : this.Database, true);</pre><pre>var parentItem = db.GetItem(this.Parent);</pre><pre>var existing = parentItem.Children.Where(x =&gt; String.Equals(x.Name, this.Name, StringComparison.CurrentCultureIgnoreCase)).ToList();<br>if(existing.Any())<br>{<br>    //do not add a new item if an item with the same name already exists. This makes it possible to run the script multiple times with changes or additions<br>    return existing.FirstOrDefault();<br>}</pre><pre>using (new SecurityDisabler())<br>{<br>    return ItemManager.CreateItem(this.Name, parentItem, new ID(this.Template));<br>}</pre><blockquote>Note: You could extend the functionality of the <em>Create-Item</em> CmdLet with, for example, automatic creation of month and year folders for news items as I described earlier.</blockquote><p>After we created the new item, we’ll save the old and new item in a <em>Dictionary&lt;SyncItem, Item&gt;. </em>That way we’ll have their relationship and we can easily fix the broken links later on.</p><h3>Mapping fields</h3><p>After creating the items we should populate them with content. A Sitecore item has versions with different content, but also contains shared fields. First we’ll create the different versions. The <em>SyncItem </em>object has a property <em>Versions </em>which is a <em>List&lt;SyncVersion&gt;</em>. Each version has a language in which you should select the new item before adding a version.</p><pre>foreach(SyncVersion version in from.Versions)<br>{<br>    var language = LanguageManager.GetLanguage(version.Language);<br>    var item = database.GetItem(to.ID, language);<br>    using (new SecurityDisabler())<br>    {<br>        var newversion = ItemManager.AddVersion(item);<br>        MapFields(from, newversion, version.Fields);<br>    }<br>}</pre><p>The <em>MapFields</em> method is the same for the shared fields, only instead of <em>version.Fields</em>, use <em>from.SharedFields</em>.</p><h4>Discrepancies between fields</h4><p>As I mentioned before, the instance A templates can differ from the instance B templates. To fix that, I created mapper functionality to let my code know how the fields should be mapped.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*BrFQSCZdKoKdyfaQ_dPOhA.png" /></figure><p>Every template combination (old template, new template) has a mapper object implementing a <em>IMapper</em> interface and are placed in a <em>List&lt;IMapper&gt;</em>. A Mapper has a dictionary of old- and new fieldnames which will be used to map the fields.</p><p>We’ll loop through the fields of the from item, find a match in the mapper and fill the to field. This is what it looks like in short:</p><pre>foreach (SyncField field in from.Fields)<br>{<br>    foreach(var fieldmap in mapper.Fields)<br>    {<br>        if(!String.Equals(field.FieldName, fieldmap.Key, StringComparision.CurrentCultureIgnoreCase)) continue;<br>        var tofield = to.Fields[fieldmap.Value];<br>        SetValue(tofield, field.FieldValue);<br>    }<br>}</pre><h4>What about images and such?</h4><p>Setting the value is pretty easy for normal text fields like a single line text, but we want to also set the field value for image fields for instance. The images from instance A are not yet migrated.</p><p>When the <em>tofield.Type</em> is “image” or “file” we’ll parse the field value, find the linked media item, create it and map the fields the same way we’re doing for our content items. This will only create the necessary media items and fix the links immediately.</p><h4>Attachments</h4><p>The attachment field type is used for the media items and should be handled differently to correctly save the blob data.</p><pre>if(field.IsBlobField)<br>{<br>    var buffer = Convert.FromBase64String(value);<br>    var ms = new MemoryStream(buffer, false);<br>    using (new SecurityDisabler())<br>    {<br>        item.Editing.BeginEdit();<br>        field.SetBlobStream(ms);<br>        item.Editing.EndEdit();<br>    }<br>}</pre><h3>Fixing links</h3><p>We’ve now got an instance B with correct items and correct values. Only the links to other items are not migrated yet. This means that all the links in the rich text fields and link fields are pointing to GUIDs from instance A. Essentially what we need is a <em>Dictionary&lt;</em>old <em>GUID, </em>new <em>GUID&gt;</em> rewrite all the guids in the fields.</p><p>To find the links in a RTE, parse the HTML and find the <em>&lt;a href=””&gt;</em>.</p><pre>var document = new HtmlDocument();<br>document.LoadHtml(fieldValue);</pre><pre>var nodecollection = document.DocumentNode.SelectNodes(&quot;//a[@href]&quot;);<br>if(nodecollection == null) return;</pre><pre>foreach(var node in nodecollection)<br>{<br>    var hrefvalue = node.GetAttributeValue(&quot;href&quot;, String.Empty);<br>    var linkedItemId = DynamicLink.Parse(hrefvalue).ItemId.Guid;<br>    //find the guid in the Dictionary&lt;SyncItem, Item&gt;<br>    var item = GetEntryBySyncItemId(dictionary, linkedItemId);<br>}</pre><p>If <em>item</em> is not <em>null</em>, that means that the linked page is migrated and we’ll add the GUIDs to the dictionary. If not, that means that the link is pointing to an item which has not been migrated. The CmdLet will look for that item in the serialized items. If the item is present, the item will be created and the fields will be mapped as done before. Then the guids will be added to the dictionary.</p><p>With that dictionary, we can replace the old GUIDs with the new ones:</p><pre>using (new SecurityDisabler())<br>{<br>    var newvalue = field.Value;<br>    foreach (var l in linkmap)<br>    {<br>        newvalue = field.Value.Replace(i.Key.ToString(&quot;N&quot;).ToUpper(), i.Value.ToString(&quot;N&quot;).ToUpper());<br>    }<br>    item.Editing.BeginEdit();<br>    field.Value = newvalue;<br>    item.Editing.EndEdit();<br>}</pre><h3>Results</h3><p>For 3900 content items (media items excluded) takes about 20 minutes and creates a detailed log of 152401 lines describing everything the script does. I’ve ran the script about 8 times now with changes and works great every time.</p><p>I would’ve loved to share my source code with you, but unforunately I can not do that. I tried my best to clearly explain how I did the migration. If you have any questions about the migration, the code or the tools feel free to leave a comment or contact me on Twitter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb35a488cba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sitecore-tips-tricks/migrating-large-amounts-of-content-in-sitecore-fb35a488cba">Migrating large amounts of content in Sitecore</a> was originally published in <a href="https://medium.com/sitecore-tips-tricks">Sitecore Tips &amp; Tricks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running EPiServer in Azure cloud services]]></title>
            <link>https://medium.com/efocus-collection/running-episerver-in-azure-cloud-services-c652f5f38cbc?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/c652f5f38cbc</guid>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Sun, 21 Sep 2014 20:16:18 GMT</pubDate>
            <atom:updated>2014-09-22T19:01:20.172Z</atom:updated>
            <content:encoded><![CDATA[<p>Not all cloud nine</p><p>EPiServer has a nifty <a href="http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Deployment/Deployment-scenarios/Deploying-to-Azure-websites/">tutorial</a> on how to run EPiServer in an Azure website. Before I found it, I only had experience running EPiServer in a IaaS environment. Both were in my opinion not ideal. I wanted the freedom of IaaS and the ease of use of an Azure website. I created a Web role solution, created a EPiServer website and deployed my package. But somehow my cloud service would not start. Here is how I found the source and solution to the problem.</p><h3>Structure of the project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*aNcoIbRoJdN_ec6W7JG1tg.png" /><figcaption>Visual Studio solution</figcaption></figure><p>The project which I wanted to run in Azure cloud service started only a few months ago, so during the startup I picked the latest version of MVC, PostSharp, Autofac and EPiServer. I wrote my tests and my code and a pretty <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">solid</a> project was born.</p><p>Due to EPiServers removal of the Deployment Center and putting everything in NuGet packages I was able to debug the application and run it in my Azure emulator with multiple instances. Everything worked pretty well.</p><p>I also followed the tutorial EPiServer wrote for the Azure websites. I added and removed sections in my web.config and created the necessary services in Azure:</p><ul><li>Storage</li><li>Database</li><li>Cloud service</li></ul><h3>The deployment</h3><p>You can deploy to an Azure cloud service from Visual Studio, TeamCity or a .cspkg Package. The Visual Studio scenario is the easiest, so I tried that first. When you click “Publish” from the context menu you are presented with a wizard which helps you configuring your deployment. After that, everything is done for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vb3jQi0PgIOwywVzuE8e5Q.png" /><figcaption>Deploying to a web role from Visual Studio</figcaption></figure><p>The deployment did not go very well as you can see in the screenshot above.</p><h3>Finding the problem</h3><p>Something went wrong, but what? The Azure portal could not give me a lot of information. At first, everything looked okay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*zXckUqvRszMqST60W9TAbg.png" /><figcaption>Package is being installed on a cloud instance</figcaption></figure><p>But after a while the following message appeared. The role instance keeps recycling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*Ot883JSpEDMc8UqBZVbbZA.png" /><figcaption>Role keeps recycling</figcaption></figure><p>I added extra logging in my application and in the <em>RoleEntryPoint</em>, but nothing was logged which indicated that the role could not be started by Azure at all.</p><p>After logging in with remote desktop on one of the VM’s I searched through the Event Viewer but the messages were not helpful. On top of that it were all info’s and warnings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*Xx-yRDtMjLXfbZqFgoeAxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*y2YokosH5SkgP8L6eKg3pQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*muZryl9gA-_2N6sjGuOwyw.png" /></figure><p>I searched the internet and found <a href="http://blogs.msdn.com/b/kwill/archive/2013/10/03/troubleshooting-scenario-7-role-recycling.aspx">this helpful tutorial</a> on how to troubleshoot in Azure cloud services and got the following error message in WinDBG:</p><pre>(ef8.f70): Break instruction exception — code 80000003 (first chance)<br>*** ERROR: Symbol file could not be found. Defaulted to export symbols for D:\Windows\SYSTEM32\ntdll.dll —<br>ntdll!DbgBreakPoint:<br>00007ffd`c723c830 cc int 3</pre><p>Again, I Googled for a solution and found <a href="http://stackoverflow.com/a/2908002/1200072">this StackOverflow post</a>, reattached WaIISHost and after a while I got a new exception:</p><pre>Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : ModLoad: 00007ffd`b2e60000 00007ffd`b2f66000 D:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll<br>Role entrypoint could not be created:<br>System.TypeLoadException: Unable to load the role entry point due to the following exceptions:<br>— System.IO.FileLoadException: Could not load file or assembly ‘System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#39; or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)<br>File name: ‘System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#39;</pre><p>That exception is quite clear, but my solution did not contain any reference to MVC 4. However, <a href="http://blogs.msdn.com/b/cie/archive/2013/04/04/web-role-with-mvc4-just-recycles-on-windows-azure.aspx">another blogpost</a> helped me a step further.</p><p>The EPiServer DLLs that I added through NuGet <em>did</em> have references with the MVC4 assembly.</p><h3>The solution</h3><p>I ‘updated’ the Microsoft.AspNet.Mvc packages to the latest version of MVC 4 in the Package Manager Console:</p><pre>Update-Package Microsoft.AspNet.Mvc -Version 4.0.30506</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*D6mzGQds_pY4uMHKHvwvRQ.png" /><figcaption>OnRoleRun is being called and the second instance is running</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*G4-JG27OmGkvKnLlckwq_A.png" /></figure><p>That did the trick: EPiServer is running in a web role.</p><p>It turns out using MVC5 with EPiServer is not possible when running it in Azure. It’s a thing to keep in mind when you’re setting up your solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c652f5f38cbc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/efocus-collection/running-episerver-in-azure-cloud-services-c652f5f38cbc">Running EPiServer in Azure cloud services</a> was originally published in <a href="https://medium.com/efocus-collection">eFocus Collection</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Property injection with Autofac]]></title>
            <link>https://medium.com/@HLeautaud/property-injection-with-autofac-7f8763fd0495?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f8763fd0495</guid>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Fri, 18 Jul 2014 07:27:56 GMT</pubDate>
            <atom:updated>2014-07-20T17:43:25.331Z</atom:updated>
            <content:encoded><![CDATA[<h4>using PostSharp’s LocationInterceptionAspect</h4><p>A little while ago I was setting up a new solution for a project. As I am very fond of a <a href="http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29">SOLID</a> design and a big supporter to see what can be improved every new project I am starting, I dived into the world of Dependency Injection (DI) frameworks.</p><p>It is really hard to find one that fits your needs because there are <em>a lot</em> and the differences are not very large. <a href="https://twitter.com/shanselman">Scott Hanselman</a> wrote a blog post on them <a href="http://www.hanselman.com/blog/ListOf-NETDependencyInjectionContainersIOC.aspx">a while back,</a> and most of them are still out there. Ninject, Unity, Autofac, StructureMap, Castle Windsor are generally used. I ultimately chose for <a href="http://autofac.org/">Autofac</a> because of the <a href="https://code.google.com/p/autofac/wiki/MultitenantIntegration">multitenancy</a> which I was looking for.</p><p>When using a DI framework, you’ll notice there are several ways to inject your registered objects. One of them is property (setter) injection. In a few frameworks this can be done with an attribute. In Ninject, for example, this looks something like this:</p><pre>[Inject]<br>public IWeapon Weapon { get; set; }</pre><p>To achieve this in Autofac, you have to tell your registered objects that you’ll probably want to resolve some properties within the object. This means that you’ll have to do this for all your registered objects.</p><pre>builder.RegisterType&lt;Weapon&gt;().As&lt;IWeapon&gt;().PropertiesAutowired();</pre><p>In my opinion the attribute is a cleaner solution. It should not be the concern of the container whether or not I want to inject other objects.</p><p>That is why I searched for a solution which I found in <a href="http://www.postsharp.net/">PostSharp</a>, which is a Design Pattern Automation tool.</p><blockquote>“PostSharp is a tool that allows development teams to achieve more with less code in Microsoft .NET”</blockquote><p>… and that is exactly what I want to achieve. Therefore I wrote a custom <em>AutofacResolveAttribute</em> which will return the correct service from the current <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.dependencyresolver%28v=vs.118%29.aspx">DependencyResolver</a>.</p><pre>[Serializable]<br>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]<br>public class AutofacResolveAttribute : LocationInterceptionAspect<br>{<br>    public override void OnGetValue(LocationInterceptionArgs args)<br>    {<br>        args.ProceedGetValue();<br>        if (!args.Location.LocationType.IsInterface) return;</pre><pre>        if ( args.Value != null )<br>        {<br>            args.Value = DependencyResolver.Current.GetService(args.Location.LocationType);<br>            args.ProceedSetValue();<br>        }<br>    }<br>}</pre><p>In the code snippet you can see the <em>OnGetValue</em> method which will be invoked when you <em>get</em> your property. There is also a check if the property you are trying to get is a interface, which you can remove if you like.</p><p>I know this isn’t a structual way of solving this but it may help you for your current problems. I’m hoping Autofac will include a similar functionality in a future release. If this blogpost helped you, please upvote my <a href="http://stackoverflow.com/a/23535219/1200072">answer</a> on Stack Overflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f8763fd0495" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Sitecore items with Git and TDS]]></title>
            <link>https://medium.com/sitecore-tips-tricks/deploying-sitecore-items-with-git-and-tds-f6a47605d1b4?source=rss-a3a5f6042e61------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6a47605d1b4</guid>
            <dc:creator><![CDATA[Hans Léautaud]]></dc:creator>
            <pubDate>Fri, 04 Jul 2014 12:02:46 GMT</pubDate>
            <atom:updated>2014-07-20T17:42:16.249Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fixing autocrlf and content-length issue</h4><h3>Autocrlf = true</h3><p>Git has a really cool feature which helps users to avoid annoying line ending issues in their IDE’s. A lot of client-side developers use a Mac or a different IDE than the server-side developers use. In Visual Studio this results in constantly popping up messages with the question if you want to fix these issues. Yes, there are extensions to fix these problems but we want to fix the problem at the source, right? The <a href="http://git-scm.com/book/en/Customizing-Git-Git-Configuration">autocrlf</a> property can come in handy in these situations. Git will convert all line-endings to LF when commiting your code.</p><h3>Sitecore serialization</h3><p>When you are familiar with Sitecore, you probably are also familiar with the serialization option in Sitecore. If you are not, open the Content Editor and activate the Developer tab in your ribbon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*KokHocvfgAnna2Vbjw6emw.png" /><figcaption>Developer ribbon in Sitecore</figcaption></figure><p>Sitecore will serialize items into .item files on disk. This is extremely useful in some cases. <a href="http://www.hhogdev.com/products/team-development-for-sitecore/overview.aspx">Team Development for Sitecore</a> (TDS) also uses this technique to serialize and deploy items.</p><p>These .item files are not JSON or XML formatted. No, they’re just plain text files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-YhkoOrV9LIrWCB4JsBNQ.png" /><figcaption>.item file generated by Sitecore</figcaption></figure><p>As you can see in the file above, all files are marked with the <em>—-field——</em> comment. All fields are also provided with a field GUID and a content-length. This works fine in most cases (although I find it somewhat cumbersome). However, this will give you some headaches when you are using fields with multiple lines. Then, in combination with the autocrlf option in Git, the content-length field and the actual length of the field do not correspond which will result in an error in Sitecore (and thus also in TDS):</p><blockquote>Length of field content does not match the content-length attribute</blockquote><h3>The solution</h3><p>Fortunately this is fixable with a so called .<a href="http://git-scm.com/book/en/Customizing-Git-Git-Attributes">gitattributes</a> file. Just add the following line to this file:</p><blockquote>*.item -text</blockquote><p>This will not fix your problem immediately though. You should remove all the previously synced .item files from Git and re-sync them with TDS.</p><h4>When using TeamCity</h4><p>If you are using TeamCity, don’t forget to disable the following setting in your VCS settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*pm2Ox0RfKVYqIlQqkNn2Xg.png" /><figcaption>VCS settings in TeamCity</figcaption></figure><p>Now all Sitecore items should be deployed correctly! Hope it helps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6a47605d1b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sitecore-tips-tricks/deploying-sitecore-items-with-git-and-tds-f6a47605d1b4">Deploying Sitecore items with Git and TDS</a> was originally published in <a href="https://medium.com/sitecore-tips-tricks">Sitecore Tips &amp; Tricks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>