<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://shazwazza.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Shazwazza</title>
    <link>https://shazwazza.com/</link>
    <description>My blog which is pretty much just all about coding</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <image>
      <url>/media/0libq25y/frog.png?rmode=max&amp;v=1da0e911f4e6890</url>
      <title>Shazwazza</title>
      <link>https://shazwazza.com/</link>
    </image>
    <item>
      <guid isPermaLink="false">1296</guid>
      <link>https://shazwazza.com/post/auto-upgrade-your-nuget-packages-with-azure-pipelines-or-github-actions/</link>
      <category>ASP.Net</category>
      <category>Umbraco</category>
      <title>Auto upgrade your Nuget packages with Azure Pipelines or GitHub Actions</title>
      <description>&lt;p&gt;Before we start I just want to preface this with some  &lt;strong&gt;warnings &lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;This works for me, it might not work for you&lt;/li&gt;
&lt;li&gt;To get this working for you, you may need to tweak some of the code referenced&lt;/li&gt;
&lt;li&gt;This is not under any support or warranty by anyone&lt;/li&gt;
&lt;li&gt;Running Nuget.exe update command outside of Visual Studio will overwrite your files so there is a manual review process (more info below)&lt;/li&gt;
&lt;li&gt;This is only for ASP.NET Framework using &lt;em&gt;packages.config&lt;/em&gt; – Yes I know that is super old and I should get with the times, but this has been an ongoing behind the scenes project of mine for a long time. When I need this for Package Reference projects, ASP.NET Core/5, I’ll update it but there’s nothing stopping you from tweaking this to work for you&lt;/li&gt;
&lt;li&gt;This only works for a specified csproj, not an entire sln – it could work for that but I’ve not tested, there would be a few tweaks to make that work&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through;"&gt;This does not yet work for GitHub actions but the concepts are all here and could probably very easily be converted&lt;/span&gt; &lt;strong&gt;UPDATE:&lt;/strong&gt; This works now!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that’s out of the way …&lt;/p&gt;
&lt;h2&gt;How do I do it?&lt;/h2&gt;
&lt;p&gt;With a lot of PowerShell :) This also uses a few methods from the &lt;a rel="noopener" href="https://github.com/microsoft/PowerShellForGitHub" target="_blank"&gt;PowerShellForGitHub&lt;/a&gt; project.&lt;/p&gt;
&lt;p&gt;The process is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Run a pipeline/action on a schedule (i.e. each day)&lt;/li&gt;
&lt;li&gt;This checks against your source code for the installed version for a particular package&lt;/li&gt;
&lt;li&gt;Then it checks with Nuget (using your Nuget.config file) to see what the latest stable version is&lt;/li&gt;
&lt;li&gt;If there’s a newer version:&lt;/li&gt;
&lt;li&gt;Create a new branch&lt;/li&gt;
&lt;li&gt;Run a Nuget update against your project&lt;/li&gt;
&lt;li&gt;Build the project&lt;/li&gt;
&lt;li&gt;Commit the changes&lt;/li&gt;
&lt;li&gt;Push the changes&lt;/li&gt;
&lt;li&gt;Create a PR for review&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Azure Pipelines/GitHub Actions YAML&lt;/h2&gt;
&lt;p&gt;The only part of the YAML that needs editing is the variables, here's what they mean:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ProjectFile = The relative path to your csproj that you want to upgrade&lt;/li&gt;
&lt;li&gt;PackageFile = The relative path to your packages.config file for this project&lt;/li&gt;
&lt;li&gt;PackageName = The Nuget package name you want upgraded&lt;/li&gt;
&lt;li&gt;GitBotUser = The name used for the Git commits&lt;/li&gt;
&lt;li&gt;GitBotEmail = The email used for the Git commits&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For Azure Pipelines, these are also required:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GitHubOwner = The repository owner (i.e. &lt;a href="https://github.com/Shazwazza/Articulate" title="https://github.com/Shazwazza/Articulate"&gt;https://github.com/&lt;strong&gt;Shazwazza&lt;/strong&gt;/Articulate&lt;/a&gt; )&lt;/li&gt;
&lt;li&gt;GitHubRepository = The repository name (i.e. &lt;a href="https://github.com/Shazwazza/Articulate" title="https://github.com/Shazwazza/Articulate"&gt;https://github.com/Shazwazza/&lt;strong&gt;Articulate&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;There is one Secret setting you need to create in Azure Pipelines: &lt;em&gt;GitHubAccessToken &lt;/em&gt;which is a GitHub PAT that you need to create that has access to this repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then there are some variables to assist with testing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DisableUpgradeStep = If true will just check if there’s an upgrade available and exit&lt;/li&gt;
&lt;li&gt;DisableCommit = If true will run the upgrade and will exit after that (no commit, push or PR)&lt;/li&gt;
&lt;li&gt;DisablePush = If true will run the upgrade + commit and will exit after that (no push or PR)&lt;/li&gt;
&lt;li&gt;DisablePullRequest = If true will run the upgrade + commit + push and will exit after that (no PR)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each step in the yaml build more or less either calls Git commands or PowerShell functions. The PowerShell functions are loaded as part of a PowerShell Module which is committed to the repository. This module’s functions are auto-loaded by PowerShell because the first step configures the PowerShell environment variable &lt;em&gt;PSModulePath&lt;/em&gt; to include the custom path. Once that is in place, all functions exposed by the module are auto-loaded.&lt;/p&gt;
&lt;p&gt;In these examples you’ll see that I’m referencing Umbraco Cloud names and that’s because I’m using this on Umbraco Cloud for my own website and the examples are for the &lt;em&gt;UmbracoCms&lt;/em&gt; package. But this should in theory work for all packages!&lt;/p&gt;
&lt;h2&gt;Show me the code&lt;/h2&gt;
&lt;p&gt;&lt;a rel="noopener" href="https://github.com/Shazwazza/NugetAutoUpgrade/tree/main/Examples/NET_Framework/WebApplication" target="_blank"&gt;The code for all of this is here&lt;/a&gt; in a new GitHub repo and here’s how you use it:&lt;/p&gt;
&lt;p&gt;You can copy the folder structure in the repository as-is. Here's an example of what my site's repository folder structure is to make this work (everything except the src folder is in the GitHub repo above):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[root]
&lt;ul&gt;
&lt;li&gt;auto-upgrader.devops.yml &lt;em&gt;(If you are using Azure Pipelines)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;.github
&lt;ul&gt;
&lt;li&gt;workflows
&lt;ul&gt;
&lt;li&gt;auto-upgrader.gh.yml &lt;em&gt;(If you are using GitHub Actions)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;build
&lt;ul&gt;
&lt;li&gt;PowershellModules
&lt;ul&gt;
&lt;li&gt;AutoUpgradeFunctions.psd1&lt;/li&gt;
&lt;li&gt;AutoUpgradeFunctions.psm1&lt;/li&gt;
&lt;li&gt;AutoUpgradeFunctions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;src
&lt;ul&gt;
&lt;li&gt;Shazwazza.Web
&lt;ul&gt;
&lt;li&gt;Shazwazza.Web.csproj&lt;/li&gt;
&lt;li&gt;packages.config&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of the steps have descriptive display names and it should be reasonably self documenting.&lt;/p&gt;
&lt;p&gt;The end result is a PR, here’s one that was generated by this process:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://shazwazza.com/media/8d8d9550b2c26c6/image.png?width=600&amp;amp;height=353&amp;amp;mode=max" alt=""&gt;&lt;/p&gt;
&lt;h2&gt;Nuget overwrites&lt;/h2&gt;
&lt;p&gt;Nuget.exe works differently than Nuget within Visual Studio’s Package Manager Console. All of those special commands like Install-Package, Update-Package, etc… are all PowerShell module commands built into Visual Studio and they are able to work with the context of Visual Studio. This allows those commands to try to be a little smarter when running Nuget updates and also allows the legacy Nuget features like running PowerShell scripts on install/update to run. This script just uses Nuget.exe and it’s less smart especially for these legacy .NET Framework projects. As such, it will just overwrite all files in most cases (it does detect file changes it seems but isn’t always accurate).&lt;/p&gt;
&lt;p&gt;With that  &lt;strong&gt;warning &lt;/strong&gt;it is very important to make sure you review the changed files in the PR and revert or adjust any changes you need before applying the PR.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You’ll see a note in the PowerShell script about Nuget overwrites. There are other options that can be used like "Ignore" and "IgnoreAll" but all my tests have showed that for some reason this setting will end up deleting a whole bunch of files so the default overwrite setting is used.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Get out there and try it! Would love some feedback on this if/when you get a change to test it.&lt;/p&gt;
&lt;div class="post"&gt;
&lt;div class="body"&gt;
&lt;div id="4866d04c-80a7-43ab-a84e-d2ee7756afb6" class="postBody"&gt;
&lt;p&gt;&lt;em&gt;PackageReference&lt;/em&gt; support with .NET Framework projects could also be done (but IMO this is low priority) along with being able to upgrade the entire SLN instead of just the csproj.&lt;/p&gt;
&lt;p&gt;Then perhaps some attempts at getting a NET Core/5 version of this running. In theory that will be easier since it will mostly just be &lt;em&gt;dotnet&lt;/em&gt; commands.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:10:22 Z</pubDate>
      <a10:updated>2023-03-23T15:10:22Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1274</guid>
      <link>https://shazwazza.com/post/web-application-projects-with-umbraco-cloud/</link>
      <category>Umbraco</category>
      <title>Web Application projects with Umbraco Cloud</title>
      <description>&lt;p&gt;This is a common topic for developers when working with Umbraco Cloud because Umbraco Cloud simply hosts an ASP.Net Framework “Website”. The setup is quite simple, a website is stored in a Git repository and when it’s updated and pushed to Umbraco Cloud, all of the changes are live. You can think of this Git repository as a deployment repository (&lt;em&gt;which is very similar to how &lt;/em&gt;&lt;a rel="noopener" href="https://docs.microsoft.com/en-us/azure/app-service/deploy-local-git" target="_blank"&gt;&lt;em&gt;Azure Web Apps can work with git deployments&lt;/em&gt;&lt;/a&gt;). When you create a new Umbraco Cloud site, the git repository will be pre-populated with a runnable website. You can clone the website and run it locally with IIS Express and it all just works. But this is not a compile-able website and it’s not part of a visual studio project or a solution and if you want to have that, there’s numerous work arounds that people have tried and use but in my personal opinion they aren’t the ideal working setup that I would like.&lt;/p&gt;
&lt;h2&gt;Ideal solution&lt;/h2&gt;
&lt;p&gt;In my opinion the ideal solution for building web apps in .NET Framework is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A visual studio solution&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;A compile-able Web Application project (.csproj)&lt;/li&gt;
&lt;li&gt;Additional class library projects (as needed)&lt;/li&gt;
&lt;li&gt;Unit/Integration test projects (as needed)&lt;/li&gt;
&lt;li&gt;All dependencies are managed via Nuget&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Git source control for my code, probably stored in GitHub&lt;/li&gt;
&lt;li&gt;A build server, CI/CD, I like Azure Pipelines&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think this is a pretty standard setup for building websites but trying to wrangle this setup to work with Umbraco Cloud isn’t as easy as you’d think. A wonderful Umbraco community member &lt;a rel="noopener" href="https://twitter.com/paulsterling" target="_blank"&gt;Paul Sterling&lt;/a&gt; has written about how to do this a couple of times, &lt;a rel="noopener" href="https://skrift.io/articles/archive/integrating-umbraco-cloud-with-team-development-workflow/" target="_blank"&gt;here&lt;/a&gt; and &lt;a rel="noopener" href="https://skrift.io/articles/archive/take-two-another-approach-for-team-development-workflow-with-umbraco-cloud/" target="_blank"&gt;here&lt;/a&gt; and there’s certainly a few hoops you’d need to jump through. These posts were also written before the age of &lt;a rel="noopener" href="https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&amp;amp;tabs=schema" target="_blank"&gt;Azure YAML Pipelines&lt;/a&gt; which luckily has made this process a whole lot easier&lt;/p&gt;
&lt;h2&gt;Solution setup&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;NOTE: This is for Umbraco v8, there’s probably some other edge cases you’ll need to discover on your own for v7.&lt;/em&gt; &lt;/p&gt;
&lt;p&gt;Setting up a Visual Studio solution with a web application compatible for Umbraco Cloud is pretty straight forward and should be very familiar. It will be much easier to do this starting from scratch with a new Umbraco Cloud website though it is more than possible to do this for an existing website (i.e. I did this for this website!) but most of those details are just migrating custom code, assets, etc… to your new solution.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I would suggest starting with a new Umbraco Cloud site that has no modifications to it but does have a content item or two that renders a template.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Create a new VS solution/project for a web application running .NET 4.7.2&lt;/li&gt;
&lt;li&gt;Add this Nuget.config to the root folder (beside your .sln file)
&lt;ul&gt;
&lt;li&gt;
&lt;pre class="lang-xml"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;packageSources&amp;gt;
	&amp;lt;add key="NuGet" value="https://api.nuget.org/v3/index.json" /&amp;gt;
    &amp;lt;add key="UmbracoCloud" value="https://www.myget.org/F/uaas/api/v3/index.json" /&amp;gt;
  &amp;lt;/packageSources&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Install the Nuget package for the same Umbraco version that you are currently running on your Umbraco Cloud website. For example if you are running 8.4.0 then use Install-Package UmbracoCms –Version 8.4.0&lt;/li&gt;
&lt;li&gt;Install Forms (generally the latest available): &lt;em&gt;Install-Package UmbracoForms&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Install Deploy (generally the latest available):
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Install-Package UmbracoDeploy&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Install-Package UmbracoDeploy.Forms&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Install-Package UmbracoDeploy.Contrib&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Then you’ll need to install some additional Nuget packages that are required to run your site on Umbraco Cloud. This is undocumented but Umbraco Cloud adds a couple extra DLLs when it creates a website that are required.
&lt;ul&gt;
&lt;li&gt;Install-Package Serilog.Sinks.MSSqlServer -Version 5.1.3-dev-00232&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Copy these files from your Umbraco Cloud deployment repository to your web application project:
&lt;ul&gt;
&lt;li&gt;~/data/*&lt;/li&gt;
&lt;li&gt;~/config/UmbracoDeploy.config&lt;/li&gt;
&lt;li&gt;~/config/UmbracoDeploy.Settings.config&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You then need to do &lt;em&gt;something weird&lt;/em&gt;. These settings need to be filled in because Umbraco Deploy basically circumvents the normal Umbraco installation procedure and if you don’t have these settings populated you will get YSODs and things won’t work.
&lt;ul&gt;
&lt;li&gt;Make sure that you have your Umbraco version specified in your web.config like: &amp;lt;add key="Umbraco.Core.ConfigurationStatus" value="YOURVERSIONGOESHERE" /&amp;gt;&lt;/li&gt;
&lt;li&gt;Make sure your &lt;em&gt;connectionStrings&lt;/em&gt; in your web.config is this:
&lt;ul&gt;
&lt;li&gt;
&lt;pre class="lang-xml"&gt;&lt;code&gt;&amp;lt;connectionStrings&amp;gt;
    &amp;lt;remove name="umbracoDbDSN" /&amp;gt;
    &amp;lt;add name="umbracoDbDSN"
         connectionString="Data Source=|DataDirectory|\Umbraco.sdf"
         providerName="System.Data.SqlServerCe.4.0" /&amp;gt;
&amp;lt;/connectionStrings&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;But I don’t want to use SqlCE! Why do I need that connection string? In actual fact Umbraco Deploy will configure your web application to use &lt;a rel="noopener" href="https://docs.microsoft.com/en-us/archive/blogs/sqlexpress/introducing-localdb-an-improved-sql-express" target="_blank"&gt;Sql Express LocalDb&lt;/a&gt; if it’s available on your machine (which it most likely is). This is why when running Umbraco Cloud sites locally you’ll see .mdf and .ldf files in your App_Data folder instead of SqlCE files. Local Db operates just like Sql Server except the files are located locally, it’s really sql server under the hood. You can even use Sql Management Studio to look at these databases by connecting to the &lt;em&gt;(localdb)\umbraco&lt;/em&gt; server locally with &lt;em&gt;Windows Authentication&lt;/em&gt;. It is possible to have your local site run off of a normal Sql server database with a real connection string but I think you’d have to install Umbraco first before you install the UmbracoDeploy nuget package. Ideally UmbracoDeploy would allow the normal install screen to run if there was no Umbraco version detected in the web.config, but that’s a whole other story.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That should be it! In theory your web application is now configured to be able to publish a website output that is the same as what is on Umbraco Cloud.&lt;/p&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;p&gt;At this stage you should be able to run your solution, it will show the typical Umbraco Deploy screen to restore from Cloud&lt;/p&gt;
&lt;p&gt;&lt;a href="/articulate/open-live-writer-aa627631134f_bc51-image_2.png"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-aa627631134f_bc51-image_thumb.png" border="0" alt="image" title="image" width="1024" height="243" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In theory you should be able to restore your website and everything should ‘just work’&lt;/p&gt;
&lt;h2&gt;Working with code&lt;/h2&gt;
&lt;p&gt;Working with your code is now just the way you’re probably used to working. Now that you’ve got a proper Visual Studio solution with a Web Application Project, you can do all of the development that you are used to. You can add class libraries, unit test projects, etc… Then you commit all of these changes to your own source control like GitHub. This type of repository is &lt;strong&gt;not&lt;/strong&gt; a deployment repository, this is a source code repository.&lt;/p&gt;
&lt;h2&gt;How do I get this to Umbraco Cloud?&lt;/h2&gt;
&lt;p&gt;So far there’s nothing too special going on but now we need to figure out how to get our Web Application Project to be deployed to Umbraco Cloud.&lt;/p&gt;
&lt;p&gt;There’s a couple ways to do this, the first way is surprisingly simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Right click your web application project in VS&lt;/li&gt;
&lt;li&gt;Click Publish&lt;/li&gt;
&lt;li&gt;Choose Folder as a publish target&lt;/li&gt;
&lt;li&gt;Select your cloned Umbraco Cloud project location&lt;/li&gt;
&lt;li&gt;Click advanced and choose “Exclude files from App_Data folder’&lt;/li&gt;
&lt;li&gt;Click Create Profile&lt;/li&gt;
&lt;li&gt;Click Publish – &lt;em&gt;you’ve just published a web application project to a website&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Push these changes to Umbraco Cloud&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The publish profile result created should match this one: &lt;a href="https://github.com/umbraco/vsts-uaas-deploy-task/blob/master/PublishProfiles/ToFileSys.pubxml"&gt;https://github.com/umbraco/vsts-uaas-deploy-task/blob/master/PublishProfiles/ToFileSys.pubxml&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This of course requires some manual work but if you’re ok with that then job done!&lt;/p&gt;
&lt;p&gt;You should do this anyways before continuing since it will give you an idea of how in-sync your web application project and the output website is to the Umbraco Cloud website, you can then see what Git changes have been made and troubleshoot anything that might seem odd.&lt;/p&gt;
&lt;h2&gt;Azure Pipelines&lt;/h2&gt;
&lt;p&gt;I’m all for automation so instead I want Azure Pipelines to do my work. This is what I want to happen:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Whenever I commit to my source code repo Azure Pipelines will:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Build my solution&lt;/li&gt;
&lt;li&gt;Run any unit tests that I have&lt;/li&gt;
&lt;li&gt;Publish my web application project to a website&lt;/li&gt;
&lt;li&gt;Zip the website&lt;/li&gt;
&lt;li&gt;Publish my zipped website artifact&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;When I add a “release-*” tag to a commit I want Azure Pipelines to do all of the above and also:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Clone my Umbraco Cloud repository&lt;/li&gt;
&lt;li&gt;Unzip my website artifact onto this cloned destination&lt;/li&gt;
&lt;li&gt;Commit these changes to the Umbraco Cloud deployment repository&lt;/li&gt;
&lt;li&gt;Push this commit to Umbraco Cloud&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;Luckily this work is all done for you :) and with YAML pipelines it’s fairly straight forward. Here’s how:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go copy &lt;a rel="noopener" href="https://github.com/umbraco/vsts-uaas-deploy-task/blob/master/Tasks/DeployUmbracoCloudRepository/DeployToUmbracoCloud.ps1" target="_blank"&gt;this PowerShell file&lt;/a&gt; and commit it to the /build folder of your source code repository &lt;em&gt;(our friends &lt;/em&gt;&lt;a rel="noopener" href="https://twitter.com/paulsterling" target="_blank"&gt;&lt;em&gt;Paul Sterling&lt;/em&gt;&lt;/a&gt;&lt;em&gt; and &lt;/em&gt;&lt;a rel="noopener" href="https://twitter.com/sitereactor" target="_blank"&gt;&lt;em&gt;Morten Christensen&lt;/em&gt;&lt;/a&gt;&lt;em&gt; had previously done this work, thanks guys!). &lt;/em&gt;This PS script essentially does all of that Git work mentioned above, the cloning, committing and pushing files. It’s a bit more verbose than just running these git comands directly in your YAML file but it’s also a lot less error prone and handles character encoding properly along with piping the output of the git command to the log.&lt;/li&gt;
&lt;li&gt;Go copy &lt;a rel="noopener" href="https://github.com/Shazwazza/UmbracoScripts/blob/master/src/AzurePipelines/azure-pipelines.yml" target="_blank"&gt;this azure-pipelines.yml file&lt;/a&gt; and commit it to the root of your git source code repository. This file contains a bunch of helpful notes so you know what it’s doing. &lt;em&gt;(This pipelines file does run any tests, etc… that exercise will be left up to you.)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;In Azure Pipelines, create a new pipeline, choose your Git source control option, choose “Existing Azure Pipelines YAML file”, select &lt;em&gt;azure-pipelines.yml &lt;/em&gt;file in the drop down, click continue.&lt;/li&gt;
&lt;li&gt;Click Variables and add these 3:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;gitAddress = The full Git https endpoint for your Dev environment on Umbraco Cloud&lt;/li&gt;
&lt;li&gt;gitUsername = Your Umbraco Cloud email address&lt;/li&gt;
&lt;li&gt;gitPassword = Your Umbraco Cloud password - ensure this value is set to Secret&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Click Run!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And that’s it! … Really? … In theory yes :)&lt;/p&gt;
&lt;p&gt;Your pipeline should run and build your solution. The latest commit you made is probably the azure-pipelines.yml files so it didn’t contain a release-* tag so it’s not going to attempt to push any changes to Umbraco Cloud. So first thing to do is make sure that your your pipeline is building your solution and doing what its supposed to. Once that’s all good then it’s time to test an Umbraco Cloud deployment.&lt;/p&gt;
&lt;h2&gt;Deploying to Umbraco Cloud&lt;/h2&gt;
&lt;p&gt;A quick and easy test would be to change the output of a template so you can visibly see the change pushed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go ahead and make a change to your home page template&lt;/li&gt;
&lt;li&gt;Run your site locally with your web application project and make sure the change is visible there&lt;/li&gt;
&lt;li&gt;Commit this change to your source control Git repository&lt;/li&gt;
&lt;li&gt;Create and push a release tag on this commit. For example, the tag name could be: “release-v1.0.0-beta01” … whatever suites your needs but based on the YAML script it needs to start with “release-“&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now you can sit back and watch Azure Pipelines build your solution and push it to Umbraco Cloud. Since this is a multi-stage pipeline, the result will look like:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-aa627631134f_bc51-image_4.png"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-aa627631134f_bc51-image_thumb_1.png" border="0" alt="image" title="image" width="1024" height="247" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And you should see a log output like this on the Deploy stage&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-aa627631134f_bc51-image_6.png"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-aa627631134f_bc51-image_thumb_2.png" border="0" alt="image" title="image" width="709" height="443" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whoohoo! Automated deployments to Umbraco Cloud using Web Application Projects.&lt;/p&gt;
&lt;h2&gt;What about auto-upgrades?&lt;/h2&gt;
&lt;p&gt;All we’ve talked about so far is a one-way push to Umbraco Cloud but one thing we know and love about Umbraco Cloud is the automated upgrade process. So how do we deal with that? I actually have this working on my site but want to make the process even simpler so you’re going to have to be patient and wait for another blog post :)&lt;/p&gt;
&lt;p&gt;The way it works is also using Azure Pipelines. Using a separate pipeline with a custom Git repo pointed at your Umbraco Cloud repository, this pipeline can be configured to poll for changes every day (or more often if you like). It then checks if changes have been made to the packages.config file to see if there’s been upgrades made to either the CMS, Forms or Deploy (in another solution I’m actually polling Nuget directly for this information). If an upgrade has been made, It clones down your source code repository, runs a Nuget update command to upgrade your solution. Then it creates a new branch, commits these changes, pushes it back GitHub and creates a Pull Request (currently this only works for GitHub).&lt;/p&gt;
&lt;p&gt;This same solution can be used for Deploy files in case administrators are changing schema items directly on Umbraco Cloud so the /deploy/* files can be automatically kept in sync with your source code repository.&lt;/p&gt;
&lt;p&gt;This idea is entirely inspired by &lt;a rel="noopener" href="https://twitter.com/sitereactor" target="_blank"&gt;Morten Christensen&lt;/a&gt;, thanks Morten! Hopefully I’ll find some time to finalize this.&lt;/p&gt;
&lt;p&gt;Stay tuned!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:41 Z</pubDate>
      <a10:updated>2023-03-23T15:09:41Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1234</guid>
      <link>https://shazwazza.com/post/how-i-configure-my-umbraco-cloud-website-to-support-nuget-packages/</link>
      <category>Umbraco</category>
      <title>How I configure my Umbraco Cloud website to support Nuget packages</title>
      <description>&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: &lt;em&gt;This post is about how I have my own website setup. This is based on my own personal opinions and is not meant to be an Umbraco Cloud ‘best practices’ guide. I’ve written this post since it might help others who have the same requirements as I do.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;My Requirements&lt;/h2&gt;
&lt;p&gt;For my simple website, I would like to manage all of my dependencies with Nuget, I don’t need anything compiled, don’t need class libraries and I don’t mind putting any required custom code into App_Code.&lt;/p&gt;
&lt;p&gt;Umbraco Cloud provisions a &lt;strong&gt;deployment&lt;/strong&gt; Git repository which for all intensive purposes is meant for deploying code between environments, not so much for a source code repository. That said, since my website is ultra simple and doesn’t contain any class library projects (etc…) I figured having an ASP.Net &lt;strong&gt;website&lt;/strong&gt; project configured in the Umbraco Cloud repository would be fine. A &lt;strong&gt;website&lt;/strong&gt; project is different from the standard &lt;strong&gt;web application&lt;/strong&gt; project; a website doesn’t compile, it runs &lt;em&gt;as-is&lt;/em&gt; which is suitable for the Umbraco Cloud Git repository since that’s exactly what the repository is made for: &lt;em&gt;to host a deployed website that runs based on the files as-is&lt;/em&gt;.  I prefer working with web application projects normally but in this case my website is ultra simple and a website project will work just fine plus this allows me to have a Visual Studio project/solution that works fairly seamlessly with Umbraco Cloud.&lt;/p&gt;
&lt;h2&gt;How to set this up&lt;/h2&gt;
&lt;p&gt;There’s not a lot required to set this up but there are a couple &lt;em&gt;‘gotchas’&lt;/em&gt;, here’s the steps:&lt;/p&gt;
&lt;h4&gt;1) Clone your Umbraco Cloud Git repo&lt;/h4&gt;
&lt;p&gt;The first step is straight forward, you need to clone your Umbraco Cloud Git repository to your local machine&lt;/p&gt;
&lt;h4&gt;2) Open your Umbraco Cloud site as a Website in Visual Studio&lt;/h4&gt;
&lt;p&gt;Open Visual Studio, &lt;em&gt;File –&amp;gt; Open –&amp;gt; Web site&lt;/em&gt; and choose the folder where your Umbraco Cloud site is cloned. This will open your Umbraco Cloud folder as a &lt;strong&gt;website&lt;/strong&gt; project (a&lt;em&gt;t this point you could ctrl+F5 and it would run your site). &lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;3) Save the sln file&lt;/h4&gt;
&lt;p&gt;You need to save the Visual Studio .sln file in order to have Nuget references, &lt;em&gt;File –&amp;gt; Save localhost_1234.sln As…&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This menu option is a bit odd and that’s because Visual Studio has created an in-memory .sln file which it’s auto-named to be localhost_PORT.sln&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_2.png"&gt;&lt;img style="display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_thumb.png" border="0" alt="image" title="image" width="374" height="417" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When you click on that, browse to your Umbraco Cloud Git repo folder and name the file something that makes more sense than localhost_PORT.sln.&lt;/p&gt;
&lt;h4&gt;4) Configure the Solution and Project to not build the website&lt;/h4&gt;
&lt;p&gt;This is optional but by default Visual Studio will try to build your website which means it’s going to try to precompile all views, etc… which not only can take some time but you will get false positive errors. So instead there’s 2 things to do: In Configuration Manager turn off the “Build” option for the website project and in the website project settings turn off building. Here’s how:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Build –&amp;gt; Configuration Manager&lt;/em&gt; opens a dialog, uncheck the Build checkbox for the website&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_4.png"&gt;&lt;img style="display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_thumb_1.png" border="0" alt="image" title="image" width="534" height="220" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then right click the root of your website project and choose “Property Pages” and click on the “Build” navigation element. Then change the “Start action” to “No build” and un-check the “Build website as part of solution” checkbox&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_6.png"&gt;&lt;img style="display: inline; background-image: none;" src="https://shazwazza.com/media/articulate/open-live-writer-how-i-configure-my-umbraco-cloud-website_af45-image_thumb_2.png" border="0" alt="image" title="image" width="674" height="431" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;5) Create a Kudu .deployment file&lt;/h4&gt;
&lt;p&gt;Here’s one of the &lt;em&gt;‘gotchas’&lt;/em&gt;. Like Azure web apps, Umbraco Cloud also uses Kudu to perform some of it’s operations such as deploying a website from the Git repository to the hosting directory on the server. By default Kudu will copy the files in the deployment repository as-is to the hosting directory on the server &lt;em&gt;(which is what we want)&lt;/em&gt;… that is until Kudu sees things like &lt;em&gt;.sln &lt;/em&gt;or &lt;em&gt;.csproj &lt;/em&gt;files in the root of the Git repository, then it tries to be clever and build things &lt;em&gt;(which we don’t want).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So to tell Kudu to just deploy the files as-is, we create a special Kudu file at the repository root called &lt;em&gt;.deployment (to be clear this file name starts with a dot!)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To create this, in your Visual Studio website project, right click the root click &lt;em&gt;Add –&amp;gt; Add new item –&amp;gt; Choose Text File –&amp;gt; Enter the name .deployment  &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Then add the following to this file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[config]
project = .&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and this tells Kudu to just deploy the files that are found in the repo.&lt;/p&gt;
&lt;h4&gt;6) Now you can add Nuget references&lt;/h4&gt;
&lt;p&gt;Once all of this is setup, you can add Nuget references to this website project like you would normally add Nuget references. At this point you might need to make a choice: Do you want to manage your Umbraco installation based on Nuget? In some cases you might not have a choice if you need to reference a Nuget package that has a dependency on Umbraco.Core. &lt;/p&gt;
&lt;p&gt;As it turns out this choice isn’t such a big deal but some things to be aware of. Since Umbraco Cloud auto-upgrades projects to the latest patch version, you might be concerned that your packages.config is going to get out of date… luckily Umbraco Cloud is clever and will auto-update this file to the version it just upgraded you too. This also goes for minor version upgrades that you perform on Umbraco Cloud. Since Umbraco Cloud auto-commits all of the upgraded files, it means you really don’t have to do anything.&lt;/p&gt;
&lt;h4&gt;7) You’ll need to commit the special *.dll.refresh files&lt;/h4&gt;
&lt;p&gt;Once you start using Nuget with a website project, you’ll notice a bunch of these *.dll.refresh files in your /bin directory. You’ll need to commit those. These are special marker files used by Visual Studio to know how to manage Nuget dependencies with a website project.&lt;/p&gt;
&lt;h2&gt;That's it!&lt;/h2&gt;
&lt;p&gt;The above setup is an easy way to setup a Visual Studio solution with a single website project that works seamlessly with Umbraco Cloud while allowing you to manage dependencies with Nuget.&lt;/p&gt;
&lt;p&gt;But what if your solution is more complicated or you want to add class libraries, etc… ? There’s Umbraco documentation on how to configure this found here: &lt;a href="https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Visual-Studio/" title="https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Visual-Studio/"&gt;https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Visual-Studio/&lt;/a&gt;, &lt;a href="https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Working-With-Visual-Studio/" title="https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Working-With-Visual-Studio/"&gt;https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Working-With-Visual-Studio/&lt;/a&gt;  and the configuration there isn’t so different than the above except that the .sln file isn’t committed to the Umbraco Cloud Git deployment repository and instead exists in your own Git repository which in that case, the special &lt;em&gt;.deployment&lt;/em&gt; file is not necessary.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:00 Z</pubDate>
      <a10:updated>2023-03-23T15:09:00Z</a10:updated>
    </item>
  </channel>
</rss>