Is it possible to retain newlines when using CDATA in BIML Variables? - biml

I have some SQL in a variable that I want to use in a BIML template. (Originally I was getting the SQL from a C# variable, but that doesn't seem to be relevant) I'm using BIML like this:
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="Source" ConnectionString="Provider=SQLNCLI11;Data Source=localhost\dev2017;Integrated Security=SSPI;Initial Catalog=tempdb;" />
</Connections>
<Packages>
<Package Name="SO_51407483" ConstraintMode="Linear">
<Variables>
<Variable Name="querySql" DataType="String" IncludeInDebugDump="Exclude" EvaluateAsExpression="true">
<![CDATA["SELECT --This is a comment
1 AS Col1"]]>
</Variable>
</Variables>
<Tasks>
<Dataflow Name="DFT Demo">
<Transformations>
<OleDbSource Name="OLESRC query" ConnectionName="Source">
<VariableInput VariableName="User.querySql" />
</OleDbSource>
</Transformations>
</Dataflow>
</Tasks>
</Package>
</Packages>
</Biml>
The issue I have is that when the file is compiled the line breaks in querySql appear to be stripped out, but only during the validation step of the compilation. This means that anything after the first comment in querySql becomes part of the comment and BIML's validation fails.
The error message is:
Node OLESRC query: Could not execute Query on Connection Source:
SELECT --This is a comment1 AS Col1
Incorrect syntax near 'SELECT'
If I change querySql to use the /* */ style of comment the validation passes. If I then open the generated dtsx and look at the variable in SSIS the line breaks are there again.
Is there a way around this without having to use /* */ everywhere?
Experiments
This doesn't compile:
<Variable Name="querySql" DataType="String" IncludeInDebugDump="Exclude" EvaluateAsExpression="true">
"SELECT --This is a comment
1 AS Col1"
</Variable>
This compiles, and the resulting dtsx variable ends up with one line break
<Variable Name="querySql" DataType="String" IncludeInDebugDump="Exclude" EvaluateAsExpression="true">
"SELECT /*This is a comment*/
1 AS Col1"
</Variable>
This compiles, and the resulting dtsx variable ends up with two line breaks
<Variable Name="querySql" DataType="String" IncludeInDebugDump="Exclude" EvaluateAsExpression="true">
"SELECT --This is a comment
1 AS Col1"
</Variable>
I've raised this with Variagence: https://github.com/varigence/BimlPit/issues/82

As a minimal repro, I'm getting the carriage return/line feeds preserved.
I declare my query variable and then use it in both an Execute SQL Task and a Dataflow's OLEDB Source.
The Execute SQL Task doesn't look like it preserves the CR/LF until you click the ellipses but then the popup correctly displays the code.
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#
string query = #"--This is a comment
SELECT 1 AS Col1";
#>
<Connections>
<OleDbConnection Name="Source" ConnectionString="Provider=SQLNCLI11;Data Source=localhost\dev2017;Integrated Security=SSPI;Initial Catalog=tempdb;" />
</Connections>
<Packages>
<Package Name="SO_51407483" ConstraintMode="Linear">
<Tasks>
<ExecuteSQL Name="SQL Test Task" ConnectionName="Source">
<DirectInput><![CDATA[<#=query#>]]></DirectInput>
</ExecuteSQL>
<Dataflow Name="DFT Demo">
<Transformations>
<OleDbSource Name="OLESRC query" ConnectionName="Source">
<DirectInput><![CDATA[<#=query#>]]></DirectInput>
</OleDbSource>
</Transformations>
</Dataflow>
</Tasks>
</Package>
</Packages>
</Biml>

Related

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.

SSMA ProtectedStorage.ssma file being used by another process

I am getting a repeated error trying to build the protected storage file for SSMA for Oracle version 6.0.1. I have made various attempts; nothing works! SSMA insists on writing to the roaming profile directory and the file it writes to is ALWAYS in use. Even if I reboot it is reported to be "in use." Even if I power down and restart, it is reported to be in use. Even when I use my home computer (which is configured with a local profile and where there is no place to roam), the application writes to the roaming profile and the file is reported to be in use. It is the same with SSMA 5.3. I also tried launching the special command shell with the same result. It is the same with the 2012 server version. I also tried using hardcoded values and skipping the variable file.
No one else reports this issue. Does anyone know what am I doing wrong or how I can work around this issue?
Here is the command and error text:
C:\Windows\System32>SSMAforORacleConsole.exe -securepassword -add DEV -s "y:\dba\projects\OracleToSQLServerMigration\SSMAProjects\DEV_Migration\command-config\DataMigrationDEV.xml" -v y:\dba\projects\OracleToSQLServerMigration\SSMAProjects\DEV_Migration\command-config\VariableValueFileSample - DEV.xml"
[5/19/2016 10:32:33 AM] INPUT Enter password for server id 'DEV': ****
[5/19/2016 10:32:36 AM] INPUT Re-enter password for server id 'DEV': ****
[5/19/2016 10:32:38 AM] FATALERR Unexpected error during addition of servers to protected storage
[5/19/2016 10:32:38 AM] **NESTED The process cannot access the file 'C:\Users\amorris\AppData\Roaming\Microsoft SQL Server Migration Assistant\Oracle\ProtectedStorage.ssma' because it is being used by another process.**
Here is the connection file, DataMigrationDEV.xml (edited to remove server information):
<?xml version="1.0" encoding="UTF-8"?>
-<ssma-script-file xsi:noNamespaceSchemaLocation="..\Schemas\O2SSConsoleScriptSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<config>
-<output-providers>
<data-migration-connection target-server="AAA_DEV" source-server="DEV"/>
<log-verbosity level="debug"/>
</output-providers>
</config>
-<servers>
-<sql-server name="AAA_DEV">
-<windows-authentication>
<server value="$SQLServerName$"/>
<database value="$SQLServerDb$"/>
<encrypt value="true"/>
<trust-server-certificate value="true"/>
</windows-authentication>
</sql-server>
-<oracle name="DEV">
-<tns-name-mode>
<connection-provider value="Oracle Client Provider"/>
<service-name value="$OracleInstance$"/>
<user-id value="$OracleUserName$"/>
</tns-name-mode>
</oracle>
</servers>
-<script-commands>
<connect-source-database server="DEV"/>
<connect-target-database server="AAA_DEV"/>
<map-schema sql-server-schema="$SQLServerDb$.dbo" source- schema="$OracleSchemaName$"/>
<migrate-data verbose="true" report-errors="true" write-summary-report- to="$SummaryReports$" object-type="category" object-name="$OracleSchemaName$.Tables"/>
</script-commands>
</ssma-script-file>
Here is the variable file (edited to remove identifying information):
<?xml version="1.0" encoding="utf-8"?>
<!--
Variable value file for SSMA-v4.2 Console for Oracle adapted for AIMS.
Specified name and value attribute values are mandatory
Name values should begin and end with '$'
Use of this file is NOT mandatory
option -v[ariable]. See the documentation for SSMA-v4.2 Console for more information.
-->
<variables xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\Schemas\ConsoleScriptVariablesSchema.xsd">
<!--
********************************** MUST DO **************************************************
***** MUST replace occurrences of {<value>} with appropriate values wherever necessary *****
*********************************************************************************************
-->
<!--
***************************************************************************
***** The "working folder" {Working Folder Path} should exist *****
***** prior to console script execution *****
***************************************************************************
-->
<variable name="$WorkingFolder$" value="d:\app\OracleToSQLServerMigration\DEV_Migration\"/>
<variable-group name="OracleConnection">
<variable name="$OracleInstance$" value="DEV"/>
<variable name="$OracleUserName$" value="USERA"/>
<variable name="$OraclePassword$" value="{password}"/>
<variable name="$OracleSchemaName$" value="SCHEMAA"/>
</variable-group>
<variable-group name="SQLServerConnection">
<variable name="$SQLServerName$" value="dev.sample.edu\DEV"/>
<variable name="$SQLServerDb$" value="MigrationTest"/>
</variable-group>
<variable-group name="Report">
<variable name="$SummaryReports$" value="$WorkingFolder$"/>
<variable name="$AssessmentReportFolderName$" value="AssessmentReports"/>
<variable name="$AssessmentReports$" value="$WorkingFolder$\$AssessmentReportFolderName$"/>
<variable name="$RefreshDBFolder$" value="$WorkingFolder$"/>
<variable name="$ConvertARReportsFolder$" value="$WorkingFolder$\$AssessmentReportFolderName$"/>
<variable name="$SynchronizationReports$" value="$WorkingFolder$"/>
<variable name="$SaveScriptFolder$" value="$WorkingFolder$"/>
<variable name="$ConvertSQLReports$" value="$WorkingFolder$"/>
<!--
***************************************************************************
***** The folder {Folder where sql files are stored} needs to exists *****
***** and should contain the *.sql files that need to be converted *****
***** using convert-sql-statement command *****
***************************************************************************
-->
<variable name="$ConvertSqlSampleFiles$" value="$WorkingFolder$\ {Folder where sql files are stored}"/>
</variable-group>
<variable-group name="ProjectSpecs">
<variable name="$project_name$" value="DEV_Migration"/>
<variable name="$project_overwrite$" value="true"/>
<variable name="$project_type$" value="sql-server-2014"/>
<variable name="$project_folder$" value="$WorkingFolder$\$project_name$"/>
</variable-group>
</variables>
I have been through some web pages for file used by another process errors. I just do not see how the file could be used by another process. It gets created by this application! And the repetition on all servers makes a legitimate error or any kind of server permission error less likely.
Any ideas?
Thank you,
A L Morris

WiX Bootstrapper: How do I set burn variables from the command line?

Using WiX 3.7 and .NET 4.0.
How does one set burn variables when running a WiX bootstrapper EXE from the command line?
First of all, the burn variables that you wish to set need to be set as Overridable. To do this you must include the follow namespace in your WXS: xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" and if you're using Visual Studio like me you need to include WixBalExtension.dll in your project references. Next you need to add the following attribute to all of the burn variables that you want to set via the command line: bal:Overridable="yes".
Now you can set the variables via the command line in this fashion:
BootstrapperSetup.exe /i /passive MyBurnVariable1=1 MyBurnVariable2=2
Below is an example of a WXS file that satifies all of the conditions described above:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="MyProduct" Version="1.0.0" Manufacturer="MyManufacturer" UpgradeCode="PUT-UPGRADE-CODE-HERE">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
<bal:WixStandardBootstrapperApplication LicenseUrl="MyLicense.htm" ThemeFile="MyThemeFile.xml" LocalizationFile="MyLocFile.wxl" />
</BootstrapperApplicationRef>
<Variable Name="MyBurnVariable1" bal:Overridable="yes" Type="numeric" Value="0" />
<Variable Name="MyBurnVariable2" bal:Overridable="yes" Type="numeric" Value="0" />
<Chain>
<MsiPackage Id="MyFirstMsiPackage"
SourceFile="first.msi"
InstallCondition="MyBurnVariable1 = 1" />
<MsiPackage Id="MySecondMsiPackage"
SourceFile="second.msi">
<MsiProperty Name="MY_PROPERTY" Value="[MyBurnVariable2]" />
</MsiPackage>
</Chain>
</Bundle>
</Wix>

Why is NAnt executing my sql scripts in the wrong order?

Here is my Script:
<?xml version="1.0"?>
<project name="createAndPopulateDB" default="deploy">
<property name="sql.connstring" value="Provider=SQLOLEDB;Server=G-PC\sqlexpress;Integrated Security=SSPI" />
<property name="createDB" value="BuildTestDatabase.sql" />
<property name="populateDB" value="CreateTables.sql"/>
<target name="deploy">
<echo message="* Connecting to ${sql.connstring}"/>
<foreach item="File" property="sql.script">
<in>
<items>
<include name="${createDB}" />
<include name="${populateDB}" />
</items>
</in>
<do>
<echo message="* Executing ${path::get-file-name(sql.script)}"/>
<sql connstring="${sql.connstring}" delimiter="go" delimstyle="Line" batch="false" source="${sql.script}"/>
</do>
</foreach>
</target>
</project>
The NAnt script is supposed to call two tsql programs. The first tsql is designed to drop a database if it is present, and if it isn't, create it. The second checks to see if a table is present, and if so, delete it. Similarly if it isn't, it populates the created database with a simple table.
My question is why does it run the populateDB script first?
I found that the best way to determine the order in which the tsql programs are run is through a depends attribute attached to separate targets. This will run them in a predetermined order and is extremely easy to follow logically if the NAnt script is a part of a repository.

nant: expanding properties in a string

Summary:
How do I expand a property with value "download\${bulidmode}\project\setup.msi" to "download\Debug\project\setup.msi" if the property buildmode contained debug so I can use it as the file="" part of < copy >
Detail:
I have a bit of a requirement to be able to expand properties within a string in nant.
For example I have a target that is copying file A to B. A and B both come from a simple two field CSV file which I'm iterating through using
<foreach item="Line" in="filelist.csv" delim="," property="source.file,target.file">
<property name="sourcefile" value="${path::combine(source.dir,source)}" />
<property name="targetfile" value="${path::combine(download.dir,destination)}" />
<echo message="Copy ${sourcefile} to ${targetfile}" />
<copy file="${sourcefile" tofile="${destination}" />
</foreach>
and the filelist.csv will be
build\manifest.xml
solutiondirectory\setup-proj-directory\Release\setupproj.msi,ProductA\ProductA.msi
solutiondirectory\another-proj-dir\Release\setupproj.msi,ProductB\ProductB.msi
(The reason we split these out is that we write multi-tiered applications and deploy by MSI to each tier - so one product has multiple msi's all built with the same version numbers)
Anyway - I want to change this to that I no longer have "Release" in the filelist.csv file but something like ${build.mode}. I would wrap the above code with a
<foreach item="String" in="Release,Debug" delim="," property="build.mode">
....as above
</foreach>
and the property embedded within the string in the file gets expanded.
I've been beating my head against a brick wall for a few hours, but just can't figure it out.
Thanks
It is possible with a custom function :
<?xml version="1.0"?>
<project>
<script language="C#" prefix="vbfox" >
<code>
<![CDATA[
[Function("expand")]
public string ExpandString(string str)
{
return Project.Properties.ExpandProperties(str, Location.UnknownLocation);
}
]]>
</code>
</script>
<property name="hello" value="{path::combine('_hello_', '_world_')}" />
<property name="hello" value="${'$' + hello}" />
<echo message="${hello}" />
<echo message="${vbfox::expand(hello)}" />
</project>