This configuration can be done in the web.config, and thus can be stored in source control. Here’s what you need to add to your web.config.

<rewrite>
    <rules>
        <rule name="Redirect to non-www" stopProcessing="true">
            <match url="(.*)" negate="false"></match>
            <action type="Redirect" url="http://domain.com/{R:1}"></action>
            <conditions>
                <add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>
            </conditions>
        </rule>
    </rules>
</rewrite>

Note: Make sure that for redirecting a site like www.domain.com to domain.com, you’ll need to make sure that you’ve configured both of those domains to point to your website.