2016-04-04 13 views
0

私はエンティティフレームワーク接続文字列を持つweb.configを持っています。msdeployとregexは接続文字列値を置き換えます

、このような文字列のサンプルです:

<add name="MyEntities" connectionString="metadata=res://*/GeneratedModel.MyModel.csdl|res://*/GeneratedModel.MyModel.ssdl|res://*/GeneratedModel.MyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=CRAP;persist security info=True;user id=MyUser;password=password;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

私は新しい名前「TEST」

別名データベース名「CRAP」そのコードを初期カタログを交換したいですmsdeploy.exeコマンドを使用して以前と同じように動作するはずです。

私はちょうど私が上記のステートメントを実行すると、私は、web.configファイルで、この接続文字列を取得します... $のMSD変数の再構成に

$newActiveTargetDbName = 'TEST'; 

$msd = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
$iisPath = "MyWebSite/MyService,wmsvc='MyMachine:MyPort/msdeploy.axd',userName='username',password='password'" 
& $msd -verb=sync -allowUntrusted -dest=contentPath="$iisPath" -source=contentPath="$iisPath" -setParam=kind="TextFile,match=""(MyEntities.*?catalog=).*?(;)"",scope=web.config$,value=`$1$newActiveTargetDbName`$2" 

を持っていた:

<add name="$1TEST$2persist security info=True;user id=MyUser;password=password;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

それは、私はどこかのシングル/ダブルクォートなどが必要だと私には思われますが、私は実際にあらゆる種類の組み合わせを試して、私を狂ってしまいました。

どうすれば修正できますか?

UPDATE

これは、私はそれを変更する前に働いた方法をする場合msdeploy文の構文です!

$iisServicePath = 'MyWebsite/MyService'; 
$iisPath = "$iisServicePath,computerName=%TargetComputerName%,userName=%NTUserName%,password=%NTUserPassword%" 

& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` 
"-source=contentPath=$iisPath" ` 
'-verb=sync' ` 
'-verbose' ` 
'-allowUntrusted' ` 
"-dest=contentPath=$iisPath" ` 
"-setParam=kind=TextFile,match=""(MyEntities.*?catalog=).*?(;)"",scope=web.config$,value=`$1$newActiveTargetDbName`$2"; 

答えて

関連する問題