2016-03-30 28 views
0

ile değiştirin. Barındırılan bir iis hizmetinin web.config dosyasındaki connectionString öğesini msdeploy ve powershell ile uzak bir bilgisayarda değiştirin.Web.config dosyasındaki bağlantı dizesini msdeploy

komut hatasız çalıştığını:

$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"'; 

senaryonun ayrıntılı çıktı diyor:

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 değeri

yerini değildi.

Bunu nasıl yapabilirim?

GÜNCELLEME hata mesajı şimdi olsun edilmektedir

: Bununla

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) 

kodu değişti: Eğer tek tırnak kullandığınız

& "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`"'; 

cevap

0

Değişim burada son satırı, tam olarak yazılan olarak yorumlanacaktır (örneğin, bir değişken için değerde değişmeyecek)

Tek tırnak işaretlerini iki katıyla değiştirdim ve ileri gitti ve iç tırnaklardan da kaçtım. Bu işe yaramazsa, haberim olsun!

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

Kısmen işe yarar ;-) yukarıdaki ileti güncellememe bakın. – HelloWorld

İlgili konular