I am currently trying to start the deployment process on my production server. I am currently using web deployment and profile publishing to achieve this, and everything works fine for me, except for updating the connection strings to match the production server.
I use:
msbuild myProj.csproj /p:DeployOnBuild=true;PublishProfile=myProfile;Configuration=Release
to create a publication package, and:
call myProj.deploy.cmd /Y /M:http://myServer/MSDeployAgentService -allowUntrusted /U:user /:Password
So it works, it packs and then sends it to the server in order and configures IIS correctly, but points to the wrong database.
My publication profile looks like this:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebPublishMethod>MSDeploy</WebPublishMethod> <SiteUrlToLaunchAfterPublish /> <MSDeployServiceURL>http://myserver</MSDeployServiceURL> <DeployIisAppPath>Website</DeployIisAppPath> <RemoteSitePhysicalPath /> <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer> <MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod> <UserName>user</UserName> <_SavePWD>True</_SavePWD> <PublishDatabaseSettings> <Objects xmlns=""> <ObjectGroup Name="DBContext" Order="1" Enabled="False"> <Destination Path="Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"" Name="" /> <Object Type="DbCodeFirst"> <Source Path="DBMigration" DbContext="myproj.Repositories.DBContext, myproj.Repositories" MigrationConfiguration="myproj.Repositories.Migrations.Configuration, myproj.Repositories" Origin="Configuration" /> </Object> </ObjectGroup> <ObjectGroup Name="DefaultConnection" Order="2" Enabled="False"> <Destination Path="Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"" Name="" /> <Object Type="DbDacFx"> <PreSource Path="Data Source=localhost;Initial Catalog=devDB;User ID=user;Password="password"" includeData="False" /> <Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" /> </Object> <UpdateFrom Type="Web.Config"> <Source MatchValue="Data Source=localhost;Initial Catalog=devDB;User Id=user;Password=password" MatchAttributes="$(UpdateFromConnectionStringAttributes)" /> </UpdateFrom> </ObjectGroup> </Objects> </PublishDatabaseSettings> </PropertyGroup> <ItemGroup> <MSDeployParameterValue Include="$(DeployParameterPrefix)DBContext-Web.config Connection String"> <ParameterValue> Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"</ParameterValue> </MSDeployParameterValue> <MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String"> <ParameterValue>Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"</ParameterValue> </MSDeployParameterValue> </ItemGroup> </Project>
Annoyingly, this works great when publishing directly from VS2012, and not through the command line. Is there a switch or option that I am missing in my msbuild call?
It does not work correctly, as in my myProj.SetParameters.xml file, the connection strings shown here are incorrect. If I manually changed them to the correct connection strings, the web.xml file will be correct on the production server after it is deployed. How to get the correct line in a SetParameters file? Any help would be greatly appreciated.
source share