title: How to override ASP.NET deployment parameters when publishing
body: <p>I've seen some questions, read all the posts, still I can't get this done. Either I'm missing something, or it cannot be done..</p>
  
  <p>So I have a rather simple (ASP.NET MVC) project.
  In the root of my project there is a parameters.xml file with parameter definitions, such as:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;parameters&gt;
    &lt;parameter 
     name="Realm"
     description="Realm for ADFS authentication"
     defaultValue="http://somewebsite"&gt;
     &lt;parameterEntry 
        kind="XmlFile"
        scope="Web.config"
        match="/configuration/appSettings/add[@key='ida:Realm']/@value" /&gt;
     &lt;parameterEntry 
        kind="XmlFile" 
        scope="Web.config"
        match="/configuration/system.identityModel/identityConfiguration/audienceUris/add/@value" /&gt;
  &lt;parameterEntry 
        kind="XmlFile" 
        scope="Web.config"
        match="/configuration/system.identityModel.services/federationConfiguration/wsFederation/@realm" /&gt;
  </code></pre>
  
  <p>
      </p>
  
  <p>So far so good. This structure is very well understood, you a name of a deployment parameter (e.g. "Realm") a default value for it, and a few XCLT options where it can be found in the Web.config file.</p>
  
  <p>Now when I create a deployment package, by running Publish, I get a directory that contains:</p>
  
  <ol>
  <li>An auto generated cmd file for the deployment</li>
  <li>A readme file</li>
  <li>A manifest XML file</li>
  <li>A zip file with all the files that have to be deployed to my server.</li>
  <li>A .SetParameters.xml file</li>
  </ol>
  
  <p>That last file contains the parameter values which were set in the parameters.xml file I quoted above, and those values are set to be the default ones which were defined there.<br>
  e.g. if the default value for Realm was set to be <a href="http://somewebsite" rel="nofollow noreferrer">http://somewebsite</a>, in the generated deployment SetParameters.xml, I will get this record:</p>
  
  <pre><code>&lt;setParameter name="Realm" value="http://somewebsite" /&gt;
  </code></pre>
  
  <p>When the package gets deployed, these values will be taken from this xml file and replace the values in my Web.Config, according to the XPaths defined in the original parameter.xml file.</p>
  
  <p>Now, what I want is to override this parameters (as well as many others) when I build my deployment package, because I need different values for different deployment profiles.</p>
  
  <p>The key seems to be my .pubxml file, which is in charge of the publishing settings. I tried many options, including what Sayed Hashimi said <a href="http://sedodream.com/PermaLink,guid,25ddd39e-59de-4e35-becc-de19dcc5e4ea.aspx" rel="nofollow noreferrer">here</a>, previous answers given <a href="https://stackoverflow.com/questions/13030265/how-do-you-parameterize-deployments-when-using-asp-net-4-5-publish-profiles">here</a> and <a href="https://stackoverflow.com/questions/22890323/web-config-transformation-msdeploy-keeping-production-passwords-out-of-sourc">here</a>, <a href="http://cromwellhaus.com/2012/05/build-once-msdeploy-all-over-the-place/" rel="nofollow noreferrer">here too</a> (and others too)... nothing seems to make a difference for the damn parameters!</p>
  
  <p>Am I missing something? Is there some magic hack?<br>
  Should I ignore the params altogether and just rely on a matching web.config transformation? Any other advice? Maybe add custom targets to the .csproj file? (even tried that...)</p>
  
  <p>Thank you!
  Alon.</p>