2016-03-30 15 views
0

リモートコンピュータのhosted iisサービスのweb.config内のconnectionStringをmsdeployおよびpowershellに置き換えます。webdeconfigの接続文字列をmsdeployに置き換えてください。

スクリプトがエラーなしで実行されます。

$iisPath = "$iisServicePath,computerName=$computerName,userName=$userName,password=$password" 

& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` 
"-source=contentPath=$iisPath" ` 
'-verb=sync' ` 
'-verbose' ` 
'-allowUntrusted' ` 
"-dest=contentPath=$iisPath" ` 
'-setParam=kind=TextFile,match="configuration/connectionStrings/add[@name=MyEntities]/@connectionString",scope=web\.config$,value="$newConString"'; 

スクリプトの詳細出力は言う:

Verbose: The synchronization completed in 1 pass(es). 
Total changes: 0 (0 added, 0 deleted, 0 updated, 0 parameters changed, 0 bytes copied) 

たconnectionString Attribute`s値が交換されませんでした。

どうすればいいですか?

UPDATEエラーメッセージ私は今取得され

:これにより

Verbose: Parameter entry 'MSDeploySetParameter-2080747909/1' could not be applied to 'MyWebSite/MyService\Web.config'. Deployment will continue with the original data. Details: 
No matches were found for the search string '`"configuration/connectionStrings/add[@name=MyEntities]/@connectionString`' (type 'TextFile'). 
Verbose: Attribute 'size' equality changed to False when comparing filePath (MyWebSite/MyService\Web.config) to MyWebSite/MyService\Web.config because of rule Parameterizat 
ion. 
Verbose: Source filePath (MyWebSite/MyService\Web.config) does not match destination (MyWebSite/MyService\Web.config) differing in attributes (parameters). Update pending. 
Verbose: Source filePath (MyWebSite/MyService\Web.config) replaced with changed attributes (size['3710','3707']) because of rule Parameterization. 
Info: Updating file (MyWebSite/MyService\Web.config). 
Verbose: The dependency check 'DependencyCheckInUse' found no issues. 
Verbose: The synchronization completed in 2 pass(es). 
Total changes: 1 (0 added, 0 deleted, 1 updated, 0 parameters changed, 3707 bytes copied) 

は、コード変更:あなたは、単一引用符を使用している

& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` 
"-source=contentPath=$iisPath" ` 
'-verb=sync' ` 
'-verbose' ` 
'-allowUntrusted' ` 
"-dest=contentPath=$iisPath" ` 
'-setParam=kind=TextFile,match=`"configuration/connectionStrings/add[@name=MyEntities]/@connectionString`",scope=web\.config$,value=`"$newConString`"'; 

答えて

0

変更ここでは最後の行を、これは型指定されたものと正確に解釈されます(たとえば、変数の値に入れ替えられません)

私はあなたの一重引用符を二重引用符に置き換えて、先に行って内側の引用符もエスケープしました。これがうまくいかない場合は、私に教えてください!

-setParam=kind=TextFile,match=`"configuration/connectionStrings/add[@name=MyEntities]/@connectionString`",scope=web\.config$,value=`"$newConString`" "; 
+0

上記の私のメッセージの更新を参照してください。 – HelloWorld

関連する問題