18

I am using to deploy a web application via .

I am using a paramaters.xml file to manipulate my application's , specifically the application settings section.

I have some Settings where it is only valid to have a value for a specific environment and the rest of the time the value should be blank (ie, Property should only have a value on Production). However, MSDeploy gives me this Exception when I do not specify a value:

 Microsoft.Web.Deployment.DeploymentException: 
   The 'facebookUserToken' argument cannot be null or empty.
   at Microsoft.Web.Deployment.DeploymentSyncParameterValidation.Validate(String parameterName, String parameterValue)
   at Microsoft.Web.Deployment.DeploymentSyncParameter.set_Value(String value)
   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadFromFile(XPathNavigator nav, String fileName, Boolean ignoreExtraSetParameters)
   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.Load(Stream stream, String fileName, Boolean ignoreExtraSetParameters)
   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.Load(String fileName, Boolean ignoreExtraSetParameters)
   at MSDeploy.MSDeploy.HandleSetParameters(DeploymentObject sourceObject, Random random)
   at MSDeploy.MSDeploy.ExecuteWorker()
   at MSDeploy.MSDeploy.Execute()
   at MSDeploy.MSDeploy.Main(String[] unusedArgs)

How can I configure MSDeploy to allow a parameter to have an empty value?

web.config:

<applicationSettings>
    <SO.Example>
        <setting name="FacebookUserToken" serializeAs="String">
           <value></value>
        </setting>
    </SO.Example>
</applicationSettings>

parameters.config:

   <parameter name="facebookUserToken" description="" defaultValue="">   
      <parameterEntry kind="XmlFile" scope="Web.config"
      match="XPath removed for readability">
       </parameterEntry>
   </parameter>

2 Answers 2

41

I ran across this issue a while back and found the solution at Richard Szalay's blog. You need to add the parameterValidation to your parameter declaration:

<parameters> 
   <parameter name="ReplaceVariable"
          description="Sample variable that allows empty values" defaultValue="">
     <parameterValidation kind="AllowEmpty" />
     <parameterEntry type="TextFile" scope="Web\.config$" match="TextToReplace" /> 
   </parameter> 
</parameters> 

So for your specific case:

  <parameter name="facebookUserToken" description="" defaultValue="">   
      <parameterValidation kind="AllowEmpty"/>
      <parameterEntry kind="XmlFile" scope="Web.config"
      match="XPath removed for readability">
       </parameterEntry>
   </parameter>
Sign up to request clarification or add additional context in comments.

1 Comment

I just want point out that this IIS.net page does not work with MsBuild 14. parameterValidation should have kind attribute instead of type attribute.
5

I think you're looking for <parameterValidation />.

In your parameters.config:

<parameter name="facebookUserToken" description="" defaultValue=""> 
    <parameterValidation kind="AllowEmpty" />  
    <parameterEntry kind="XmlFile" scope="Web.config"
       match="XPath removed for readability">
    </parameterEntry>
</parameter>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.