locked
how to change appliacation setting from command prompt

    Question

  • Is there any option to change application setting such as a <name,value,scope>triplet(which appear when u open project properties in VSTS) from command prompt so that while building the project,it is reflected in my settings?
    Wednesday, April 18, 2007 7:51 AM

Answers

  • I have not seen this option anywhere but I can think of a couple possible word-arounds:

    1. Create multiple app.config files (e.g. one for each situation) and name them accordingly (e.g. dev.app.config, test.app.config, prod.app.config, etc.).  Then, in your build, copy the appropriate configuration file to its respective destination renaming it along the way.  You can use the "Copy" build task to copy a file to a location with a new name.  For example, here's one for a web.config file:


      <
      ItemGroup>

      <AdminWebConfig Include="$(SolutionRoot)\..\..\Configs\Test\Test.Web.config"/>
      </ItemGroup>

      <
      Copy SourceFiles="@(AdminWebConfig)" DestinationFiles=\\server\d$\Inetpub\testnet\Admin\web.config />

      The above "Copy" task will copy the "Test.Web.config" file and rename it to "web.config".

    2. Another option would be to create a custom task that takes the location of the config file and the <name, value, scope> triplet and updates the config file for you.  I haven't done this but I don't think it would be too difficult.  This custom task may already exist, and if so, you'd be able to implement it fairly quickly.  I'll take a look around tonight and if I can't find one I'll try to go ahead and create one and post back to this forum.
    Monday, April 23, 2007 6:04 PM