haacked / routemagic

Utility Library to get the most out of ASP.NET Routing.
MIT License
186 stars 46 forks source link

Added transform for Nuget web.config transform #20

Closed WiredUK closed 8 years ago

WiredUK commented 8 years ago

The transform in the project causes a line to be added in the target web.config. However, if that line already exists (i.e. when updating Nuget packages) it still gets added and you end up with 2 entries. This is valid in a web.config file and the last entry is the one that gets used. Took me a while to figure out I had multiple entries after updating my packages today so thought I'd supply this fix.

This change uses the standard Microsoft transform syntax to only update the existing entry. Nuget info is here if needed.

haacked commented 8 years ago

Very nice!

selfie-0

WiredUK commented 8 years ago

Just as I got the notification that you merged my PR I had a minor moment of panic. My change just makes the transform update an existing key but will never create one for the new people installing from fresh. D'oh! The correct code should be:

<add key="RouteDebugger:Enabled" value="true" 
    xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)"/>

Note that it's now InsertIfMissing which makes perfect sense. This one has the added benefit that it won't overwrite an existing value so if a user has it disabled, it won't re-enable it.

(PS Love the gif though thanks!)

haacked commented 8 years ago

Ah! Want to submit a new PR?