<setParameter>
值,但它忽略了一些......特别是用户名,密码和安全令牌参数\Views\Web.config
。我们想写信给\Web.config
。DeploySettings.xml
文件中。<setParameter>
值写入 \ Web.config 而非 \ Views \ Web.config DeploySettings.Dev.xml
文件-setParamFile
使用<setParameter>
文件中的DeploySettings.Dev.xml
值覆盖\ Web.config值-setParamFile:"%WORKSPACE%\DeploySettings.Dev.xml" -verbose
⚠️这不是整个文件
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter
name="username"
value="lukeSkywalker" />
<setParameter
name="password"
value="xxxxxx" />
<setParameter
name="token"
value="xxxxxx" />
<setParameter
name="DBConnection"
value="Data Source=fully.qulified.domain;Initial Catalog=CatalogName;uid=obiwan;password=xxxxx;MultipleActiveResultSets=True" />
<setParameter
name="SessionDBConnection"
value="Data Source=1.2.3.4;uid=userId;password=xxxxxx" />
...
请注意
username
,password
和token
不存在
Verbose: Parameter entry 'DBConnection/1' is applicable to '\Web.config' because of its scope.
Verbose: Parameter entry 'SessionDBConnection/1' is applicable to '\Web.config' because of its scope.
Verbose: Parameter entry 'DBConnection/1' is applicable to '\Views\Web.config' because of its scope.
Verbose: Parameter entry 'DBConnection/1' could not be applied to '\Views\Web.config'. Deployment will continue with the original data. Details:
Verbose: Parameter entry 'DBConnection/1' is applicable to '\Views\Web.config' because of its scope.
Verbose: Parameter entry 'DBConnection/1' could not be applied to '\Views\Web.config'. Deployment will continue with the original data. Details:
-setParamFile
来抓取并覆盖username
,password
和token
?感谢您的时间。
答案 0 :(得分:1)
我将这种类型的config-rewrite工作转移到构建脚本(Jenkins&gt;“Your Project”&gt; Build&gt; Configure)。
这是我如何让它工作的一个例子
SET PATH=%PATH%;c:\Program Files (x86)\IIS\Microsoft Web Deploy V3
msdeploy.exe -verb:sync -source:dirPath="%WORKSPACE%\" ^
-dest:package="%WORKSPACE%\ArtifactName-%BUILD_NUMBER%.zip" ^
-replace:objectName=dirPath,targetAttributeName=path,match="^C:\\.*\\pathToSite",replace="c:\sitesRoot\pathToSite" ^
-declareParam:name=DBConnection,kind=XmlFile,scope=Web.config,match=//configuration/connectionStrings/add/@connectionString,defaultValue="Data Source=1.2.3.4;Initial Catalog=dbName;uid=website;password=xxxx;MultipleActiveResultSets=True" ^
-declareParam:name=SessionDBConnection,kind=XmlFile,scope=Web.config,match=//configuration/system.web/sessionState/@sqlConnectionString,defaultValue="Data Source=1.2.3.4;uid=xxxx;password=xxxx" ^
-declareParam:name=Parameter1,kind=XmlFile,scope=Web.config,match=//configuration/appSettings/add[@key="Parameter1"]/@value,defaultValue="paramValue1" ^
-declareParam:name=Paramtere2,kind=XmlFile,scope=Web.config,match=//configuration/appSettings/add[@key="Parameter2"]/@value,defaultValue="paramvalue2" ^