Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slowcheetah to transform value of an element in config file

I know how to change the value of attributes with SlowCheetah, but how would I change the value of the element.

app.Debug.config:

 <applicationSettings>
  <MyProgram.Properties.Settings>
    <setting name="aName" serializeAs="String">
      <value>myName</value>
    </setting>
  </MyProgram.Properties.Settings>
 </applicationSettings>

This was my failed attempt in app.Staging.config:

 <applicationSetting>
   <MyProgram.Properties.Settings>
     <setting name="aName" serializeAs="String">
        <value xdt:Transform="Replace" xdt:Locator="Match(value)">newName</value>
     </setting>
   </MyProgram.Properties.Settings>
</applicationSetting>
like image 699
asunrey Avatar asked Mar 26 '12 19:03

asunrey


People also ask

What does SlowCheetah do?

This package allows you to automatically transform your app. config (or any file) when you press F5 in Visual Studio. You can have different transformations based on the build configuration. This will enable you to easily have different app settings, connection strings, etc for Debug versus Release.

What is Xdt transform in web config?

The xdt:Transform attribute value "SetAttributes" indicates that the purpose of this transform is to change attribute values of an existing element in the Web. config file.

What is web config transform?

A transform file is an XML file that specifies how the Web. config file should be changed when it is deployed. Purpose of These Files. The purpose of these files is to generate a new Web.config file depending upon the environment. It's extremely useful to store settings in these files, for example.


1 Answers

<applicationSetting>    
  <MyProgram.Properties.Settings>      
    <setting name="aName" serializeAs="String" xdt:Locator="Match(name)">         
      <value xdt:Transform="Replace">newName</value>     
    </setting>    
  </MyProgram.Properties.Settings> 
</applicationSetting> 

This should do it!

like image 73
asunrey Avatar answered Sep 21 '22 23:09

asunrey