<?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 Anthony Simmon on Medium]]></title>
        <description><![CDATA[Stories by Anthony Simmon on Medium]]></description>
        <link>https://medium.com/@asimmon?source=rss-dc6e639b4ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eI4cGq0CFa2r38L9BsUFdQ.jpeg</url>
            <title>Stories by Anthony Simmon on Medium</title>
            <link>https://medium.com/@asimmon?source=rss-dc6e639b4ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:17:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asimmon/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[How we enforce .NET coding standards at Workleap to improve productivity, quality and performance]]></title>
            <link>https://medium.com/workleap/how-we-enforce-net-coding-standards-at-workleap-to-improve-productivity-quality-and-performance-02ff340b4a96?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/02ff340b4a96</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 11:01:03 GMT</pubDate>
            <atom:updated>2025-08-04T16:22:01.638Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we enforce .NET codingstandards at Workleap to improve productivity, quality and performance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ewozomiYRxIPo4vju2UHA.jpeg" /><figcaption>Photo of our office in Montréal by <a href="https://cslangloisphoto.photofolio.com/projects/GHALL-at-GSOFT/thumbs">Claude-Simon Langlois</a>.</figcaption></figure><p>In today’s competitive software development landscape, organizations are actively looking to optimize their Software Development Life Cycle (SDLC) to deliver faster, with better quality, and reduce friction. The rise of Generative AI amplifies this trend even more. Teams that know how to leverage these tools and practices achieve unprecedented velocity.</p><p>At Workleap, we decided to take a step back to analyze where we could improve our SDLC as well, in order to reduce friction and help our developers deliver value for our customers faster, without compromising on quality.</p><p>Previously, we talked about <a href="https://anthonysimmon.com/dotnet-aspire-at-workleap/">our improvements in local development with .NET Aspire</a> and <a href="https://anthonysimmon.com/web-api-standards-at-workleap/">how we enforce web APIs standards and guidelines</a>. In this article, we will focus on how we enforce C# code style, quality and performance standards at scale with our <a href="https://github.com/workleap/wl-dotnet-codingstandards">open source .NET coding standards NuGet package</a>.</p><h3>Identifying problems and possible improvements</h3><p>Many of our services are made of several .NET solutions and hundreds of C# projects. While going through the different code repositories, our platform engineering team found a recurring pattern. Every time developers create a new solution, they are inspired by existing ones and copy some boilerplate code. This boilerplate includes .editorconfig files with dozens if not hundreds of rules, the inclusion of certain packages such as <a href="https://github.com/DotNetAnalyzers/StyleCopAnalyzers">StyleCop</a>, and .csproj properties affecting compiler/MSBuild behavior. Over the years, a certain drift occurred between different projects, resulting in inconsistencies in code style, quality and performance.</p><p>We also analyzed more than a hundred pull requests across different repositories, looking for patterns that would influence how long it takes to merge a pull request. We found that a significant number of review comments were related to code style issues. Interviews with developers confirmed that these comments had a negative impact on cycle time, as the back-and-forth could delay the merge to the next day or worse. We also noticed a certain degree of nitpicking, which proved harmful to productivity and relationships among developers. Finally, we detected multiple performance, quality or security issues in these pull requests that went unnoticed, which could be attributed to various factors, such as an overwhelming number of minor style comments that distracted reviewers from more important issues, or too many changes in a single pull request.</p><p>Digging deeper in these projects, we also found out that several warnings would pop up at build time, but nothing would prevent the associated code from being merged. This was the beginning of other related MSBuild-related findings, such as:</p><ul><li>Nullable reference types being disabled by default in some places</li><li>Roslyn analysis level kept to the default, minimal value</li><li>Style code not enforced at build time</li><li>NuGet packages auditing not enabled</li></ul><p>Moving forward, we wanted to address these issues in a way that would be sustainable and scalable across all our projects. We needed a solution that would not only enforce code style, quality and performance standards, but that would also be easy to integrate and migrate for existing projects. We knew that one of the most difficult challenges to overcome would be developers’ reluctance to change their habits and accept new rules.</p><h3>Building reusable .NET coding standards</h3><p>Once we had identified the problems, we started evaluating if we could build a solution that could be applied to at least 80% of our projects. Being a .NET/C# software company for more than 15 years meant we had a minimum baseline in terms of code style. Instead of relying on StyleCop, which has been useful to many of us for a long time, we decided to leverage the modern Roslyn-based analyzers and code fixes.</p><p>What followed were long hours trying to retrofit what would be the ideal coding style for the company in terms of <a href="https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options">language rules, formatting rules and naming rules</a>. Fortunately, we knew that the code fixes integrated into these Roslyn analysis rules would allow developers to automatically fix them across solutions. The result is <a href="https://github.com/workleap/wl-dotnet-codingstandards/blob/1.1.20/src/files/2_CodeStyle.editorconfig#L9-L264">more than 200 lines of configuration</a>, fine-tuned for the needs of the majority. This includes details as granular as where to place dots, commas, parentheses, spacing, the order of visibility modifiers, variable and type naming, etc. This is a level of granularity and attention to detail that we had never had before.</p><p>Once the code style was defined, we started configuring quality, performance and security rules. This was followed by meticulous work to <a href="https://github.com/search?q=repo%3Aworkleap%2Fwl-dotnet-codingstandards+%22.severity+%3D+%22+path%3A*.editorconfig+path%3A%2F%5Esrc%5C%2Ffiles%5C%2Fanalyzers%5C%2F%2F&amp;type=code">configure more than 800 individual Roslyn analysis rules</a>. Notable examples include: prevent multiple enumerations of IEnumerable, forwarding CancellationToken parameters to methods, rethrowing to preserve stack details, not using obsolete or weak key derivation functions, awaiting tasks instead of using .Result, etc. While this represented a colossal effort of tweaking hundreds of knobs with different severity levels, we also evaluated the impact of these rules on the build duration using <a href="https://msbuildlog.com/">MSBuild Log Viewer</a>, as we did not want to introduce a significant overhead. Surprisingly, we were able to keep the build duration impact at the same level as before or slightly better, while enabling dozens of new relevant rules. We attributed this to the previous use of StyleCop, which was less performant with many rules enabled at low severity levels. As usual, we also considered the impact of these rules on the developer experience, and we made sure that the rules would not be too intrusive or disruptive, unless they were critical for code quality, performance or security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtd0M-t5Po_5A__varcIig.gif" /><figcaption>Debating the severity of more than 800 Roslyn analysis rules took a bit of time.</figcaption></figure><p>In parallel with the configuration of these Roslyn analysis rules, we also <a href="https://github.com/workleap/wl-dotnet-codingstandards/blob/1.1.20/src/build/Workleap.DotNet.CodingStandards.props">tweaked multiple MSBuild properties</a> to ensure deterministic, consistent and performant builds. We made sure to set their values only if they were not already set in the project. Notable properties include:</p><ul><li>AnalysisLevel set to latest-all to enable all the latest Roslyn analysis features, individually tweaked by the rules defined in the .editorconfig mentioned above.</li><li>TreatWarningsAsErrors set to true when building in a CI environment or in Release configuration, to ensure that no warnings are left unaddressed in production code.</li><li>EnforceCodeStyleInBuild set to true to ensure that code style is enforced at build time, preventing any code that does not comply with the defined style from being merged.</li><li>NuGetAudit and several auditing-related properties enabled to ensure that all NuGet packages used in the project are audited for vulnerabilities.</li><li>AccelerateBuildsInVisualStudio and RestoreUseStaticGraphEvaluation opt-in to improve the build performance in specific scenarios.</li></ul><p>We also added <a href="https://www.nuget.org/packages/Microsoft.CodeAnalysis.BannedApiAnalyzers/">Microsoft.CodeAnalysis.BannedApiAnalyzers</a> as a dependency to <a href="https://github.com/dotnet/roslyn/blob/9a487721ee1f78ad48778b26a22dd86adfa56053/src/RoslynAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md">block the usage of certain .NET APIs</a> that are known to be problematic in most web development scenarios, such as using DateTime.Now, invariant culture for string operations or using Newtonsoft.Json for JSON serialization instead of the built-in System.Text.Json.</p><p>Finally, nullable reference types were not enabled by default, as migrating existing projects to nullable reference types can be a long and tedious process. However, we strongly believe that nullable reference types are one of the best features introduced in C#, and our default service templates for new projects come with the Nullable MSBuild property enabled.</p><h3>A single NuGet package to rule them all</h3><p>None of these efforts would have made sense if we had not been able to redistribute them in a simple and efficient way. If they had to be copied into every solution, these hundreds of lines of manual configuration would have been a maintenance nightmare.</p><p>Fortunately, we happened to have the <a href="https://www.meziantou.net/">amazing Gérald Barré</a> working with us at that time in our team, and he had previously studied <a href="https://www.meziantou.net/sharing-coding-style-and-roslyn-analyzers-across-projects.htm">how to redistribute </a><a href="https://www.meziantou.net/sharing-coding-style-and-roslyn-analyzers-across-projects.htm">.editorconfig files across projects in a NuGet package</a>. Being aware of this allowed us to advance from a small proof of concept to an actual game-changer initiative for our company.</p><p>To put it simply, anyone that wanted to adopt our new .NET coding standards could <a href="https://www.nuget.org/packages/Workleap.DotNet.CodingStandards/">simply add a single NuGet package</a> to their project, and all the magic would happen automatically. This capability from the .NET SDK to import .editorconfig and other MSBuild properties and targets files is something we had never seen before in other languages and runtimes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vfKtLQ77f5JTtMfJZeNKJw.png" /><figcaption>We use the EditorConfigFiles MSBuild property to import EditorConfig files globally.</figcaption></figure><h3>Reception and adoption</h3><p>When building internal tools, one of the most important aspects is adoption. No matter how great the tool is, if it is not adopted by the developers, it will not bring any value.</p><p>Knowing this, we used a communication technique that was… interesting to say the least. We applied our coding standards to several key company products and services projects, and through a document explaining our motivations, how it works and the expected benefits, we used a “positive shaming” approach where dozens of examples of non-compliant code were presented. The idea was to show how this new standard could detect thousands of potential errors and improvements in our existing projects, and create a desire to fix them.</p><p>This approach was a real success, and we quickly received approval from several technical leaders and managers to proceed with the adoption of our new coding standards across the entire company.</p><p>What came out of this was a relatively small effort of migrating more than 80% of our projects to the new coding standards. Small effort, because most Roslyn analysis rules came with code fixes, or because we provided documentation and guidance on migration. Here are some of the benefits we have seen so far:</p><ul><li><strong>Reduction of time spent in code reviews</strong>. Code style issues are now addressed automatically while writing code, or reported by CI checks to authors. This means reviewers spend less time on nitpicking and more time on verifying the actual logic and functionality of the code.</li><li><strong>Improvement of code quality, performance and security</strong>. .NET has all these amazing Roslyn analysis rules that can help catch potential issues early in the development process. Enabling these rules by default has helped us catch many issues that would have otherwise gone unnoticed.</li><li><strong>Increased developer knowledge</strong>. By being exposed to new rules and code suggestions in their IDEs, developers end up learning more about the language and its best practices. It contributed to make them better C# developers.</li><li><strong>Less boilerplate configuration</strong>. Dozens of large, unmaintained .editorconfig files were removed across our repositories. Several Directory.Build.props and *.csproj files were simplified. Developers no longer ask themselves why a certain rule is enabled or not, as it is now centralized in a single place with exhaustive documentation for each rule.</li><li><strong>Uniformity across projects</strong>. Developers can now expect the same code style across all projects, regardless of how ancient they are. This has helped reduce the friction when switching between projects or collaborating with other teams.</li><li><strong>Faster builds</strong>. A few huge solutions have seen their build time reduced by up to 20% thanks to the removal of unnecessary StyleCop rules, in favor of built-in performant .NET rules. This translates to faster feedback loops, better developer satisfaction and less compute time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*980rH6YC1aaEw6R_DAzKrw.png" /><figcaption>Without our .NET coding standards, this poorly written code example would have triggered only one warning!</figcaption></figure><h3>Try it yourself</h3><p>Our .NET coding standards are open source and <a href="https://github.com/workleap/wl-dotnet-codingstandards">available on GitHub</a>. You can <a href="https://www.nuget.org/packages/Workleap.DotNet.CodingStandards/">install the package from NuGet.org</a> and try it out in your own projects. We have proper tooling to automatically keep the analysis rules up-to-date as new rules or rule changes are made in the .NET SDK. We have several tests that ensure that several rules or code style settings work as expected. Sometimes, we harden the rules’ severity as the NuGet package adoption increases and we get more feedback from developers.</p><p>A few other companies have started using our coding standards and have provided positive feedback. They are grateful for no longer having to think about several aspects that were previously a source of friction, and for being able to focus on delivering value faster.</p><p>Code styling is subjective, and these coding standards are what work best for us. If you have different preferences, you can easily fork the repository. You can also modify the behavior of the analysis rules and the compiler with your own .editorconfig and MSBuild properties in your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02ff340b4a96" width="1" height="1" alt=""><hr><p><a href="https://medium.com/workleap/how-we-enforce-net-coding-standards-at-workleap-to-improve-productivity-quality-and-performance-02ff340b4a96">How we enforce .NET coding standards at Workleap to improve productivity, quality and performance</a> was originally published in <a href="https://medium.com/workleap">Workleap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we enforce web API standards and guidelines at Workleap]]></title>
            <link>https://medium.com/workleap/how-we-enforce-web-api-standards-and-guidelines-at-workleap-8a535d813244?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a535d813244</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 11:02:35 GMT</pubDate>
            <atom:updated>2025-07-29T11:02:35.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKn1tCY1dDgWYtrSQWL77A.jpeg" /><figcaption><em>Photo of our office in Montréal by </em><a href="https://cslangloisphoto.photofolio.com/projects/GHALL-at-GSOFT/thumbs"><em>Claude-Simon Langlois</em></a><em>.</em></figcaption></figure><p>Creating a web API means making a promise about the shape of the data exchanged between the API and its consumers. While behavioral aspects are also important, they often require more complex testing strategies, such as integration tests. When it comes to the contract, however, we can leverage tools to ensure that the API adheres to the expected standards, does not break existing consumers, and remains stable over time.</p><p>Maintaining API contracts is even more critical when multiple services interact with one another. This is the case at Workleap, where we use a mix of external and internal services to build our products. To provide stability as our HTTP REST APIs evolve, we have established a set of standards, practices, and tools that guarantee API quality and consistency. Everything is fully automated and integrates seamlessly into our teams’ development workflow, both on local machines and in CI environments.</p><p>The tooling we built relies on well‑known, open‑source technologies that are widely adopted in the industry. We use <a href="https://www.openapis.org/">OpenAPI</a> to describe our APIs, <a href="https://github.com/stoplightio/spectral">Spectral</a> to validate the descriptions, <a href="https://github.com/oasdiff/oasdiff">oasdiff</a> to detect potential breaking changes, and either <a href="https://learn.microsoft.com/en-us/openapi/kiota/overview">Kiota</a> or <a href="https://github.com/OpenAPITools/openapi-generator">openapi‑generator</a> to generate clients automatically.</p><p>That is a lot of tools to manage, and a major challenge was ensuring they are easy for developers to use without complex configuration or deep domain knowledge. Everything had to be integrated into the development flow so that developers could stay focused on delivering value instead of wrestling with new technical details. Consistency across departments and teams was also an important factor. To achieve this, we created <a href="https://github.com/workleap/wl-openapi-msbuild">Workleap.OpenApi.MSBuild</a>, a wrapper that embeds these tools into the build process of our ASP.NET Core projects.</p><h3>Generating the OpenAPI specification</h3><p>First, we believe that to make API contracts first‑class citizens, they must be treated like code. That means they should be versioned, tested, and maintained just like the rest of the application code. At build time, the API contract must be generated, validated, and compared with the previous version to detect breaking changes.</p><p>To automate this, we needed a way to integrate into the .NET build process. Enter Workleap.OpenApi.MSBuild, an MSBuild task that runs automatically during the build of ASP.NET Core projects. The only requirement is to <a href="https://www.nuget.org/packages/Workleap.OpenApi.MSBuild/">install the NuGet package</a>.</p><p>Normally, the usual ASP.NET Core OpenAPI tooling exposes an endpoint /swagger/v1/swagger.json containing the API description. As mentioned earlier, we want this description to be part of the codebase, not just available at runtime.</p><p>Therefore, Workleap.OpenApi.MSBuild automatically downloads <a href="https://www.nuget.org/packages/Swashbuckle.AspNetCore.Cli">Swashbuckle.AspNetCore.Cli</a>, a CLI that extracts an OpenAPI specification from an ASP.NET Core project. The task downloads the CLI efficiently and reliably, then generates the specification in the project’s root directory. When a developer changes an API contract, the modified file appears in source control and must be reviewed in the pull request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uA1rPVSC1x0Nuvvff0U9Og.gif" /><figcaption>The OpenAPI specification is automatically created at build time.</figcaption></figure><p>To ensure the OpenAPI file is always up to date, Workleap.OpenApi.MSBuild performs the same generation step in CI and raises an error if the generated specification differs from the committed one. This guarantees that contract changes are always intentional and validated by developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xA0nc7DiIx-BuJ44SoIi5g.gif" /><figcaption>Changes to the C# code are automatically reflected in the OpenAPI specification.</figcaption></figure><p>In short, developers are not forced to maintain the OpenAPI file manually. They <em>can</em> update their C# code and continue to use familiar ASP.NET Core or Swashbuckle annotations such as [HttpGet], [EndpointSummary], [Consumes], and [Tags].</p><h3>Validating the OpenAPI specification</h3><p>Having an OpenAPI specification is great, but it must also be valid and comply with company standards and guidelines. For this, we use <a href="https://github.com/stoplightio/spectral">Spectral</a>, which is also adopted by companies like Adidas, Microsoft, Box, and DigitalOcean.</p><p>Spectral is a linter for OpenAPI specifications and allows us to define custom rules. A few examples of <a href="https://github.com/workleap/wl-api-guidelines/tree/main">the rules we have defined</a>:</p><ul><li>Every object property must have a defined type.</li><li>Operations with a body must specify an allowed content‑type.</li><li>Each operation must have an operation ID.</li><li>Every operation must return at least one 2xx or 3xx status code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PB0kIWEgAJvcneWij8IkJw.png" /><figcaption>Example of an OpenAPI validation error.</figcaption></figure><p>To enforce these rules at build time, Workleap.OpenApi.MSBuild automatically downloads Spectral and runs it against the generated specification. In a local development environment, violations are reported as warnings; in CI, they are treated as errors, causing the build to fail. The issues are highlighted in the logs, and a full report is attached to the workflow run.</p><h3>Detecting breaking changes</h3><p>Introducing breaking changes is sometimes unavoidable as an API evolves, but the intent must be explicit and clearly communicated. During refactoring, developers might rename a property, change its type, or modify an object’s structure. While additions are usually safe, modifications or removals can cause issues. Developers need to be aware of these changes.</p><p>To automate this, we integrated <a href="https://github.com/oasdiff/oasdiff">oasdiff</a>, a CLI that compares two OpenAPI specifications and reports differences according to a predefined policy. For example, we configure oasdiff to ignore changes to descriptions, examples, titles, and summaries, because altering them does not affect API consumers.</p><p>During the build, Workleap.OpenApi.MSBuild runs oasdiff to compare the generated specification with the committed version. Because breaking changes can be intentional, validation does not block the build or the completion of a pull request check. The oasdiff output is attached to the workflow run, and developers are encouraged to review and understand the changes during the pull request review.</p><h3>Performance considerations</h3><p>When a development tool is used frequently, slow performance quickly becomes frustrating. We therefore paid special attention to the performance of Workleap.OpenApi.MSBuild, which sits at the heart of the build process for most of our ASP.NET Core services.</p><p>Fast execution, robust error handling, and resilience are crucial for a smooth developer experience. For example, Workleap.OpenApi.MSBuild downloads each required tool only once and includes a retry policy. Once cached, the impact on build time drops significantly. Even on the first build of a new service, the overhead is under five seconds with a decent internet connection, which is acceptable for most developers. After Swashbuckle.AspNetCore.Cli, Spectral, and oasdiff are cached, the impact is reduced to less than one second.</p><h3>A customizable golden path</h3><p>Although we believe the defaults of Workleap.OpenApi.MSBuild suit most use cases, we also provide configuration options for teams that need to customize its behavior:</p><ul><li>Generate multiple OpenAPI specifications for the same project, for example, for versioned APIs.</li><li>Override the Spectral ruleset URL used for validation.</li><li>Change the location of downloaded or generated intermediate files.</li><li>Disable CI errors, which is useful for progressively adopting the tooling in existing projects.</li><li>Skip specification generation while still running validation, for teams that prefer to maintain contracts manually.</li></ul><h3>Conclusion</h3><p>Workleap.OpenApi.MSBuild saves us significant time and effort when creating and maintaining our web services. It ensures that our APIs comply with company standards and guidelines while delivering a seamless development experience. By automating the generation and validation of OpenAPI specifications, we have improved API quality, reduced the risk of breaking changes, and strengthened collaboration across teams.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a535d813244" width="1" height="1" alt=""><hr><p><a href="https://medium.com/workleap/how-we-enforce-web-api-standards-and-guidelines-at-workleap-8a535d813244">How we enforce web API standards and guidelines at Workleap</a> was originally published in <a href="https://medium.com/workleap">Workleap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Workleap uses .NET Aspire to transform local development]]></title>
            <link>https://medium.com/workleap/how-workleap-uses-net-aspire-to-transform-local-development-f73cb48f6673?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/f73cb48f6673</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Mon, 12 May 2025 11:02:41 GMT</pubDate>
            <atom:updated>2025-05-12T11:02:41.673Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Workleap uses .NET Aspire to transform local development</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1mUErSLX1Mao9QR93ekvAw.jpeg" /><figcaption>We are a remote company, but our employees can enjoy our bright and inspiring offices in Montréal at any time. Photo by <a href="https://cslangloisphoto.photofolio.com/projects/GHALL-at-GSOFT/thumbs"><em>Claude-Simon Langlois</em></a><em>.</em></figcaption></figure><p>Jessica just joined the team as a developer. After cloning her team’s repos, she runs a single command in her terminal: leap run. Within minutes, she&#39;s looking at a fully functioning dashboard showing a microservice architecture with backends, frontends, databases, and messaging services — all running locally on her machine. &quot;That was easy&quot;, she thinks, unaware that <strong>months of engineering effort made this magical experience possible</strong>.</p><p>Behind the scenes, <strong>Leap</strong> — our <em>Local Environment Application Proxy</em> — orchestrates the setup of several services, containerized or not, configures networking between them, starts emulators and databases, installs a local-only HTTPS certificate, and updates the hosts file with custom domains. What would take a day or more of environment setup <strong>now happens automatically in minutes</strong>.</p><p>This satisfying experience isn’t just the result of clever engineering — it’s made possible by embracing <a href="https://learn.microsoft.com/en-us/dotnet/aspire/get-started/aspire-overview"><strong>.NET Aspire</strong></a><strong> as the foundation of our solution</strong>. In this post, I’ll share how we leveraged Aspire in unique and creative ways to create Leap and revolutionize our local development workflow.</p><h3>Our local development challenge</h3><p>Workleap has embraced microservice architectures for numerous advantages — improved scalability, team autonomy, and technological flexibility. However, these benefits come with a significant cost: <strong>setting up a local development environment became more complex</strong>.</p><p>A typical developer at our organization might need to interact with:</p><ul><li>A few back-end services and frontends.</li><li>Various databases (MongoDB, SQL Server, etc.).</li><li>Cloud resources (Azure Blob Storage, Azure Event Grid, etc.).</li></ul><p>Before Leap, each team had its own approach to local development, leading to a fragmented experience. Custom scripts and Docker Compose files, mostly copied from one project to another — but always with differences — contributed to a <strong>lack of consistency and standardization</strong>.</p><p>Port management was particularly frustrating. Developers had to assign localhost ports for backends, frontends, and third-party dependencies. They needed to “negotiate” with other teams to avoid conflicts when they worked together. Keeping the default ports (3000 for React frontends, 27017 for MongoDB, etc.) was common and caused errors when switching between projects.</p><p>To develop a single service, developers needed to know how to start multiple dependent services, clone various repositories, run different setup scripts, and maintain knowledge of exact service localhost URLs. HTTPS support was built in silos, with each team managing its own certificates, at the risk of incompatibility when starting multiple services.</p><p>These challenges were identified from company-wide developer surveys where <strong>local development complexity ranked as our developers’ #1 pain point</strong>. After analyzing the feedback patterns, our Platform Engineering team recognized the opportunity to create a <em>golden path</em> — a standardized, well-supported development workflow that would improve productivity across all teams.</p><h3>Transforming local development with Leap</h3><p>About two years ago, Leap emerged as an answer to these challenges — an opinionated internal CLI tool that streamlines the entire local development workflow, tailored to our developers’ needs. At its core, Leap uses a declarative approach with YAML configuration files that specify services, their dependencies, and how they should run locally. One of our sources of inspiration was <a href="https://github.com/dotnet/tye">Microsoft’s Tye</a>, which is .NET Aspire’s precursor, even though Aspire did not exist at that time.</p><pre>services:<br>  backend:<br>    # Requests to app.workleap.localhost/api will be routed to this service<br>    ingress:<br>      host: app.workleap.localhost<br>      path: /api<br>    # Service owners can define one or more ways to run a service and let users choose which one to use at runtime<br>    # This is useful for optimizing resource consumption with pre-built images or service mocks<br>    runners:<br>      - type: dotnet<br>        project: &quot;./backend/backend.csproj&quot;<br>      - type: docker<br>        image: demo.azurecr.io/workleap/demo-backend:latest<br><br>  frontend:<br>    ingress:<br>      host: app.workleap.localhost<br>    runners:<br>      - type: executable<br>        command: &quot;npm&quot;<br>        args: [&quot;run&quot;, &quot;dev&quot;]<br>        workingDirectory: &quot;./frontend&quot;<br><br># Dependencies are recipes for commonly used third-party services<br>dependencies:<br>  - type: mongo<br>  - type: redis</pre><p>In this example, we declare two services, a backend API and its frontend. Both are accessible from the same custom local domain. For the backend, there are two <em>runners</em> — ways to start a given service — and developers can choose one in the CLI or in the Aspire dashboard. Finally, we declare a few pre-configured third-party dependencies (more on that later).</p><p>leap.yaml file supports a wider range of configuration options, including, but not limited to: custom environment variables, protocol and port overrides, health check URL paths, container volumes, profiles like Docker Compose, additional built-in runners and dependency types.</p><p>The leap run command scans for these configuration files, parses them, and orchestrates the entire environment automatically. <strong>Leap’s key features include</strong>:</p><ol><li><strong>Unified service management</strong> — Start, stop, and monitor all services from a single dashboard.</li><li><strong>Automatic port management</strong> — No more port conflicts or manual port assignment.</li><li><strong>Custom domain support</strong> — Local services accessible via custom domains like app.workleap.localhost.</li><li><strong>Intelligent dependency management</strong> — MongoDB, Redis, and other dependencies are automatically provisioned and shared across services.</li><li><strong>Environment variable standardization</strong> — Services discover each other through consistent environment-variable conventions.</li><li><strong>Built-in HTTPS</strong> — Automatic certificate generation and configuration for secure local development from end to end.</li><li><strong>Observability</strong> — Integrated logging, metrics, and distributed tracing for debugging complex interactions.</li><li><strong>Cross-platform support</strong> — Leap works on Windows, macOS, and Linux for x64 and arm64 architectures.</li><li><strong>Multi-repository support</strong> — Leap supports multiple repositories and solutions by ingesting leap.yaml files from any location on the filesystem.</li><li><strong>Multi-language support</strong> — Leap can run any .NET project, Docker container, or executable.</li><li><strong>Reliable and performant</strong> — Leap is a fast, reliable tool that developers can use all day long.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIdotMUrZfe28h9bzKdJwQ.gif" /><figcaption>Leap in action!</figcaption></figure><h3>.NET Aspire: The technological foundation</h3><p>Microsoft publicly launched the first preview of .NET Aspire a couple of weeks after we started the development of Leap. Back then, we implemented a custom process-orchestration layer on top of <a href="https://github.com/F1bonacc1/process-compose">Process Compose</a>. There was no dashboard, but we knew we wanted to build one with Process Compose’s API. In terms of observability, only distributed tracing was covered with <a href="https://www.jaegertracing.io/">Jaeger</a>.</p><p>Soon, we recognized <strong>Aspire’s potential to solve many of our local development challenges</strong>. Rather than building our orchestration engine from scratch, we decided to leverage Aspire as our foundation. The available features weren’t enough to cover our needs, but we were able to <strong>leverage its extensibility to address that</strong>. Like many, <a href="https://anthonysimmon.com/dotnet-aspire-dashboard-best-tool-visualize-opentelemetry-local-dev/">we found its dashboard valuable</a>, and the OpenTelemetry viewer was a great opportunity to educate our developers about distributed tracing.</p><h3>Embedding Aspire in a CLI tool</h3><p>One of our first challenges was ensuring Leap worked across our diverse development environments. It needed to work as a <strong>redistributable, cross-platform tool</strong> without requiring developers to install specific Aspire SDKs. At the beginning, Aspire was distributed through .NET workloads, which had several limitations. Leap had to work with multiple existing projects, repositories, and solutions, no matter where they were located.</p><p>Even now, an Aspire main project (the app host) can only support a single repository, unless each developer follows the exact same directory conventions. You also can’t publish the app host and reuse it elsewhere. There are specific file and directory paths that end up being embedded in the resulting assembly metadata, like the location of its orchestrator (<a href="https://anthonysimmon.com/exploring-microsoft-developer-control-plane-core-dotnet-aspire-dotnet-8/">DCP</a>) or the dashboard binaries. Paths to projects and other resources are also tied to the app-host source code location.</p><p>So, we ended up taking a deep dive into Aspire’s source code to understand how to bypass these limitations:</p><ul><li>We re-enabled the IsPublishable and IsPackable MSBuild properties, <a href="https://github.com/dotnet/aspire/blob/v9.2.1/src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets#L16-L18">which are disabled by default</a> as Aspire doesn’t support publishing.</li><li>Using NuGet’s .NET client, we download, unzip and cache the <a href="https://www.nuget.org/packages?q=Aspire.Hosting.Orchestration.&amp;includeComputedFrameworks=true&amp;prerel=true&amp;sortby=relevance">orchestration engine</a> and <a href="https://www.nuget.org/packages?q=Aspire.Dashboard.Sdk.&amp;includeComputedFrameworks=true&amp;prerel=true&amp;sortby=relevance">dashboard binaries</a> for the right platform in Leap’s data directory. Their version matches the version of the Aspire libraries used in Leap.</li><li>With a bit of reflection, we create custom IOptions&lt;DcpOptions&gt; so that Aspire app hosts use these downloaded binaries.</li><li>Finally, we ensured <a href="https://github.com/dotnet/aspire/blob/v9.2.1/src/Aspire.Hosting/Dcp/DcpOptions.cs#L131-L133">our custom options are used</a> instead of the assembly metadata by setting the configuration property DcpPublisher:CliPath.</li></ul><pre>// These are the assembly metadata values injected by Aspire at build time.<br>// Thankfully, we could craft a custom instance of the internal DcpOptions class to override them.<br>[assembly: AssemblyMetadata(&quot;dcpclipath&quot;, &quot;/root/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.2.0/tools/dcp&quot;)]<br>[assembly: AssemblyMetadata(&quot;dcpextensionpaths&quot;, &quot;/root/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.2.0/tools/ext/&quot;)]<br>[assembly: AssemblyMetadata(&quot;dcpbinpath&quot;, &quot;/root/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.2.0/tools/ext/bin/&quot;)]<br>[assembly: AssemblyMetadata(&quot;apphostprojectpath&quot;, &quot;/actions-runner/_work/wl-leap/wl-leap/src/Leap.Cli&quot;)]<br>[assembly: AssemblyMetadata(&quot;apphostprojectname&quot;, &quot;Leap.Cli.csproj&quot;)]<br>[assembly: AssemblyMetadata(&quot;aspiredashboardpath&quot;, &quot;/root/.nuget/packages/aspire.dashboard.sdk.linux-x64/9.2.0/tools/Aspire.Dashboard&quot;)]<br>[assembly: AssemblyMetadata(&quot;apphostprojectbaseintermediateoutputpath&quot;, &quot;/actions-runner/_work/wl-leap/wl-leap/src/Leap.Cli/obj/&quot;)]</pre><h4>Reimagining .NET project orchestration</h4><p>Aspire’s default .NET project orchestration assumes a single .NET solution, and that all referenced projects are already built. Our requirements were more complex — <strong>support for multiple repositories, arbitrary project paths, projects not yet built </strong>— sometimes freshly cloned.</p><p>We ended up rebuilding the default ProjectResource from scratch:</p><ul><li>Built on top of the built-in ExecutableResource.</li><li>dotnet watch (default) or dotnet run support with automatic retries for build-race conditions (CS2012 compilation error).</li><li>Support for debugging on application startup with a custom command that injects a custom <a href="https://github.com/dotnet/runtime/blob/main/docs/design/features/host-startup-hook.md">.NET startup hook</a> to wait for a debugger to attach.</li><li>No launch profiles as we trusted Leap to provide startup environment variables, like DOTNET_ENVIRONMENT.</li><li>Custom configuration for ASP.NET Core URLs and the Kestrel certificate path.</li></ul><pre>// Part of our custom .NET project resource implementation - there&#39;s a lot more<br>internal static class DotnetExecutableResourceExtensions<br>{<br>    public static IResourceBuilder&lt;DotnetExecutableResource&gt; AddDotnetExecutable(<br>        this IDistributedApplicationBuilder builder, [ResourceName] string name, string workingDirectory, string projectPath, bool watch)<br>    {<br>        string[] args = watch<br>            ? [&quot;watch&quot;, &quot;--project&quot;, projectPath, &quot;--no-launch-profile&quot;, &quot;--non-interactive&quot;, &quot;--no-hot-reload&quot;]<br>            : [&quot;run&quot;, &quot;--project&quot;, projectPath, &quot;--no-launch-profile&quot;];<br><br>        var resource = new DotnetExecutableResource(name, &quot;dotnet&quot;, workingDirectory);<br><br>        return builder.AddResource(resource).WithArgs(args);<br>    }<br><br>    // [...]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*653NHkTl7PE3WMP9Gm1TEA.png" /><figcaption>Our custom command to attach to the debugger on startup prints the process ID in the logs.</figcaption></figure><h3>Dynamic Docker Compose integration</h3><p>We encountered some bugs and limitations with the built-in Aspire container support in the first previews, especially with teams dealing with large numbers of containers. We decided to <strong>rewrite the container orchestration on top of Docker Compose</strong> with custom Aspire resources:</p><ul><li>Generated Docker Compose files dynamically based on declared containerized services in the discovered leap.yaml configurations.</li><li>Streamed logs, container status, and metadata to the Aspire dashboard in real time using <a href="https://github.com/dotnet/Docker.DotNet">Docker.DotNet library</a>.</li><li>Managed the container lifecycle independently of the dashboard lifecycle (containers are persistent by default).</li><li>All containers shared the same network.</li><li>Re-implemented built-in dashboard commands for starting, stopping, and restarting containers.</li><li>Configured extra hosts <a href="https://anthonysimmon.com/dotnet-aspire-containers-share-custom-hosts/">so that containers can resolve custom domains</a>.</li><li>Configured certificate file mounts to support <a href="https://anthonysimmon.com/dotnet-aspire-containers-trust-self-signed-certificates/">per-user trusted HTTPS from end-to-end</a>.</li><li>Configured OpenTelemetry the way Aspire does by passing the right environment variables.</li><li>Modeled the Docker Compose YAML specification using <a href="https://github.com/aaubry/YamlDotNet">YamlDotNet</a>.</li></ul><p>This approach has proven <strong>extremely performant and reliable</strong>. At first, we started Docker Compose before the dashboard, which could be slow depending on how many images had to be pulled. At some point, we realized we could launch the dashboard right away and let a custom Aspire lifecycle hook take care of individually starting each Docker Compose service, which made Leap very snappy.</p><p>Maybe, in the future, we’ll consider going back to the built-in Aspire container support. But you know the saying: <em>If it ain’t broke, don’t fix it.</em></p><pre># Leap transforms this leap.yaml file...<br>services:<br>  aspnetapp:<br>    ingress:<br>      host: aspnetapp.workleap.localhost<br>    runners:<br>      - type: docker<br>        image: mcr.microsoft.com/dotnet/samples:aspnetapp<br>        containerPort: 8080<br>        protocol: https<br><br># Into this dynamically generated Docker Compose file:<br>name: &quot;leap&quot;<br>services:<br>  aspnetapp:<br>    image: &quot;mcr.microsoft.com/dotnet/samples:aspnetapp&quot;<br>    container_name: aspnetapp-e385ce4e<br>    security_opt:<br>    - no-new-privileges:true<br>    restart: no<br>    pull_policy: missing<br>    extra_hosts:<br>    - host.docker.internal:host-gateway<br>    - aspnetapp.workleap.localhost:host-gateway<br>    environment:<br>      ASPNETCORE_URLS: &quot;https://*:8080&quot;<br>      PORT: &quot;8080&quot;<br>      OTEL_SERVICE_NAME: &quot;aspnetapp&quot;<br>      OTEL_EXPORTER_OTLP_PROTOCOL: &quot;grpc&quot;<br>      OTEL_EXPORTER_OTLP_ENDPOINT: &quot;https://host.docker.internal:18889&quot;<br>      OTEL_EXPORTER_OTLP_HEADERS: &quot;x-otlp-api-key=leap&quot;<br>      OTEL_BLRP_SCHEDULE_DELAY: &quot;1000&quot;<br>      OTEL_BSP_SCHEDULE_DELAY: &quot;1000&quot;<br>      OTEL_METRIC_EXPORT_INTERVAL: &quot;1000&quot;<br>      OTEL_TRACES_SAMPLER: &quot;always_on&quot;<br>      OTEL_METRICS_EXEMPLAR_FILTER: &quot;trace_based&quot;<br>      NODE_EXTRA_CA_CERTS: &quot;/etc/ssl/certs/ca-certificates.crt&quot;<br>      ASPNETCORE_Kestrel__Certificates__Default__Path: &quot;/etc/ssl/certs/leap-certificate.crt&quot;<br>      ASPNETCORE_Kestrel__Certificates__Default__KeyPath: &quot;/etc/ssl/certs/leap-certificate.key&quot;<br>      DOTNET_ENVIRONMENT: &quot;Local&quot;<br>      Logging__LogLevel__System.Net.Http.HttpClient.OtlpMetricExporter: &quot;Warning&quot;<br>      Logging__LogLevel__System.Net.Http.HttpClient.OtlpTraceExporter: &quot;Warning&quot;<br>      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: &quot;true&quot;<br>      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: &quot;true&quot;<br>      OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: &quot;in_memory&quot;<br>      OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_DISABLE_URL_QUERY_REDACTION: &quot;true&quot;<br>      OTEL_DOTNET_EXPERIMENTAL_HTTPCLIENT_DISABLE_URL_QUERY_REDACTION: &quot;true&quot;<br>      DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: &quot;true&quot;<br>      LOGGING__CONSOLE__FORMATTERNAME: &quot;simple&quot;<br>      LOGGING__CONSOLE__FORMATTEROPTIONS__TIMESTAMPFORMAT: &quot;yyyy-MM-ddTHH:mm:ss.fffffff &quot;<br>      IDENTITY_ENDPOINT: &quot;http://host.docker.internal:6501/token&quot;<br>      IMDS_ENDPOINT: &quot;dummy_required_value&quot;<br>      Services__aspnetapp__BaseUrl: &quot;https://aspnetapp.workleap.localhost:1347&quot;<br>    ports:<br>    - &quot;55336:8080&quot;<br>    volumes:<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/ssl/certs/ca-certificates.crt:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/pki/tls/certs/ca-bundle.crt:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/ssl/ca-bundle.pem:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/pki/tls/cacert.pem:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate-ca.crt:/etc/ssl/cert.pem:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate.crt:/etc/ssl/certs/leap-certificate.crt:ro&quot;<br>    - &quot;C:\\Users\\anthony.simmon\\.leap\\generated\\certificates\\leap-certificate.key:/etc/ssl/certs/leap-certificate.key:ro&quot;<br>networks:<br>  default:<br>    name: leap<br>    driver: bridge</pre><h3>Certificate management and secure communication</h3><p>HTTPS is built into ASP.NET Core, and our teams were used to configuring HTTPS for frontend dev servers too. This is why we implemented a <strong>future-proof local certificate management system</strong> that:</p><ul><li>Automatically installs <a href="https://github.com/FiloSottile/mkcert">mkcert</a> on Windows (instructions are provided on Unix-like platforms).</li><li>Uses mkcert to create and install a local certificate authority if not already created and installed.</li><li>Generates wildcard certificates for custom local domains (e.g., *.workleap.localhost).</li><li>Uses a PEM certificate format with a private key instead of PFX and the default changeit password for better compatibility.</li><li>Certificates also support container hostnames like host.docker.internal.</li><li>Distributes certificates to both containerized services and services running on the host.</li><li><a href="https://anthonysimmon.com/programmatically-elevate-dotnet-app-on-any-platform/">Requests administrative rights</a> when needed to update the system hosts file according to the domains specified in leap.yaml files.</li></ul><p>This is how we <strong>put an end to custom local certificate management scripts</strong> in several repositories.</p><h3>YARP reverse proxy integration</h3><p>To solve the port management challenge and to support custom domains, we built an integration for <a href="https://github.com/dotnet/yarp">YARP</a>, a <strong>high-performance HTTP reverse proxy</strong> to create a single entry point for all services. Developers <strong>must only remember a single port</strong>, 1347, which stands for “leap” in <a href="https://en.wikipedia.org/wiki/Leet">leetspeak</a>.</p><p>Our YARP integration enables:</p><ul><li>Routing requests to services based on the requested host.</li><li>Routing requests to services on the same domain but different paths (e.g., /api).</li><li>Header preservation for distributed tracing (passthrough).</li><li><a href="https://anthonysimmon.com/securely-reverse-proxy-aspnet-core-web-apps/">Preserving the original IP address, host, protocol, and path prefix</a>.</li><li>Automatic HTTP/HTTPS redirection.</li><li>Custom domain support with a single port and Leap’s certificate.</li><li>Teams to practice their CORS and cookie policies.</li></ul><p>Developers can still specify specific localhost ports for their services in leap.yaml files. This was part of an effort to ease the migration to Leap. Ideally, they let Leap assign random ports to their services on localhost.</p><h3>Cloud emulators and third-party dependencies</h3><p>For the most commonly used cloud services and databases our applications depend on, we created custom Aspire resources that provide local emulation:</p><ul><li>MongoDB <a href="https://anthonysimmon.com/the-only-local-mongodb-replica-set-with-docker-compose-guide-youll-ever-need/">configured as a single-node replica set</a> for transactions and change streams support.</li><li><a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite">Azurite</a> (Azure Storage emulator) on HTTPS, which enables Azure Identity support (DefaultAzureCredential, etc.) without connection strings or any kind of secrets.</li><li>Redis with local-development optimized configuration.</li><li>Our <a href="https://github.com/workleap/wl-eventgrid-emulator">Azure Event Grid emulator</a> with declarative topics and subscription management in YAML. Topics and subscriptions from all leap.yaml files are automatically merged by Leap at startup time.</li><li>SQL Server and PostgreSQL.</li></ul><p>All of these are powered by our custom Docker Compose integration, so they are persistent and use volumes by default. They always start first, and other services depend on them using Aspire’s WaitFor feature.</p><p>For each dependency, we decided to use distinct fixed, well-known ports than the default ones. This way, Leap does not conflict with existing local setups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNWg1G9O2n3AFrLeFgOtJQ.png" /><figcaption>We fine-tuned each dependency to provide the best local development experience.</figcaption></figure><h3>Azure CLI integration</h3><p>At Workleap, we use Azure identities to access Azure resources in production. This approach is <strong>more secure than using connection strings and secrets</strong>. During local development, developers use the Azure CLI, which authenticates against Microsoft Entra ID with their credentials. Services would then use the Azure SDK with DefaultAzureCredential to access them.</p><p>We quickly identified a <strong>significant performance bottleneck</strong>: DefaultAzureCredential takes up to 10 seconds to initialize when using Azure CLI credentials, causing frustrating delays during frequent service restarts. To solve this, we implemented a <a href="https://anthonysimmon.com/dotnet-aspire-better-azure-identity-support/">custom Aspire resource that acts as an Azure managed credential proxy between services to access local Azure CLI credentials</a>. This <strong>reduces Azure credentials lookup time from 10 seconds to less than one second</strong>. It also allows containerized services to access Azure CLI credentials from the host machine, which is publicly known to be incredibly difficult to achieve.</p><h3>Prioritizing developer experience and reliability</h3><p>When building development tools, reliability is essential. Leap was meant to become a critical part of our developers’ daily workflow, and any flakiness directly impacts productivity, causes frustration, and eventually damages trust in the tool and the team behind it. We approached Leap’s design with the <strong>same standards we would apply to production services</strong>.</p><h3>Performance and reactivity</h3><p>Developers have high expectations from their tools. Leap can open the dashboard in a matter of seconds. For many months, very few bugs have been reported. Our strict adherence to C# null-reference types, zero-trust stance toward user input, and our <a href="https://github.com/workleap/wl-dotnet-codingstandards">.NET coding standards</a> has significantly contributed to this stability. Some developers keep Leap open all day long and leverage start, stop, and restart commands, as well as dotnet watch, to restart their services. Cancellation tokens are used everywhere to ensure that long-running tasks can be interrupted gracefully at any time.</p><h3>Robust error handling and pragmatic testing</h3><p>We implemented a comprehensive error handling system that:</p><ul><li>Provides clear, actionable error messages for common failures or misconfigurations.</li><li>Includes a customizable verbosity level to access Aspire logs when needed.</li><li>Makes errors as actionable as possible.</li></ul><p>We have almost no unit tests. Most of our confidence in changes comes from a few integration tests where we start Leap for real. They cover many critical paths and use cases on the three main operating systems. This proved to be a worthwhile choice and allowed us to evolve the tool very quickly.</p><h3>Telemetry for product improvement</h3><p>To continuously improve Leap, we implemented an OpenTelemetry-based telemetry system that collects anonymous usage data. This data provides invaluable insights into:</p><ul><li>How many developers actively use Leap.</li><li>Which features and dependencies are most valuable.</li><li>Performance metrics and statistics.</li><li>Spans for HTTP requests and child processes.</li></ul><h3>Preemptive environment verification</h3><p>Many local development issues are caused by misconfigured environments. Leap proactively checks for:</p><ul><li>Docker to be up and running, ready to accept connections.</li><li>Whether developers are authenticated in Azure CLI.</li><li>Whether developers are authenticated against container registries.</li><li>Available Leap updates (npm style).</li></ul><p>When issues are detected, Leap provides specific guidance on how to resolve them.</p><h3>Conclusion</h3><p>While we didn’t use Aspire in its conventional form, our changes demonstrate its <strong>flexibility as a foundation for developer tooling</strong>. By extending and customizing its core components, we created a solution that aligns with our organization’s needs. The beauty of this approach is that <strong>developers can leverage Aspire’s powerful capabilities without needing to learn how it works</strong>. This abstraction allows our teams to focus on what they do best.</p><p>Building Leap with .NET Aspire has been a transformative experience. Aspire’s orchestration capabilities, combined with its extensible application model, allowed us to create a <strong>robust developer experience</strong> that would have been nearly impossible to build from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*WA-wL-Qkk5eN2k6xIICNig.png" /><figcaption>Leap logo after it became an internal brand at Workleap.</figcaption></figure><p>Today, Leap has evolved beyond a tool into an <strong>internal brand at Workleap</strong>, embodying our Platform Engineering team’s <em>platform as a product</em> philosophy. While this article focused on local development, Leap’s scope has expanded to include project scaffolding, CI/CD integration, and a robust developer portal. By approaching our internal developer platform with the same care and user focus we apply to customer-facing products, we’ve created a solution our teams genuinely enjoy using — accelerating collaboration and value delivery across the organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f73cb48f6673" width="1" height="1" alt=""><hr><p><a href="https://medium.com/workleap/how-workleap-uses-net-aspire-to-transform-local-development-f73cb48f6673">How Workleap uses .NET Aspire to transform local development</a> was originally published in <a href="https://medium.com/workleap">Workleap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Must-have resources for new .NET Aspire developers]]></title>
            <link>https://medium.com/@asimmon/must-have-resources-for-new-net-aspire-developers-b2cb5c8fb72a?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2cb5c8fb72a</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[aspire]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Mon, 27 May 2024 11:02:22 GMT</pubDate>
            <atom:updated>2024-05-27T11:02:22.516Z</atom:updated>
            <content:encoded><![CDATA[<h3>Must-have resources for new .NET Aspire developers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FScWYGbqSychFBzoBxME7g.jpeg" /><figcaption>From left to right: .NET Aspire documentation, David Fowler and Damian Edwards during an ASP.NET Community Standup, Aspireify.NET and Nick Chapsas on YouTube.</figcaption></figure><p>Six months after its first preview released during .NET Conf 2023, .NET Aspire becomes generally available (GA) at Microsoft Build 2024. This project, which aims to revolutionize the local development of distributed applications, has unfortunately been overlooked by some due to its preview status. This is good news for those who can now embark on the adventure. Here are some resources to learn how to use .NET Aspire.</p><h3>.NET Aspire official documentation</h3><p>The best place to start learning .NET Aspire is <a href="https://learn.microsoft.com/dotnet/aspire/">the official documentation</a>. It includes an overview, a quickstart guide, dives into conceptual details and much more.</p><h3>Official videos on the Microsoft YouTube channels</h3><p>Not a fan of reading? Microsoft has published videos throughout the development of .NET Aspire. You can understand what problem it tries to solve, how the .NET team arrived at this solution, how to use it, and what the vision for the future is.</p><ul><li><a href="https://aka.ms/aspire/videos">Welcome to .NET Aspire video series</a>, a series of 9 videos released at the Microsoft Build 2024.</li><li><a href="https://youtu.be/z1M-7Bms1Jg">Building Cloud Native apps with .NET 8 | .NET Conf 2023</a>, November 15, 2023.</li><li><a href="https://www.youtube.com/live/KEcUfMbCgpA">ASP.NET Community Standup — .NET Aspire Update</a>, January 23, 2024.</li><li><a href="https://www.youtube.com/live/kAF9No5KZrg">ASP.NET Community Standup — .NET Aspire in action</a>, February 6, 2024.</li><li><a href="https://www.youtube.com/live/Osf7_ZxRlvw">ASP.NET Community Standup: .NET Aspire Update</a>, April 16, 2024.</li><li><a href="https://youtu.be/uryJN7UEn4M">Deploy distributed .NET apps to the cloud with .NET Aspire and Azure Container Apps</a>, April 10, 2024.</li></ul><h3>Official code samples on GitHub</h3><p>The <a href="https://github.com/dotnet/aspire-samples">official samples repository</a> contains valuable examples and demonstrates a small portion of the possibilities offered by .NET Aspire:</p><ul><li>A real-world example of a distributed application with microservices,</li><li>JavaScript frontends and Node.js backends integration,</li><li>Desktop apps integration,</li><li>Various databases integration,</li><li>Dapr integration and more.</li></ul><h3>Community videos</h3><p>.NET Aspire has generated a lot of enthusiasm in the community. Here are some videos from developers who have experimented with .NET Aspire and share their experiences.</p><ul><li><a href="https://youtu.be/DORZA_S7f9w">What Is .NET Aspire? The Insane Future of .NET!</a> by Nick Chapsas, November 19, 2023.</li><li><a href="https://youtu.be/8aG410nmjtQ">First Look at .NET Aspire — Distributed Applications in .NET 8</a> by Milan Jovanović, December 26, 2023.</li><li><a href="https://youtu.be/fN3ufsIF7vs">WHY and HOW to Add .NET Aspire to ANY .NET API and Web App in Minutes</a> by James Montemagno, April 18, 2024.</li><li><a href="https://youtu.be/J02mvcEKrsI">Cloud-native apps with .NET Aspire</a> by Layla Porter, November 26, 2023.</li><li><a href="https://www.youtube.com/live/dJ4uEANZIdQ">Learn C# with CSharpFritz: Introducing .NET Aspire</a> by Jeff Fritz, May 8, 2024.</li></ul><h3>David Fowler’s experiments on GitHub</h3><p>Do you want deep technical content about .NET Aspire? Watch how David Fowler pushes the limits of the .NET Aspire application model in these advanced scenarios. In my opinion, some of this content should be integrated into .NET Aspire.</p><ul><li><a href="https://github.com/davidfowl/AspireWithRedis">How to use .NET Aspire with Redis</a>.</li><li><a href="https://github.com/davidfowl/AspireYarp">How to use YARP with .NET Aspire to route between services</a>.</li><li><a href="https://github.com/davidfowl/AspireSwaggerUI">How to use .NET Aspire to show a Swagger UI for any resource that exposes an OpenAPI endpoint</a>.</li><li><a href="https://github.com/davidfowl/WaitForDependenciesAspire">How to extend .NET Aspire application model to enable waiting for dependencies to be available before starting the application</a>.</li><li><a href="https://github.com/davidfowl/EventGridDemo">How to use .NET Aspire to deploy Event Grid for local use then publish and subscribe events between resources</a>.</li><li><a href="https://github.com/davidfowl/AspireEventHub">How to use and deploy Event Hubs, which is a resource that doesn’t exist in .NET Aspire by default</a>.</li><li><a href="https://github.com/davidfowl/AspirePulumi">A prototype using Pulumi and .NET Aspire together for local development</a>.</li></ul><h3>My blog posts</h3><p>Since the launch of .NET Aspire, I’ve written several articles on the subject. Here are some of my favorites:</p><ul><li><a href="https://anthonysimmon.com/exploring-microsoft-developer-control-plane-core-dotnet-aspire-dotnet-8/">Exploring the Microsoft Developer Control Plane at the heart of the new .NET Aspire</a>, November 21, 2023.</li><li><a href="https://anthonysimmon.com/dotnet-aspire-dashboard-best-tool-visualize-opentelemetry-local-dev/">.NET Aspire dashboard is the best tool to visualize your OpenTelemetry data during local development</a>, March 25, 2024.</li><li><a href="https://anthonysimmon.com/dotnet-aspire-best-way-to-experiment-dapr-local-dev/">.NET Aspire is the best way to experiment with Dapr during local development</a>, April 29, 2024.</li><li><a href="https://anthonysimmon.com/referencing-external-docker-containers-dotnet-aspire-custom-resources/">Referencing external Docker containers in .NET Aspire using the new custom resources API</a>, April 11, 2024.</li><li><a href="https://anthonysimmon.com/running-ruby-on-rails-with-dotnet-aspire/">Running Ruby on Rails web apps with .NET Aspire</a>, April 18, 2024.</li></ul><h3>More blog posts, online resources and projects</h3><p>There are many other online resources to learn .NET Aspire. Here are some of my recommendations:</p><ul><li><a href="https://devblogs.microsoft.com/dotnet/dotnet-aspire-general-availability/">General Availability of .NET Aspire: Simplifying .NET Cloud-Native Development</a>, by Damian Edwards.</li><li><a href="https://aka.ms/aspire/learn">.NET Aspire Learn Path</a>, the official collection of learning resources for .NET Aspire.</li><li><a href="https://aspireify.net/">Aspireify.NET</a>, a .NET Aspire content aggregator by Jeff Fritz.</li><li><a href="https://devblogs.microsoft.com/dotnet/category/dotnet-aspire/">.NET Aspire announcements &amp; articles on Microsoft’s .NET blog</a>.</li><li><a href="https://blog.jetbrains.com/dotnet/2024/02/19/jetbrains-rider-and-the-net-aspire-plugin/">JetBrains Rider and the .NET Aspire Plugin</a>, because not everyone uses Visual Studio.</li><li><a href="https://tonybaloney.github.io/posts/using-dotnet-aspire-dashboard-for-python-opentelemetry.html">Using the Aspire Dashboard for Python OpenTelemetry tracing, metrics, and logs</a> by Anthony Shaw.</li><li><a href="https://github.com/prom3theu5/aspirational-manifests#aspirate-aspir8">Aspirate</a>, a tool that can generate kustomize manifests for deploying aspire apps to Kubernetes, by David Sekula.</li></ul><h3>Social networks</h3><p>If you want to stay updated with the latest news on .NET Aspire and discover what the community is building with it, I recommend following the news on X: <a href="https://x.com/hashtag/aspire">#aspire</a> and more recently <a href="https://x.com/hashtag/dotnetaspire">#dotnetaspire</a>.</p><p>You can also follow the people who work closely on .NET Aspire:</p><ul><li><a href="https://twitter.com/davidfowl">David Fowler</a>, Distinguished Engineer at Microsoft.</li><li><a href="https://twitter.com/DamianEdwards">Damian Edwards</a>, Principal Architect at Microsoft.</li><li><a href="https://twitter.com/timheuer">Tim Heuer</a>, Principal Product Manager Lead at Microsoft.</li><li><a href="https://twitter.com/davidpine7">David Pine</a>, Senior Content Developer at Microsoft.</li><li><a href="https://twitter.com/jamesnk">James Newton-King</a>, Principal Software Engineer at Microsoft.</li><li><a href="https://twitter.com/eehardt">Eric Erhardt</a>, Principal Software Engineer at Microsoft.</li></ul><h3>.NET Aspire’s source code</h3><p>The <a href="https://github.com/dotnet/aspire">.NET Aspire repository on GitHub</a> is the source of truth for understanding how it works. I strongly encourage you to explore it in your browser or in your IDE via SourceLink.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2cb5c8fb72a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TreatWarningsAsErrors and warnaserror are not the same]]></title>
            <link>https://medium.com/@asimmon/treatwarningsaserrors-and-warnaserror-are-not-the-same-2cfa8f44282d?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cfa8f44282d</guid>
            <category><![CDATA[msbuild]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[csproj]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Wed, 10 Apr 2024 13:32:02 GMT</pubDate>
            <atom:updated>2024-04-10T13:32:02.008Z</atom:updated>
            <content:encoded><![CDATA[<p>At work, my team recently developed a <a href="https://github.com/gsoft-inc/wl-openapi-msbuild">custom MSBuild task</a> designed to extract the OpenAPI specification from an ASP.NET Core application during compilation and validate it against <a href="https://github.com/gsoft-inc/wl-api-guidelines">our API design guidelines</a> with <a href="https://docs.stoplight.io/docs/spectral/">Spectral</a>.</p><p>When a Spectral rule is violated, the MSBuild task generates a warning. To ensure developers fix these issues, we planned for these warnings to be treated as errors in their CI pipeline. To achieve this, we relied on the TreatWarningsAsErrors property, which is already widely used in our projects.</p><p>Surprisingly, we discovered that the build of some projects did not fail despite the presence of warnings related to non-compliance with the OpenAPI specification. Here are the findings of my investigation.</p><h3>TreatWarningsAsErrors only impacts the C# compiler</h3><p>Indeed, the <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#treatwarningsaserrors">Microsoft documentation</a> is clear on this matter:</p><blockquote><em>TreatWarningsAsErrors only impacts the C# compiler, not any other MSBuild tasks in your csproj file. The </em><em>warnaserror command line switch impacts all tasks.</em></blockquote><p>If you want to ensure that there are absolutely no warnings in your build, you must include the -warnaserror argument:</p><pre>dotnet build -warnaserror</pre><h3>-warnaserror can produce output on errors, TreatWarningsAsErrors does not</h3><p>The same documentation states:</p><blockquote><em>Secondly, the compiler doesn’t produce any output on any warnings when </em><em>TreatWarningsAsErrors is used. The compiler produces output when the </em><em>warnaserror command line switch is used.</em></blockquote><p>If you still wish to produce an assembly, despite there being warnings treated as errors, you can set TreatWarningsAsErrors to false and use -warnaserror instead.</p><h3>References</h3><ul><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings">C# Compiler Options to report errors and warnings</a></li><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings">C# Compiler Options to report errors and warnings</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cfa8f44282d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Locally test and validate your Renovate configuration files]]></title>
            <link>https://medium.com/@asimmon/locally-test-and-validate-your-renovate-configuration-files-3cd4429b63e2?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cd4429b63e2</guid>
            <category><![CDATA[renovate]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 13:32:47 GMT</pubDate>
            <atom:updated>2024-04-09T13:32:47.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKTzpfJVWWs_Y84msEdm1w.jpeg" /><figcaption>Console output of Renovate running locally in dry run mode</figcaption></figure><p><a href="https://github.com/renovatebot/renovate">Renovate</a> is an automated dependency management tool that can be used to keep your dependencies up-to-date. It can be configured to automatically create pull requests to update your dependencies, and it supports a wide range of package managers and platforms.</p><p>To use Renovate, you need to create a <a href="https://docs.renovatebot.com/configuration-options/">renovate.json configuration file</a>. The creation process can take some time, as there are many configuration options available. Depending on the complexity of your project, the package managers you use, your platform (GitHub, GitLab, Azure DevOps, etc.), and your specific needs, you may need to go through several iterations to get a configuration that works well for you.</p><p>In this article, we will see how to test and validate your Renovate configuration files locally, to avoid having to push changes to your source control and wait for your pipeline to see if Renovate works as intended.</p><h3>Prerequisites</h3><p>We will be using the <a href="https://docs.renovatebot.com/examples/self-hosting/">self-hosted version of Renovate</a> distributed via npm, but you can adapt the scripts in this article to use the Docker version, or others. Make sure you have <a href="https://nodejs.org/">Node.js</a> installed on your machine.</p><p>You also need a project with a Renovate configuration file, of course. For demonstration purposes, we will use a .NET project that contains a single dependency on an older version of <a href="https://www.nuget.org/packages/Microsoft.Extensions.Hosting">Microsoft.Extensions.Hosting</a>:</p><pre>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;<br>  &lt;PropertyGroup&gt;<br>    &lt;TargetFramework&gt;net8.0&lt;/TargetFramework&gt;<br>  &lt;/PropertyGroup&gt;<br><br>  &lt;ItemGroup&gt;<br>    &lt;!-- The most recent version of Microsoft.Extensions.Hosting is 8.0.0 as of this writing. --&gt;<br>    &lt;PackageReference Include=&quot;Microsoft.Extensions.Hosting&quot; Version=&quot;7.0.0&quot; /&gt;<br>  &lt;/ItemGroup&gt;<br>&lt;/Project&gt;</pre><p>Next, let’s create a renovate.json file at the root:</p><pre>{<br>  &quot;$schema&quot;: &quot;https://docs.renovatebot.com/renovate-schema.json&quot;,<br>  &quot;extends&quot;: [<br>    &quot;config:best-practices&quot;<br>  ],<br>  &quot;enabledManagers&quot;: [<br>    &quot;nuget&quot;<br>  ]<br>}</pre><p>This simplistic Renovate configuration will serve as our example. Use your own Renovate configuration file if you already have one.</p><h3>Launching Renovate locally</h3><p>It is possible to run Renovate locally to test your configuration. To do this, we will use the following command for Linux and macOS:</p><pre>LOG_LEVEL=debug npx renovate --platform=local --repository-cache=reset</pre><p>For Windows using PowerShell Core, use this command:</p><pre>pwsh -Command { $env:LOG_LEVEL=&quot;debug&quot;; npx renovate --platform=local --repository-cache=reset }</pre><p>The three important points to remember here are:</p><ul><li>LOG_LEVEL=debug is used to obtain additional debugging information. Thanks to this environment variable, Renovate will display the updates available for the packages.</li><li>--platform=local is used to perform a <a href="https://docs.renovatebot.com/modules/platform/local/">dry run</a> on the local computer.</li><li>--repository-cache=reset is used to force Renovate to ignore the cache. This can avoid incorrect results between your different modifications of your configuration.</li></ul><h3>Reading the Renovate output logs</h3><p>In the .NET project of our example, we intentionally used an older version of Microsoft.Extensions.Hosting (7.0.0) so that Renovate could find an update. Here is an excerpt from the Renovate logs:</p><pre>DEBUG: packageFiles with updates (repository=local)<br>       &quot;config&quot;: {<br>         &quot;nuget&quot;: [<br>           {<br>             &quot;deps&quot;: [<br>               {<br>                 &quot;datasource&quot;: &quot;nuget&quot;,<br>                 &quot;depType&quot;: &quot;nuget&quot;,<br>                 &quot;depName&quot;: &quot;Microsoft.Extensions.Hosting&quot;,<br>                 &quot;currentValue&quot;: &quot;7.0.0&quot;,<br>                 &quot;updates&quot;: [<br>                   {<br>                     &quot;bucket&quot;: &quot;non-major&quot;,<br>                     &quot;newVersion&quot;: &quot;7.0.1&quot;,<br>                     &quot;newValue&quot;: &quot;7.0.1&quot;,<br>                     &quot;releaseTimestamp&quot;: &quot;2023-02-14T13:21:52.713Z&quot;,<br>                     &quot;newMajor&quot;: 7,<br>                     &quot;newMinor&quot;: 0,<br>                     &quot;updateType&quot;: &quot;patch&quot;,<br>                     &quot;branchName&quot;: &quot;renovate/dotnet-monorepo&quot;<br>                   },<br>                   {<br>                     &quot;bucket&quot;: &quot;major&quot;,<br>                     &quot;newVersion&quot;: &quot;8.0.0&quot;,<br>                     &quot;newValue&quot;: &quot;8.0.0&quot;,<br>                     &quot;releaseTimestamp&quot;: &quot;2023-11-14T13:23:17.653Z&quot;,<br>                     &quot;newMajor&quot;: 8,<br>                     &quot;newMinor&quot;: 0,<br>                     &quot;updateType&quot;: &quot;major&quot;,<br>                     &quot;branchName&quot;: &quot;renovate/major-dotnet-monorepo&quot;<br>                   }<br>                 ],<br>                 &quot;packageName&quot;: &quot;Microsoft.Extensions.Hosting&quot;,<br>                 &quot;versioning&quot;: &quot;nuget&quot;,<br>                 &quot;warnings&quot;: [],<br>                 &quot;sourceUrl&quot;: &quot;https://github.com/dotnet/runtime&quot;,<br>                 &quot;registryUrl&quot;: &quot;https://api.nuget.org/v3/index.json&quot;,<br>                 &quot;homepage&quot;: &quot;https://dot.net/&quot;,<br>                 &quot;currentVersion&quot;: &quot;7.0.0&quot;,<br>                 &quot;isSingleVersion&quot;: true,<br>                 &quot;fixedVersion&quot;: &quot;7.0.0&quot;<br>               }<br>             ],<br>             &quot;packageFile&quot;: &quot;RenovateDemo.csproj&quot;<br>           }<br>         ]<br>       }</pre><p>Notice how config.nuget[0].deps[0].updates contains two updates for Microsoft.Extensions.Hosting: one for a patch update (7.0.1) and one for a major update (8.0.0). This is the type of information you can expect to see when you run Renovate locally. The output might be more detailed or contain more information depending on your configuration and the packages you use.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cd4429b63e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remove git hash from assembly informational version in .NET 8]]></title>
            <link>https://medium.com/@asimmon/remove-git-hash-from-assembly-informational-version-in-net-8-8f43cd231665?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f43cd231665</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 13:31:58 GMT</pubDate>
            <atom:updated>2024-04-08T13:31:58.124Z</atom:updated>
            <content:encoded><![CDATA[<h3>Remove git hash from assembly informational version in .NET 8</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFcgA8amhOrKZRZ8QRZtBA.png" /><figcaption>Since .NET 8, a git hash can appear in the assembly informational version</figcaption></figure><p>If you build your .NET projects with the .NET 8 SDK, you may have noticed that the <a href="https://learn.microsoft.com/en-us/dotnet/standard/assembly/set-attributes#informational-attributes">assembly informational version</a> now includes the <strong>git hash of the associated commit</strong>:</p><pre>var informationalVersion = typeof(Program).Assembly<br>    .GetCustomAttribute&lt;AssemblyInformationalVersionAttribute&gt;()<br>    .InformationalVersion;<br><br>Console.WriteLine(informationalVersion);<br><br>// Prints something like<br>// 1.0.0+9aa8e4c69145f5b7b4b59c93f2a1ee5ea19b79f9</pre><p>This is a <strong>breaking change</strong> in the .NET 8 SDK, which now includes <a href="https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link">Source Link by default</a>. Source Link allows packages and applications to embed information about the source control of generated artifacts. This affects any target framework, as long as the code is compiled with the .NET 8 SDK.</p><p>If you had logic that uses the assembly informational version, it might not work at all anymore. To opt out of this feature, you need to add the following property in your .csproj file:</p><pre>&lt;PropertyGroup&gt;<br>  &lt;IncludeSourceRevisionInInformationalVersion&gt;false&lt;/IncludeSourceRevisionInInformationalVersion&gt;<br>&lt;/PropertyGroup&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f43cd231665" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your custom HttpClient delegating handlers should be transient]]></title>
            <link>https://medium.com/@asimmon/your-custom-httpclient-delegating-handlers-should-be-transient-2a3463d0ace7?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a3463d0ace7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 13:31:56 GMT</pubDate>
            <atom:updated>2024-04-05T13:31:56.554Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hedJe1SioNdeDhofrkETMg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mbenna">Mike Benna</a> on <a href="https://unsplash.com/">unsplash</a></figcaption></figure><p>If you&#39;ve ever encountered the following error, this article is for you:</p><blockquote>InvalidOperationException: The &#39;InnerHandler&#39; property must be null. &#39;DelegatingHandler&#39; instances provided to &#39;HttpMessageHandlerBuilder&#39; must not be reused or cached.</blockquote><p>This means you are using the <a href="https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory">Microsoft.Extensions.Http</a> library and have modified an HttpClient&#39;s handler pipeline by inserting a DelegatingHandler. As the error indicates, you cannot reuse a handler across multiple HttpClient instances. In other words, your DelegatingHandler <strong>cannot be a singleton</strong>. Here&#39;s an example of problematic code:</p><pre>internal sealed class MyCustomDelegatingHandler : DelegatingHandler<br>{<br>    // Implementation omitted<br>}<br><br>// Registering the handler as a singleton is the mistake<br>services.AddSingleton&lt;MyCustomDelegatingHandler&gt;();<br><br>services.AddHttpClient(&quot;MyClient&quot;)<br>    .AddHttpMessageHandler&lt;MyCustomDelegatingHandler&gt;();</pre><p>This code is also susceptible to the error mentioned above:</p><pre>// This same instance will be used for all named HttpClient &quot;MyClient&quot;<br>var handler = new MyCustomDelegatingHandler();<br><br>services.AddHttpClient(&quot;MyClient&quot;)<br>    .AddHttpMessageHandler(() =&gt; handler);</pre><p>Let&#39;s try to understand what&#39;s wrong here. The implementation of IHttpClientFactory, the service producing HttpClient instances, constructs the pipeline from multiple DelegatingHandlers making up an HttpClient. Each time an HttpClient is requested, the pipeline <em>may</em> be recreated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pd5w3z6U95GbXBnQ7DVQTg.png" /><figcaption>HttpClient handler pipeline</figcaption></figure><p>Different DelegatingHandlers are linked to each other through the InnerHandler property, thanks to the <a href="https://github.com/dotnet/runtime/blob/v8.0.0/src/libraries/Microsoft.Extensions.Http/src/HttpMessageHandlerBuilder.cs#L81">CreateHandlerPipeline</a> method. This method checks that the InnerHandler property isn&#39;t already set and throws the InvalidOperationException mentioned above if it is.</p><p>Handlers created as part of the IHttpClientFactory implementation are temporarily stored in a cache, for a duration equal to <a href="https://github.com/dotnet/runtime/blob/v8.0.0/src/libraries/Microsoft.Extensions.Http/src/HttpClientFactoryOptions.cs#L58">HttpClientFactoryOptions.HandlerLifetime</a>. By default, <strong>this duration is 2 minutes</strong>. During this time, as many HttpClients as needed can be created and used without issue.</p><p>However, once the handler is removed from the cache, it will go through the CreateHandlerPipeline method again, and if it is a singleton, the InnerHandler property will already be set, leading to the exception being thrown.</p><p>If you control the lifecycle of the HttpClient and only create one throughout the lifespan of your application, you might never notice this issue. But often, developers overlook this aspect and are not aware of the exact context in which their HttpClient is used.</p><p>A particularly noticeable and error-prone example is that of <a href="https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#how-to-use-typed-clients-with-ihttpclientfactory">typed clients</a>. Typed clients are registered using the generic AddHttpClient&lt;TClient&gt; method (and its overloads), but in my experience, few developers realize that the TClient type becomes registered in services with a <strong>transient lifecycle</strong>. Thus, requesting this TClient multiple times will result in the creation of multiple HttpClients, causing the pipeline construction error if one of your delegating handlers is a singleton.</p><p>The solution is simple: ensure that the handler factory passed to the AddHttpMessageHandler method always returns a new instance.</p><pre>// Registering the handler as a transient is the fix<br>services.AddTransient&lt;MyCustomDelegatingHandler&gt;();<br><br>services.AddHttpClient(&quot;MyClient&quot;)<br>    .AddHttpMessageHandler&lt;MyCustomDelegatingHandler&gt;();<br><br>// Or explicitly create a new instance each time<br>services.AddHttpClient(&quot;MyClient&quot;)<br>    .AddHttpMessageHandler(() =&gt; new MyCustomDelegatingHandler());</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a3463d0ace7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to securely reverse-proxy ASP.NET Core web apps]]></title>
            <link>https://medium.com/@asimmon/how-to-securely-reverse-proxy-asp-net-core-web-apps-316e993d221f?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/316e993d221f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 21:17:31 GMT</pubDate>
            <atom:updated>2024-04-04T21:17:31.034Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6uRvmqsNXCzcR8CAoih2g.jpeg" /><figcaption>A Common Kestrel, searching for a prey.</figcaption></figure><p><a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel">Kestrel</a> is the solid, fast, and reliable web server that powers ASP.NET Core applications. It is entirely capable of serving as a front-facing web server, as proven by the Azure teams when they chose Kestrel and YARP to handle <a href="https://devblogs.microsoft.com/dotnet/bringing-kestrel-and-yarp-to-azure-app-services">reverse-proxying all services hosted on Azure App Services</a>.</p><p>However, it’s very unlikely that .NET developers will directly expose their Kestrel-based web apps to the internet. Typically, we use other popular web servers like <a href="https://nginx.org/">Nginx</a>, <a href="https://traefik.io/">Traefik</a>, and <a href="https://caddyserver.com/">Caddy</a> to act as a reverse-proxy in front of Kestrel for various reasons:</p><ul><li>To add a <a href="https://en.wikipedia.org/wiki/TLS_termination_proxy">TLS termination layer</a>: the reverse-proxy manages the TLS encryption and decryption (HTTPS),</li><li>To handle requests on a specific domain and port, often using a virtual host configuration,</li><li>To implement security features such as rate limiting, request filtering, <a href="https://developer.mozilla.org/en-US/docs/Glossary/HSTS">HSTS</a>, etc.,</li><li>To provide request compression and caching, depending on the end-user’s browser capabilities,</li><li>For load balancing, failover support, and response transformation.</li></ul><p>While these features can be configured with Kestrel, managing them across many web apps is more straightforward with a unified configuration point.</p><h3>Understanding the need for header forwarding</h3><p>When placing a reverse-proxy in front of our ASP.NET Core applications, the apps may lose access to certain original HTTP request information, like the client’s IP address, specific HTTP headers, the original domain, and port. We need this information for the proper functioning of our applications.</p><p>This is where the concept of header forwarding comes into play. The reverse-proxy forwards the original HTTP request’s information to the backend application server via specific headers. The most common forwarding headers are:</p><ul><li>X-Forwarded-For: contains the original client&#39;s IP address,</li><li>X-Forwarded-Host: contains the original host requested by the client,</li><li>X-Forwarded-Proto: contains the original protocol (HTTP or HTTPS),</li><li>X-Forwarded-Prefix: contains the original path base used by the client.</li></ul><p>Most ASP.NET Core applications, especially those that are containerized, listen on the loopback address and port 8080. Thus, X-Forwarded-Host and X-Forwarded-Proto are sometimes essential in scenarios where ASP.NET Core needs to generate URLs, such as in Razor templates or when generating redirect links in an OAuth2 authorization flow.</p><p>From a security perspective, X-Forwarded-For is also crucial. Without this header, your application would not be able to obtain the client&#39;s IP address, potentially affecting logging, your authentication and authorization stack, rate limiting logic, etc.</p><h3>How to securely interpret X-Forwarded-* headers in ASP.NET Core</h3><p>Ensuring ASP.NET Core securely interprets X-Forwarded-* headers is vital. Attackers could manipulate these headers to bypass security measures. How can we trust these header values?</p><p>Your reverse-proxy is responsible for stripping these headers from client requests. If not done, an end-user could, for instance, impersonate an IP address. By default, well-configured reverse-proxies don’t accept them and populate these headers with reliable values like the TCP connection and original HTTP headers such as Host.</p><p>Avoid writing your logic to read and interpret X-Forwarded-* headers. ASP.NET Core already includes middleware that handles this securely:</p><pre>// [...]<br>app.UseForwardedHeaders(); // &lt;-- Add this line<br><br>app.UseAuthentication();<br>app.UseAuthorization();<br>// [...]</pre><p>UseForwardedHeaders should be placed before any other middleware, especially before UseHsts, and can follow diagnostics and error handling middlewares.</p><p>Remember to configure the middleware options to specify which headers you wish to forward; otherwise, the middleware will not take any action. For example, to forward X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Proto:</p><pre>builder.Services.Configure&lt;ForwardedHeadersOptions&gt;(options =&gt;<br>{<br>    options.ForwardedHeaders =<br>        ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;<br>});</pre><p>The <a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.forwardedheadersoptions?view=aspnetcore-8.0">ForwardedHeadersOptions</a> are very flexible, allowing you also to change the forwarding headers’ names if you’re not using the standard X-Forwarded-*.</p><p>The <a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.httpoverrides.forwardedheadersmiddleware">ForwardedHeadersMiddleware</a>, inserted via UseForwardedHeaders, automatically updates HTTP request properties like RemoteIpAddress, Host, Scheme, and PathBase.</p><h3>Restricting IP addresses of reverse-proxies authorized to forward headers</h3><p>If you know the IP address or range of your reverse-proxy, you can specify them in the ForwardedHeadersOptions to ensure that the X-Forwarded-* headers come from a trusted source:</p><pre>builder.Services.Configure&lt;ForwardedHeadersOptions&gt;(options =&gt;<br>{<br>    // 10.0.0.100 is the IP address of the reverse proxy<br>    // Use KnownProxies to add individual IP addresses you trust<br>    options.KnownProxies.Add(IPAddress.Parse(&quot;10.0.0.100&quot;));<br><br>    // In case you have a range of IP addresses you trust, you can use KnownNetworks<br>    IPNetwork.Parse(&quot;10.0.0.0/24&quot;);<br>});</pre><h3>References</h3><ul><li><a href="https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer">Configure ASP.NET Core to work with proxy servers and load balancers</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host">X-Forwarded-Host</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto">X-Forwarded-Proto</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=316e993d221f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enable tab completion for the .NET CLI in your terminal]]></title>
            <link>https://medium.com/@asimmon/enable-tab-completion-for-the-net-cli-in-your-terminal-43fdcef39aa8?source=rss-dc6e639b4ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/43fdcef39aa8</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Anthony Simmon]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 13:31:58 GMT</pubDate>
            <atom:updated>2024-04-01T13:31:58.267Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Enable tab completion for the .NET CLI in your terminal</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXF3LlbRtaj8MxfKRQ4KhA.jpeg" /><figcaption>Screenshot showing the terminal’s autocomplete feature for the “dotnet new” command</figcaption></figure><p>Have you ever forgotten the name of a .NET command or the necessary arguments to execute it? Even though using the -h parameter can often bail us out by reminding us of the commands, arguments, and descriptions, this process can sometimes feel a bit tedious.</p><p>You might not know this, but the .NET CLI includes an autocomplete feature, which can complete or suggest commands and arguments when you press the TAB key. Let’s discover together how to enable it for 3 popular shells: PowerShell, Bash, and Zsh.</p><blockquote><em>The behavior of tab completion varies depending on the shell you use. For instance, in PowerShell, you can cycle through the available options by repeatedly pressing the TAB key, while in zsh, it displays the full list of available options.</em></blockquote><h3>Enabling .NET CLI tab completion for PowerShell</h3><p>First, you must open <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles">your PowerShell profile</a>. If you have Visual Studio Code installed, you can do so with the command code $PROFILE ($PROFILE is a special variable that contains the path to your profile file).</p><p>Then, add the following lines to your profile file:</p><pre># PowerShell parameter completion shim for the dotnet CLI<br>Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {<br>  param($wordToComplete, $commandAst, $cursorPosition)<br>    dotnet complete --position $cursorPosition &quot;$commandAst&quot; | ForEach-Object {<br>      [System.Management.Automation.CompletionResult]::new($_, $_, &#39;ParameterValue&#39;, $_)<br>    }<br>}</pre><p>Save the file and restart your PowerShell session. The function Register-ArgumentCompleter will register the completion function for the dotnet command when your session starts.</p><h3>Enabling .NET CLI tab completion for bash</h3><p>To enable tab completion for your bash shell for the .NET CLI, add the following code to your .bashrc file:</p><pre># bash parameter completion for the dotnet CLI<br><br>function _dotnet_bash_complete()<br>{<br>  local cur=&quot;${COMP_WORDS[COMP_CWORD]}&quot; IFS=$&#39;\n&#39; # On Windows you may need to use use IFS=$&#39;\r\n&#39;<br>  local candidates<br><br>  read -d &#39;&#39; -ra candidates &lt; &lt;(dotnet complete --position &quot;${COMP_POINT}&quot; &quot;${COMP_LINE}&quot; 2&gt;/dev/null)<br>  read -d &#39;&#39; -ra COMPREPLY &lt; &lt;(compgen -W &quot;${candidates[*]:-}&quot; -- &quot;$cur&quot;)<br>}<br><br>complete -f -F _dotnet_bash_complete dotnet</pre><h3>Enabling .NET CLI tab completion for zsh</h3><p>To enable tab completion for your zsh shell for the .NET CLI, add the following code to your .zshrc file:</p><pre># zsh parameter completion for the dotnet CLI<br><br>_dotnet_zsh_complete()<br>{<br>  local completions=(&quot;$(dotnet complete &quot;$words&quot;)&quot;)<br><br>  # If the completion list is empty, just continue with filename selection<br>  if [ -z &quot;$completions&quot; ]<br>  then<br>    _arguments &#39;*::arguments: _normal&#39;<br>    return<br>  fi<br><br>  # This is not a variable assignment, don&#39;t remove spaces!<br>  _values = &quot;${(ps:\n:)completions}&quot;<br>}<br><br>compdef _dotnet_zsh_complete dotnet</pre><h3>.NET CLI tab completion in action</h3><p>Let’s say you forgot what the available arguments for the dotnet test command are. You can simply type dotnet test --, then press the TAB key, and the .NET CLI will print the following available arguments:</p><pre>--arch                        --configuration               --no-build                    <br>--artifacts-path              --diag                        --no-restore                  <br>--blame                       --disable-build-servers       --nologo                      <br>--blame-crash                 --environment                 --os                          <br>--blame-crash-collect-always  --filter                      --output                      <br>--blame-crash-dump-type       --framework                   --results-directory           <br>--blame-hang                  --help                        --runtime                     <br>--blame-hang-dump-type        --interactive                 --settings                    <br>--blame-hang-timeout          --list-tests                  --test-adapter-path           <br>--collect                     --logger                      --verbosit</pre><p>When there’s only one possible completion, the .NET CLI will automatically complete the command for you. For example, if you type dotnet new x, then press the TAB key, the .NET CLI will automatically complete the command to dotnet new xunit.</p><h3>References</h3><ul><li><a href="https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete">How to enable tab completion for the .NET CLI</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43fdcef39aa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>