How do I force MSDeploy API to keep an existing Connectionstring? - connection-string

We are deploying an ASP.Net application to IIS via MSDeploy API. We only want to update existing websites. In our ...pubxml we have defined following:
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringA-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringB-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>
By default, the setParameters.xml created on publish, looks like this:
<setParameter name="ConnectionstringA-Web.config Connection String" value="metadata=res://*/itrDTO.csdl|res://*/itrDTO.ssdl|res://*/itrDTO.msl;provider=System.Data.SqlClient;provider connection string="data source=devServer;initial catalog=devDB;User Id=devUser;Password=devPW;MultipleActiveResultSets=True;App=EntityFramework"" />
<setParameter name="ConnectionstringB-Web.config Connection String" value="data source=devServer;initial catalog=devDB;integrated security=True" />
I also tried to create a "Projectname.wpp.targets" with this configuration inside my project:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
</PropertyGroup>
</Project>
The result is that the connectionstrings are not created inside setparameters.xml.
However, all combinations of configurations here are changing the connectionstrings inside the web.config on the destinationserver. This happens if we import the package by the IIS-ManagementUI AND when we deploy the package by MSDeploy API.
All examples I've found for the "parameterization" - topic are for the IIS-Management process. As I understand parameterization, this is only usefull for manually installing updates, so that the admin has a UI to configure stuff. But we have no UI when we update the systems of our customers.
Update:
When I Publish with Visual Studio, here is the funny result:
I think this means "Hey WebDeploy, keep your hands off the connection strings!"
When I preview the changes, this is the result:

Parameterization is useful both through the IIS install UI and via the commandline. We use WebDeploy/Parameterization for the deployment of all our 40+ applications.
I just ran a test with a new blank ASP.NET application and found that by default the ConnectionString is parameterized but after setting the AutoParameterizationWebConfigConnectionStrings MSBUILD property to false it did not parameterize the ConnectionString. The parameter entry was removed from both the parameters.xml and SetParameters files.
I suggest you clear out your target website folder and republish with this property set.
Also double check that you don't have config transforms or something else that might be changing the config.

Related

Windows 10 Kiosk Mode (MultiAppAssignedAccess Provisioning package) won't install

For my Project at work i want to install a provisioning Package, that contains a xml configuration for Kiosk Mode (Assigned Access).
I used the exact code from the xml reference page and inserted my Apps, as an account i used a local account that i created for testing.
<?xml version="1.0" encoding="utf-8" ?>
<AssignedAccessConfiguration
xmlns="http://schemas.microsoft.com/AssignedAccess/2017/config"
xmlns:rs5="http://schemas.microsoft.com/AssignedAccess/201810/config"
>
<Profiles>
<Profile Id="{786df454-09d0-492f-9ef0-c07731d1606f}">
<AllAppsList>
<AllowedApps>
<App DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe"/>
</AllowedApps>
</AllAppsList>
<StartLayout>
<![CDATA[<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="Group1">
<start:Tile Size="4x4" Column="0" Row="0" DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe" />
</start:Group>
</defaultlayout:StartLayout>
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
]]>
</StartLayout>
<Taskbar ShowTaskbar="true"/>
<Taskbar/>
</Profile>
</Profiles>
<Configs>
<Config>
<Account>.\Kiosk-test</Account>
<DefaultProfile Id="{786df454-09d0-492f-9ef0-c07731d1606f}"/>
</Config>
</Configs>
</AssignedAccessConfiguration>
When i try to install it, it either wont install at all with Error code 0x8007000b on one computer or on my private computer the installation will fail.
The Settings say that i has to Lock the user interface and make changes to the device.
then the EventLogs say that it failed due to follwing error: "Error during verification because the document does not contain exactly one root node. (0xC00CE223)" (translated with deepl, so might be a bit different in reality)
I could not find a matching solution on the internet.
I also tried using the configuration Wizard for single app Kiosk, and there the same error occured.
Does anyone of you know a solution to that or can tell me what the problem is at all?
I tried to change every part of the code, so that every aspect (App, User, e.g.) is tested seperately.
I moved my computer out the group policies, so that there are no GPOs that vreate an error.
The error messages didn't change at all
Thanks and best Regards!

Changing version of cxf on Service Mix

I want to change the version of cxf on Service Mix 7.0.1 where cxf version is 3.1.9 . Because of using Brave tracing that is implemented in 3.1.12 version of cxf.
So Is there a way to change the version of the CXF on Service Mix.
I have deleted manually everything in the system/apache/cxf folder that has 3.1.9 version and add a file with 3.2.5 version. But it is still not working. When I write feature:list all of the cxf dependencies are with 3.1.9 version...
Deleting files from the system folder won't work. It does not scan the system folder for files, but rather uses it as a cache to go looking for specific versions. You don't need to add new versions to system either because it will download them from the central maven repo it they arn't in system.
If it starts up without a data folder, it will install features & versions listed in org.apache.karaf.features.cfg
One would expect to be able to delete the data folder, change the version in org.apache.karaf.features.cfg & start it up, but I tried that and Camel was broken. Unsure why.
I find it easier to deal with it using the management console.
Install the management console by dropping the following xml file into the deploy folder:
<features name="features-murray" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:io.hawt/hawtio-karaf/1.5.7/xml/features</repository>
<feature name="murray" version="1" install="auto">
<feature>hawtio-offline</feature>
</feature>
</features>
Then point your browser at http://localhost:8181/hawtio and login with SMX/SMX.
From OSGI/Features add the your new feature version with the plus button:
mvn:org.apache.cxf.karaf/apache-cxf/3.1.12/xml/features
It may take some time to install, because it downloads it from the net. I found it bounced me out of the management console also, but after logging back in I could uninstall the old cxf 3.1.9. It again logged me out of the management console, but after logging back in I had Camel active and CXF on 3.1.12.
No testing though - goodness knows what else is broken.

Automatic publish of sql server project after each build on VS2015

I am using visual studio 2015 and have a SQLServer project, what I want is that whenever i build the project it automatically gets published to sql server. In TFS we can achieve it by following
Update Build definition -> Process -> MSBuild arguments -> /t: Build /t:Publish /p:SqlPublishProfilePath = filePath.publish.xml
On local pc we can use the following command to achieve the task
msbuild ProjectName.sqlproj /t:build /t:Publish /p:SqlPublishProfilePath=filePath.publish.xml
But how can we update the build definition of the project so that when I build it on my local machine it gets published automatically without using command line
how can we update the build definition of the project so that when I build it on my local machine it gets published automatically without using command line
To accomplish this, unload your project, edit the project file ProjectName.sqlproj. Then at the very end of the project, just before the end-tag </Project>, place below scripts:
<Target Name="DeployDB" AfterTargets="build">
<Message Importance="high" Text="************** Star Deploying DB **************"/>
<Message Importance="high" Text="Deploying Project: $(MSBuildProjectDirectory)$(MSBuildProjectName).sqlproj" />
<Message Importance="high" Text="Deployment Profile: $(MSBuildProjectDirectory)PublishProfiles$(MSBuildProjectName).publish.xml" />
<MSBuild Projects="$(MSBuildProjectDirectory)$(MSBuildProjectName).sqlproj” Properties=”SqlPublishProfilePath=$(MSBuildProjectDirectory)PublishProfiles$(MSBuildProjectName).publish.xml" Targets="sqlPublish" />
</Target>
You can use some of MSBuild Reserved and Well-Known Properties like $(MSBuildProjectName) and $(MSBuildProjectDirectory), for complete list
BTW, automatic publish will slow you down, and you probably don't need to publish for every build. Under this condition, you can add a Condition for this target so that you select whether you need to automatic publish of sql server project after each build(Do not forget to add a Configuration with LocalAutoDeploy).
<Target Name="DeployDB" AfterTargets="build" Condition="'$(Configuration)' == 'LocalAutoDeploy'">

How to configure p6spy for mssql server with hibernate?

In our web application we are using spring, hibernate & sql server 2016 as db. We are using jndi to connect to the database. To record all the queries executed by hibernate I am trying to implement the p6spy.
Here are the changes I have made.
Changed the resource information from
<Resource name="jdbc/eportalcore" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databaseName=eportal-core;"
username="eportaldbadmin"
password="P#ssw0rd"
maxTotal="100"
maxIdle="20"
minIdle="5"
maxWaitMillis="10000" />
to
<Resource name="jdbc/eportalcore" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.p6spy.engine.spy.P6SpyDriver"
url="jdbc:p6spy:sqlserver://localhost:1433/eportal-core"
username="eportaldbadmin"
password="P#ssw0rd"
maxTotal="100"
maxIdle="20"
minIdle="5"
maxWaitMillis="10000" />
and added the spy.properties file under lib folder of tomcat directory. Also I have placed the p6spy-3.0.0.jar too inside the lib folder.
But after this my application is not getting connected to the DB. What mistake I am doing here? If I remove this changes then it is working fine.
Any suggestions?
I had the same question and here is what I did to make it work. Note my Database connection properties are in a property file (shouldn't be an issue) and that I use tomcat as an Application Server. You can also add P6Spy as a Maven dependency in your project.
Before :
db.properties
db.driver=net.sourceforge.jtds.jdbc.Driver
db.url=jdbc:jtds:sqlserver://${db.server}/${db.name};useNTLMv2=true;domain=XX
After :
Download(latest version when writing this response) the project. Put the p6spy-3.7.0.jar and spy.properties in the tomcat/lib folder. Change the spy.properties and application properties as noted under. Restart application and you should find a spy.log where your logs are printed normally.
db.properties
db.driver=com.p6spy.engine.spy.P6SpyDriver
db.url=jdbc:p6spy:jtds:sqlserver://${db.server}/${db.name};useNTLMv2=true;domain=XX
spy.properties
driverlist=net.sourceforge.jtds.jdbc.Driver

TeamCity SQL Deploy

I followed the guide at http://blogs.adatis.co.uk/jonathon%20eveoconnor/post/Using-TeamCity-to-Automate-Building-and-Deployment-of-Database-Projects to set up SQL build and publish from TeamCity.
The build step works great, but I'm stuck when it comes to publishing. I've set the step up as below, which matches what is in the guide, but I'm getting an error.
Step 2/2: Publish (MSBuild) (2s)
[Step 2/2] KAInternal\KAInternal.sqlproj.teamcity: Build target: Publish
[KAInternal\KAInternal.sqlproj.teamcity] SqlPublish
[SqlPublish] SqlPublishTask
[SqlPublishTask] C:\TeamCity\buildAgent\work\1472f1322571ddd\KAInternal\bin\Debug\KAInternal.sqlproj.publish.sql error Deploy72002: Unable to connect to master or target server 'KAInternal'. You must have a user with the same password in master or target server 'KAInternal'.
[Step 2/2] Step Publish (MSBuild) failed
I've searched a fair bit, but everyone seems to believe this is a permission issue on the source machine, well my publish profile is using the built in "sa" SQL Server account to publish (for now, mainly to disprove this theory).
Here is the publish profile XML:
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>KAInternal</TargetDatabaseName>
<DeployScriptFileName>Staging_KAInternal.sql</DeployScriptFileName>
<TargetConnectionString>Data Source=192.168.194.6;Persist Security Info=False;User ID=sa;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
<BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
<ExcludeLogins>True</ExcludeLogins>
<IgnoreRoleMembership>True</IgnoreRoleMembership>
<ExcludeUsers>True</ExcludeUsers>
<ProfileVersionNumber>1</ProfileVersionNumber>
</PropertyGroup>
And the publish step in TeamCity
Hopefully someone can point me in the right direction, thanks in advance.
The guide you're following describes creating a separate proj file for the deployment, but here you're using the sqlproj file instead. There actually is an msbuild publish target for sqlproj files, so I'm not sure whether this was an intentional deviation on your part.
It may be the case that the sqlproj build task doesn't accept the password as an msbuild property. You could test whether this is the problem by specifying the password in the connection string in the publish profile file.
Also, I would suggest ensuring that you're using the latest versions of SSDT and DACFx. See the SSDT team blog for information about the latest versions and download links: https://blogs.msdn.microsoft.com/ssdt/

Resources