This project is read-only.

Variables only config

Nov 24, 2014 at 9:49 AM
is there a way to use one generic config-file and only change variable values depending the machinename? Copying the whole default.xml to machinname1.xml... makes it necessary to maintain multiple files.
 <Variables ID="HostnameDev">
      <Variable Name="WebAppUrl">http://dev</Variable>
 <Variables ID="HostnameStage">
      <Variable Name="WebAppUrl">http://stage</Variable>
 <Variables ID="HostnameProd">
      <Variable Name="WebAppUrl">http://prod</Variable>
Nov 24, 2014 at 11:18 AM
You can extract any an piece of the xml to a separate file and reference it from another file.
Please have a look at the documentation at slide 17 which explains it.

By this you can have a general xml file for Environment, Extensions etc. and on specific one only for the variables section or even only one single variable.

Eg. Default.xml (shared by all machines)
<SPSD Version="">
    <Configuration ID="Default">
        <Actions AfterDeploy="true" AfterRetract="true" AfterUpdate="true">...</Actions>
    <Environment ID="Default">
            <!-- no variables -->
        <PreRequisiteSolutions ID="Default">...</PreRequisiteSolutions>
        <Solutions ID="Default" Force="true" Overwrite="true">...</Solutions>
    <Extensions ID="Default">...</Extensions>
<SPSD Version="">
    <Configuration ID="Default" FilePath="default.xml" />
         <Variables ID="MyMachine">
            <Variable Name="UserID">$(env:USERDOMAIN)\$(env:USERNAME)</Variable>
            <Variable Name="WebAppUrl">http://$(env:COMPUTERNAME).$(env:USERDNSDOMAIN)</Variable>
            <Variable Name="SiteUrl">http://$(env:COMPUTERNAME).$(env:USERDNSDOMAIN)/sites/TestSite</Variable>
            <Variable Name="LCID">1033</Variable>
        <PreRequisiteSolutions ID="Default"  FilePath="default.xml"/>
        <Solutions FilePath="default.xml"/>
    <Extensions ID="Default"  FilePath="default.xml"/>
You see above that Machine1.xml is getting the configuration from the node with the ID "Default" from the file default.xml located in the same folder (use relative paths if you reference from somewhere else)
It also gets the PreRequisiteSolutions, the Solutions and the Extensions node from the same file.

Only the Variables are defined int he machine1.xml file.
Of course you have to make sure that you use the same variable names for all machines if you refer to them within the xml or the PowerShell custom targets.

Hope that clears things up.
I usually have a separate file for every main node and just plug the stuff together for each machine.

PS: Avoid circular references ;) SPSD will cancel resolving them after a loop count of 10.
Marked as answer by ReneHezser on 11/24/2014 at 11:32 AM
Nov 24, 2014 at 11:43 AM
Thanks for the quick reply. I've read the documentation, but it wasn't clear to me.

Nov 24, 2014 at 7:12 PM
No problem!
Always ways to improve the docs :)

Let me know if you can get it to work to your satisfaction.