MSDeploy setParamFile is not recognizing parameters - powershell

I'm trying to use MSDeploy with the parameter settings file option so I can build once and deploy to multiple environments by overriding the parameters with different files. From PowerShell I'm calling msdeploy.
msdeploy.exe -verb:sync `
-source:"contentPath='$SourceLocalPath'" `
-dest:"contentPath='$TargetLocalPath',computername='$TargetServer'"
-setParamFile:"$ParamFilePath" `
-verbose
This results in an error about not recognizing parameters.
msdeploy.exe : Error: The declared parameter 'SqlConnString' is not
recognized.
If I remove the "setParamFile" line, it deploys fine, but then uses default values. Also if I try to manually import the package from IIS, it displays the parameters with defaults filled in.
I have a Parameter.xml file in the root of the web project:
<parameters>
<parameter name="SqlConnString" description="Please provide the SQL connection string" defaultValue="...;Initial Catalog=xxx;server=xxx;" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='Sql']/#connectionString" />
</parameter>
</parameters>
The package is getting created with a ...SetParameters.xml file inside the package, which contains the entries from my Parameters.xml file plus the standard entries.
<parameters>
<setParameter name="SqlConnString" value="...Initial Catalog=xxx;server=xxx;"/>
...
</parameters>
Thank you

Try changing the value in "name" from "SqlConnString" to "YourSqlConnectionName-Web.config Connection String". If you want to know the exact name you have to look at your web.config file. The above example should work for a section like this in your web.config file:
<connectionStrings>
<add name="YourSqlConnectionName"
connectionString="...;Initial Catalog=xxx;server=xxx;"
providerName="System.Data.EntityClient"/>
</connectionStrings>
So you should configure your setParameters.xml file like:
<parameters>
<setParameter name="YourSqlConnectionName-Web.config Connection String" value="...Initial Catalog=xxx;server=xxx;"/>
</parameters>
and your Parameters.xml file like:
<parameters>
<parameter name="YourSqlConnectionName-Web.config Connection String" description="Please provide the SQL connection string" defaultValue="...;Initial Catalog=xxx;server=xxx;" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='YourSqlConnectionName']/#connectionString" />
</parameter>
</parameters>
Hope this solves your issue.

Related

Azure Devops Release XML variables not being replaced

I'm trying to create a release where variables from my library are used to replace values in SetParameters.xml. For replacing I used following task: https://github.com/qetza/vsts-replacetokens-task#readme
In my web.config I have following for my connectionStrings:
<connectionStrings configSource="config\connectionStrings.local.config" />
For deployment, this should use another file, eg:
<connectionStrings configSource="config\connectionStrings.config" />
My parameters.xml looks like this:
<parameter name="Connection Strings Config File Location"
defaultValue="__ConnectionStringsConfigurationFileLocation__">
<parameterEntry kind="XmlFile"
scope="\\Web.config$"
match="/configuration/connectionStrings/#configSource" />
<parameter name="Umbraco Database Connection String"
defaultValue="__UmbracoDatabaseConnectionString__">
<parameterValidation kind="AllowEmpty" />
<parameterEntry kind="XmlFile"
scope="\\config\\connectionStrings.config$"
match="/connectionStrings/add[#name='umbracoDbDSN']/#connectionString" />
The variable ConnectionStringsConfigurationFileLocation is in my library:
After deploying, the value of the configSource in web.config remains untouched. But the value of connectionString in \config\connectionStrings.config is replaced succesfully.
What could be the issue that the web.config is not updating?
Edit: Screenshots tasks:
replace
deploy

Controlling the sequence of events in a Wixtoolset (.msi) installer

I am creating a Microsoft Installer (.msi file) using the Wixtoolset (Windows Installer XML). This installer must automate the installation of an existing .exe program (named installer.exe below) and copy a custom configuration file (named settings.conf below) to the target directory. In addition the installer must modify the configuration file using the InstallFiles command below. But the timing of events is critical. If the executable installer runs too early, it fails or exhibits strange behavior. And if the executable installer run too late in the install sequence, it overwrites my modified configuration file with the generic values. I believe this can be done by assigning a string to the Before or After property value. What Before or After property assignment will allow the executable to run properly but not overwrite the configuration file I moved by the CopyFile element? Here is my Wixtoolset XML code.
<Property Id="CONFIGFOLDER" Value="C:\acme\config" >
<Feature
Id="ConfigurationFile"
Title="Configuration File"
Level="1"
<ComponentRef Id="CMP_ACME_Config_File" />
</Feature>
<DirectoryRef Id="TARGETDIR">
<Component Id="CMP_ACME_Config_File" Guid="">
<File
Id="ACME_Config"
Source="MySettings.conf"
KeyPath="yes"
<CopyFile Id="Copy_ACME_Config"
DestinationProperty="CONFIGFOLDER"
DestinationName="settings.conf" />
</File>
</Component>
</DirectoryRef>
<Binary
Id="InstallerEXE"
SourceFile="installer.exe" />
<CustomAction
Id="Launch_Installer"
BinaryKey="InstallerEXE"
Impersonate="yes"
Execute="deferred"
ExeCommand=""
Return="check" />
<InstallExecuteSequence>
<Custom Action="Launch_Installer"
Before="InstallFiles">
</Custom>
</InstallExecuteSequence>
</Property>
I can't explain exactly why this works but assigning "InstallFiles" to the "After" property in the "Custom" element seems to do the trick.
<InstallExecuteSequence>
<Custom Action="Launch_Installer"
After="InstallFiles">
</Custom>
</InstallExecuteSequence>

The Settings section with name 'Blah' in ConfigOverride 'Config' is invalid. Cannot find a section with the same name

I'm trying to add a new config section to our SF app configuration and it is failing:
Register-ServiceFabricApplicationType : The Settings section with name 'Blah' in ConfigOverride
'Config' is invalid. Cannot find a section with the same name.
Nothing fancy, done this many times before but I'm doing something wrong and I don't see.
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="eBenefits.OrganizationDomainType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Parameter1" DefaultValue="" />
<Parameter Name="Parameter2" DefaultValue="" />
<Parameter Name="Parameter3" DefaultValue="" />
</Parameters>
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
...
<Section Name="Blah">
<Parameter Name="Parameter1" Value="[Parameter1]" />
<Parameter Name="Parameter2" Value="[Parameter1]" />
<Parameter Name="Parameter3" Value="[Parameter1]" />
</Section>
</Settings>
</ConfigOverride>
</ConfigOverrides>
...
</ApplicationManifest>
Copying application to image store...
Upload to Image Store succeeded
Registering application type...
Register-ServiceFabricApplicationType : The Settings section with name 'Blah' in ConfigOverride
'Config' is invalid. Cannot find a section with the same name.
FileName: C:\SfDevCluster\Data\ImageBuilderProxy\AppType\a2b68765-272d-4477-aad2-f3d4818365c7\ApplicationManifest.xml
At C:\Program Files\Microsoft SDKs\Service
Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:251 char:9
+ Register-ServiceFabricApplicationType -ApplicationPathInImage ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Servi...usterConnection:ClusterConnection) [Register-Servic
eFabricApplicationType], FabricException
+ FullyQualifiedErrorId : RegisterApplicationTypeErrorId,Microsoft.ServiceFabric.Powershell.RegisterApplicationTyp
e
Finished executing script 'Deploy-FabricApplication.ps1'.
Time elapsed: 00:00:39.7598137
The PowerShell script failed to execute.
I forgot to define it in My-Service\PackageRoot\Config\Settings.xml
Reference: Full instructions on adding SF settings
For anyone else who encountered this issue and already have Settings.xml files, you may wish to create a new Settings.xml using the Visual Studio context menu (new xml file) and get rid of the previous one after copying its contents across. For whatever reason Visual Studio did not recognise that I had a Settings.xml file and thus SF was unable to access it.
After doing this everything works.

Using text input parameter on cruisecontrol dashboard

In my Cruisecontrol task, I wish to xcopy code from a folder name, specified by the user on the dashboard. Is there a way to show a text input box on my CC dashboard along my project, which can be used in the ccnet.config file during xcopy? Or is this too wishful?
It turns out that CruiseControl.net has now added support for parameters.
A configuration similar to below needs to be added to the node of your ccnet.config:
<parameters>
<selectParameter>
<name>TargetSite</name>
<allowedValues>
<value name="DEV">DEV</value>
<value name="AT">AT</value>
</allowedValues>
</selectParameter>
<selectParameter>
<name>Operation</name>
<allowedValues>
<value name="start">start</value>
<value name="stop">stop</value>
</allowedValues>
</selectParameter>
</parameters>
Doing so would show up these as input parameters when you do a force start!
These parameters, can then be used as variables in the such as $[TargetSite]

How can I force IIS 7 to flush output?

In IIS 6, using Perl, I was able to send a stream of output to the client rather than buffering the entire thing and dumping it out at all once. This allowed such things as progress bars and such to be used.
How can I accomplish the same thing in IIS 7?
Under IIS 7, once you have created the Perl Script script mapping, you can add an attribute that will fix this.
You modify the %windir%\system32\inetsrv\config\applicationHost.control file and find the script mapping by name (in my case, Perl-Script). Then add the responseBufferLimit attribute into the XML, for example:
<add name="Perl-Script" path="*.pl" blah blah blah responseBufferLimit="0" />
This causes IIS to run as it did in IIS 6, with buffering off.
You can customize the web application's web.config to set responseBufferLimit="0" instead of changing global settings. Example web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Perl CGI for .pl (custom)" path="*.pl" verb="GET,HEAD,POST" modules="CgiModule" scriptProcessor="C:\Perl64\bin\perl.exe "%s" %s" resourceType="File" requireAccess="Script" responseBufferLimit="0" />
</handlers>
</system.webServer>
<system.web>
<identity impersonate="false" />
</system.web>
</configuration>
Place this file in the web root directory. It will override server settings for *.pl.
The ONLY thing that worked for my in IIS 7.5 (Windows 7) was the following command, run from CMD:
appcmd.exe set config /section:handlers "/[name='PHP_via_FastCGI'].ResponseBufferLimit:0"
NOTE: You must replace PHP_via_FastCGI with the name of your PHP handler in "Handler Mappings".