XDT configuration transformations in Rider
Rider 2017.3 EAP comes with support for Web.config and App.config transformations. These configuration transformations allow us to update certain settings in a Web.config or App.config file when packaging the application. For example, we may want to update the database connection string for a Release build, or update certain settings for a Debug build.
Using the context menu in Solution Explorer or in the editor, we can generate a configuration transform file for any of our solution’s configuration files. Optionally, we can nest the file under its parent configuration, too.
Rider generates a sample configuration transform file with certain pointers to the XDT transformation syntax. We could write a transformation that updates a connection string, and removes the
debug="true" attribute from our Web.config:
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <!-- Replace connection string --> <connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> <system.web> <!-- Drop debug attribute --> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration>
While these transformations should be run using MSBuild, for example when using WebDeploy, Rider provides support for previewing (and running) them in the IDE. This lets us validate the XDT transformation we are working on, without having to run a full build each time.
The configuration transformation preview shows in a diff viewer, so we can see exactly which elements or attributes will be updated:
Note in earlier versions of Rider, XDT configuration transformations are available as a plugin.
Subscribe to Blog updates
Thanks, we've got you!
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…
OSS Power-Ups: bUnit – Webinar Recording
The recording of our webinar, OSS Power-Ups: bUnit, with Egil Hansen and Steven Giesel, is available. This was the twelfth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webi…
Accelerating Your Testing Workflow with Unit Test Creation and Navigation
Unit tests play an important role in our daily development workflow. They help us ensure our codebase's correctness when writing new functionality or performing refactorings to improve readability and maintainability. In the process, we often create new test files that accompany the p…
Introducing Predictive Debugging: A Game-Changing Look into the Future
With the introduction of debugging tools, software developers were empowered to interactively investigate the control flow of software programs to find bugs in live environments. At JetBrains, we've always strived to improve the art of debugging. Besides the more standard things you expect from a de…