I have a web.config with an entity framework connection string.
That is a sample of such a string:
<add name="MyEntities" connectionString="metadata=res://*/GeneratedModel.MyModel.csdl|res://*/GeneratedModel.MyModel.ssdl|res://*/GeneratedModel.MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=CRAP;persist security info=True;user id=MyUser;password=password;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
I want to replace the initial catalog aka database name "CRAP" with the new name "TEST"
That code should work as it worked before with another msdeploy.exe command.
I just had to re-structure the $msd variable...
$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"
When I run the above statement I get this connection string in the web.config:
<add name="$1TEST$2persist security info=True;user id=MyUser;password=password;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
It seems to me that I need somewhere some single/double quotes etc... but I tried actually all kind of combinations and its driving me insane.
How can I fix that?
UPDATE
This is a syntax of the msdeploy statement how it WORKED before I changed it!
$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";