I am using the following in my project files:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="Exists('App.$(Configuration).config')">
<!--Generate transformed app config in the intermediate directory-->
<TransformXml Source="App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="App.$(Configuration).config" />
<!--Force build process to use the transformed configuration file from now on.-->
<ItemGroup>
<AppConfigWithTargetPath Remove="App.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
However, if I have a config item on multi-lines
<add key="MultiLine" value="option1,
option2,
option3 />
It gets transformed to
<add key="MultiLine" value="
option1,
option2,
option3/>
How can I prevent that?
Thank you
Ryan
Related
I have a biml file and want to use the include directive to bring in biml from another file that can get reused in other places, but it keeps giving this error when I do Check for Errors with BIDSHelper:
There are multiple root elements
I see examples online of people using the include directive but no mention on this problem. I can't find any valid element to wrap my biml in, it has to be this chunk.
ErrorHandling.biml:
<UnionAll Name="Union Errors">
<InputPaths>
<InputPath OutputPathName="Lookup Site.Error" />
<InputPath OutputPathName="Detail Level Source.Error" />
<InputPath OutputPathName="Site to Integer.Error" />
</InputPaths>
</UnionAll>
<DerivedColumns Name="Error Metadata">
<InputPath OutputPathName="Union Errors.Output" />
<Columns>
<Column Name="execution_guid" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)#[User::ExecutionGUID]</Column>
<Column Name="error_time" DataType="DateTime" >GETDATE()</Column>
<Column Name="PackageID" DataType="AnsiString" Length="38" CodePage="1252">(DT_STR,38,1252)#[System::PackageID]</Column>
<Column Name="DataflowID" DataType="AnsiString" Length="38" CodePage="1252">(DT_STR,38,1252)#[System::TaskID]</Column>
<Column Name="Step_Name" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)"QI Load"</Column>
<Column Name="Task_Name" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)"Detail Level Check"</Column>
</Columns>
</DerivedColumns>
Master.biml snippet:
<RowCount Name="Row Count" VariableName="User.CheckRowCount">
<InputPath OutputPathName="Lookup Site.Match" />
</RowCount>
<## include file="ErrorHandling.biml" #>
</Transformations>
I found two ways to get this to work- either change the extension of the file to something like .txt or simply don't select it when you "compile" your files with BIDSHelper and do "Check BIML for Errors" or "Generate SSIS packages". Just select the main files that use any included files and contain proper XML.
I want to create a static block on homepage in right side for user login. Please see the below screen short:-
enter image description here
Try to update a layout XML file app/design/frontend/*DEFAULT*/*DEFAULT*/layout/.
You also may create your own local.xml file and put it in the contents.
<layout version="0.1.0">
<default>
<reference name="right">
<block type="your/type" template="path/to/your/template.phtml" />
</reference>
</default>
</layout>
I am creating a line chart in one view(myChartView) and saving it as _ChartFiles/chart01.jpg.
var filePathName = "_ChartFiles/chart01.jpg";
Which is saving at /views/myChartView/_ChartFiles/chart01.jpg . Now in the very next line making a reference it as
<img src="#filePathName" />
but this is not displaying the image. what would be correct way to refer it?
If you want some static files to be accessed directly by the client, you cannot store them in the ~/Views folder because by default (for security reasons) the server would not serve content from this folder.
See ~/Views/Web.Config:
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
Try to save the files in other directory like ~/Static.
You should save it in another folder than "Views" because in MVC this is a folder conventionned for HTML view and no other content, try to save it in "fonts" or whatever else,
and it would be :
<img src="fonts/yourimage.jpg" />
Try giving the image path as
filePathName = "../views/myChartView/_ChartFiles/chart01.jpg";
or
filePathName = "~/views/myChartView/_ChartFiles/chart01.jpg";
//try this one
filePathName = "myChartView/_ChartFiles/chart01.jpg";
<img src="#filePathName" />
I am trying to "function"alize few lines of ant-code using macrodef. But its resulting in error like :
copy doesn't support the nested "my-macro" element.
If I "inline" definition of my-macro of adding filterchian within copy-task it works.
My test target looks like this -
<target name="copy-files">
<sequential>
<copy todir="abc" >
<fileset dir="xyz">
<!--needy includes/excludes -->
</fileset>
<my-macro/>
</copy>
</sequential>
</target>
And my-macro looks like this:
<macrodef name="my-macro">
<sequential>
<filterchain>
<fixcrlf includes="**" eol="lf"/>
</filterchain>
</sequential>
</macrodef>
Code which works (inlined-one ) looks like :
<target name="copy-files">
<sequential>
<copy todir="abc" >
<fileset dir="xyz">
<!--needy includes/excludes -->
</fileset>
<filterchain>
<fixcrlf includes="**" eol="lf"/>
</filterchain>
</copy>
</sequential></target>
The copy task doesn't accept a nested macro element, thats what the errormessage says.
Put the whole copy stuff into your macrodef, f.e. :
<macrodef name="my-macro">
<attribute name="dest"/>
<attribute name="fsdir"/>
<attribute name="fsincludes"/>
<attribute name="fsexcludes"/>
<attribute name="fixincl"/>
<sequential>
<copy todir="#dest}">
<fileset dir="#{fsdir}">
<include name="#{fsincludes}"/>
<exclude name="#{fsexcludes}"/>
</fileset>
<filterchain>
<fixcrlf includes="#{fixincl}" eol="lf"/>
</filterchain>
</copy>
</sequential>
</macrodef>
-- EDIT --
If number of filesets varies, remove the fsincludes and fsexcludes attribute if not valid for all filesets and use element like that :
<macrodef name="my-macro">
<attribute name="dest"/>
<element name="fs" description="nested filesets"/>
<attribute name="fixincl"/>
<sequential>
<copy todir="#dest}">
<!-- 1-n nested filesets) -->
<fs/>
<filterchain>
<fixcrlf includes="#{fixincl}" eol="lf"/>
</filterchain>
</copy>
</sequential>
</macrodef>
<my-macro dest="C:/whatever" fixincl="**">
<fs>
<fileset dir="." includes="**/*.foo"/>
<fileset dir="../foo" includes="**/*.xml"/>
<!-- ... -->
</fs>
</my-macro>
-- EDIT --
To copy a single file with nested fileset use :
<fileset file="C:/somepath/some.file"/>
-- EDIT --
If you need other copysteps with file tofile, you may use another element if that is sufficient:
<macrodef name="my-macro">
<attribute name="dest"/>
<element name="copyfiles" description="nested copy"/>
<element name="fs" description="nested filesets"/>
<attribute name="fixincl"/>
<sequential>
<copy todir="#dest}">
<!-- 1-n nested filesets) -->
<fs/>
<filterchain>
<fixcrlf includes="#{fixincl}" eol="lf"/>
</filterchain>
</copy>
<copyfiles/>
</sequential>
</macrodef>
<my-macro dest="C:/whatever" fixincl="**">
<fs>
<fileset dir="." includes="**/*.foo"/>
<fileset dir="../foo" includes="**/*.xml"/>
<!-- ... -->
</fs>
<copyfiles>
<copy file="..." tofile="..."/>
<!-- ... -->
</copyfiles>
</my-macro>
Normally for bulk renaming of files a mapper is used.
After all if it gets more complicated you should consider scripting with Groovy or write your own Ant Task.
Rebse's answer already shows what you should go with <macrodef>, and here's some explanation.
Copy Task
<copy>, <macrodef>, <sequential> are Ant tasks. Each Ant task is backed with Java code. Most of Java classes of built-in Ant tasks are under org.apache.tools.ant.taskdefs, e.g. Copy.java is the backend of <copy> task.
The nested elements of a task is handled by the task's Java code. For <copy> task, it's code in Copy.java (or other classes it depends on) handling the nested elements.
You will see in Copy.java methods named with createFilterChain, addFileset, createMapper and others. That's why <copy> supports fileset, filterchain, mapper and other nested elements stated in Copy's manual page.
Macrodef
This defines a new task using a nested task as a template.
Macrodef is a way to define an Ant task without coding in Java. It turns its nested Ant xml lines into a new task, which works the same way as other Ant tasks.
Obviously, you should not just put a <filterchain> in <macrodef>, as <filterchain> is not an Ant task, but an Ant type.
So my question is relatively simple.
In my Parameters.xml file I have the following line:
<parameter name="SEND_TO_FRIEND_BCC" description="Email address of developer" defaultValue="" tags="">
<parameterEntry kind="XmlFile" scope"\\web.config$" match="/configuration/appsettings/add[#key='SEND_TO_FRIEND_BCC']/#value" />
</parameter>
When publish this is creating a file that ends up like this:
<setParameter value="" name="SEND_TO_FRIEND_BCC" />
When going live, this should replace the current web.config value for SEND_TO_FRIEND_BCC to an empty string. Instead, when I try an publish I get the following:
Error: The 'SEND_TO_FRIEND_BCC" argument cannot be null or empty.
Error count: 1.
at InRelease.MSDeploy.Program.Main(String[] args)
Have to tell MSDeploy that it is okay for the value to be empty ...
<parameter name="SEND_TO_FRIEND_BCC" description="Email address of developer" defaultValue="" tags="">
<parameterValidation kind="AllowEmpty" />
<parameterEntry kind="XmlFile" scope"\\web.config$" match="/configuration/appsettings/add[#key='SEND_TO_FRIEND_BCC']/#value" />
</parameter>
So, by pure chance I tried entering a single empty space and it worked.
If there is a better way I am still eager to learn more...