Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

MSDeploy v3 - xpath-based default parameter values doesn't appear to work

$
0
0

According to the documentation page Parameterization improvements in Web Deploy V3, XmlFile parameter values can be given a defaultValue that infers the value from an existing xml file. The following example is given:

<parameter name="Replacement Param" defaultValue="\web.config:://connectionStrings" >”<parameterEntry kind="XMLFILE" scope="web\.config$" match="//connectionStrings" /></parameter>

I can't get this feature to work at all. Did the implementation make it into v3 RTW or was it culled (like app_offline templates)?

Here's my first example (of two), which declares a parameter on an XML element and gives it a default value of an element loaded from a different file (to make sure the feature works):

@echo off

REM ******** this stuff is only to read the path to the latest WebDeploy on your machine ***********
for /F "usebackq tokens=1,2,*" %%h  in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" /s  ^| findstr -i "InstallPath"`) do (
if /I "%%h" == "InstallPath" (
if /I "%%i" == "REG_SZ" (
if not "%%j" == "" (
if "%%~dpj" == "%%j" (
set MSDEPLOY="%%j\msdeploy"
)))))

mkdir source & mkdir dest
echo ^<configuration^> ^
    ^<appSettings^> ^
        ^<add key="test" value="original" /^> ^
    ^</appSettings^> ^
 ^</configuration^> > source\web.config

echo ^<configuration^> ^
    ^<appSettings^> ^
        ^<add key="test" value="default" /^> ^
    ^</appSettings^> ^
 ^</configuration^> > source\default.config

@echo on
 
@echo. & @echo Packaging
%MSDEPLOY% -verb:sync -source:contentPath=%cd%\source -dest:package=%cd%\package.zip ^
 -declareParam:name="test",kind=XmlFile,scope=Web\.config,match=//add[@key='test'],defaultValue=\default.config:://add[@key='test']

@echo. & @echo Deploying with default value
%MSDEPLOY% -verb:sync -source:package=%cd%\package.zip -dest:contentPath=%cd%\dest
@find "test" dest\web.config
@echo. & @echo "value" attribute expected to be "default"

@PAUSE

@echo. & echo Deploying with updated value
%MSDEPLOY% -verb:sync -source:package=%cd%\package.zip -dest:contentPath=%cd%\dest -setParam:name="test",value="^<add key=^"test^" value=^"updated^" /^>"
@find "test" dest\web.config
@echo. & @echo "value" attribute expected to be "updated"

@PAUSE

The output is summarised as follows:

Dumping parameters
<output>
  <parameters>
    <parameter name="test" defaultValue="\default.config:://add[@key='test']">
      <parameterEntry kind="XmlFile" scope="Web\.config" match="//add[@key='test']" />
    </parameter>
  </parameters>
</output>

Deploying with default value
<configuration>     <appSettings>         <add key="test" value="original" />     </appSettings>  </configuration>
"value" attribute expected to be "default"

Deploying with updated value
<configuration>     <appSettings>         <add key="test" value="original" />     </appSettings>  </configuration>
"value" attribute expected to be "updated"

Which appears to be ignoring the parameter entirely.

My next example does the same thing, but defines the parameter (and default value) on an attribute

@echo off

REM ******** this stuff is only to read the path to the latest WebDeploy on your machine ***********
for /F "usebackq tokens=1,2,*" %%h  in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" /s  ^| findstr -i "InstallPath"`) do (
if /I "%%h" == "InstallPath" (
if /I "%%i" == "REG_SZ" (
if not "%%j" == "" (
if "%%~dpj" == "%%j" (
set MSDEPLOY="%%j\msdeploy"
)))))

mkdir source & mkdir dest
echo ^<configuration^> ^
    ^<appSettings^> ^
        ^<add key="test" value="original" /^> ^
    ^</appSettings^> ^
 ^</configuration^> > source\web.config

echo ^<configuration^> ^
    ^<appSettings^> ^
        ^<add key="test" value="default" /^> ^
    ^</appSettings^> ^
 ^</configuration^> > source\default.config

@echo on
 
@echo. & @echo Packaging
%MSDEPLOY% -verb:sync -source:contentPath=%cd%\source -dest:package=%cd%\package.zip ^
 -declareParam:name="test",kind=XmlFile,scope=web\.config,match=//add[@key='test']/@value,defaultValue=\default.config:://add[@key='test']/@value

@echo. & @echo Dumping parameters
%MSDEPLOY% -verb:getParameters -source:package=%cd%\package.zip

@echo. & @echo Deploying with default value
%MSDEPLOY% -verb:sync -source:package=%cd%\package.zip -dest:contentPath=%cd%\dest
@find "test" dest\web.config
@echo. & @echo "value" attribute expected to be "default"

@PAUSE

@echo. & echo Deploying with updated value
%MSDEPLOY% -verb:sync -source:package=%cd%\package.zip -dest:contentPath=%cd%\dest -setParam:name="test",value="updated"
@find "test" dest\web.config
@echo. & @echo "value" attribute expected to be "updated"

@PAUSE

The output is summarised as follows:

Dumping parameters
<output>
  <parameters>
    <parameter name="test" defaultValue="\default.config:://add[@key='test']/@value">
      <parameterEntry kind="XmlFile" scope="web\.config" match="//add[@key='test']/@value" />
    </parameter>
  </parameters>
</output>

Deploying with default value
<configuration>     <appSettings>         <add key="test" value="\default.config:://add[@key='test']/@value" />     </appSettings>  </configuration>
"value" attribute expected to be "default"

Deploying with updated value
<configuration>     <appSettings>         <add key="test" value="updated" />     </appSettings>  </configuration>
"value" attribute expected to be "updated"

Which only works correctly when an explicit value is set.


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>