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
Is it possible to show the script of a macro to learn what it actually does?
Where are the macros stored so I can inspect the files, maybe they are human readable.
Once macro is saved, and Notepad++ is closed, macro will be saved to:
%USERPROFILE%\AppData\Roaming\Notepad++\shortcuts.xml
(c:\Users\%your user%\AppData\Roaming\Notepad++\shortcuts.xml)
Into <Macros> tag. It's sort of human readable: as each step is an <Action> tag, so steps could be deleted/copy-pasted, but to create a new steps it's much easier to record a new macro.
The default path of shortcuts.xml is C:\Users\%YOUR USERNAME%\AppData\Roaming\Notepad++ Here’s an simple RegEx replacement example of some of mine:
<Macro name="SO-Test" Ctrl="yes" Alt="no" Shift="yes" Key="112">
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam="(.+)" />
<Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
<Action type="3" message="1602" wParam="0" lParam="0" sParam="\1 \1" />
<Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
<Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
</Macro>
There are 2 locations that the shortcuts.xml file resides in. Notepad++ could be using either one, depending on how it was installed. Try the C:\Program Files\Notepad++ folder or C:\Program Files (x86)\Notepad++ folder.
Depending on whether you installed the 32bit or 64bit Notepad++ program it could be in either of the 2 Program Files folders (you can only install 64bit version if Windows is also 64bit).
I want to know if there is a way to run all PMD rulesets from command line.
I've used PMD integrated with Eclipse IDE and Maven. But now I need to run it from CLI.
I've checked this page http://pmd.sourceforge.net/pmd-5.1.0/running.html and it says you can run it from CLI, but with specified rulesets:
C:\tmp\pmd-bin-5.1.0\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml
In that example, you just get results for Java unused code rule and I'm trying to achieve something like:
C:\tmp\pmd-bin-5.1.0\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/*.xml
and get results for all rules in Java rulesets.
You can define a config file which includes the rulesets you wish to run. You can give this file as a parameter after the -R argument on the command line.
An example file is here (MyRules.xml):
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ruleset name="PMD.rul" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>This ruleset was created from PMD.rul</description>
<rule ref="rulesets/java/basic.xml">
<exclude name="UnnecessaryFinalModifier"/>
</rule>
<rule ref="rulesets/java/braces.xml"/>
<rule ref="rulesets/java/clone.xml"/>
<rule ref="rulesets/java/comments.xml"/>
<rule ref="rulesets/java/controversial.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="UnnecessaryParentheses"/>
</rule>
<rule ref="rulesets/java/design.xml">
<exclude name="GodClass"/>
</rule>
<rule ref="rulesets/java/empty.xml"/>
<rule ref="rulesets/java/finalizers.xml"/>
<rule ref="rulesets/java/imports.xml"/>
<rule ref="rulesets/java/j2ee.xml"/>
<rule ref="rulesets/java/javabeans.xml"/>
<rule ref="rulesets/java/junit.xml"/>
<rule ref="rulesets/java/logging-jakarta-commons.xml"/>
<rule ref="rulesets/java/logging-java.xml"/>
<rule ref="rulesets/java/naming.xml"/>
<rule ref="rulesets/java/optimizations.xml"/>
<rule ref="rulesets/java/strictexception.xml"/>
<rule ref="rulesets/java/strings.xml"/>
<rule ref="rulesets/java/sunsecure.xml"/>
<rule ref="rulesets/java/typeresolution.xml"/>
<rule ref="rulesets/java/unnecessary.xml">
<exclude name="UnnecessaryFinalModifier"/>
<exclude name="UnnecessaryReturn"/>
<exclude name="UselessParentheses"/>
</rule>
<rule ref="rulesets/java/unusedcode.xml"/>
</ruleset>
The command line arguments would look like this:
C:\tmp\pmd-bin-5.1.0\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R MyRules.xml
I am trying to replace the occurance of a string in a wxs file using Nant.
I have only found the following example, which uses <replaceString>, but it seems like it can only be used within the copied files. Are there any other way of replacing a string, without actually copying the files over?
<property name="NOW" value="${datetime::now()}" />
<copy todir="out">
<fileset basedir="in">
<include name="**/*" />
</fileset>
<filterchain>
<replacetokens>
<token key="NOW" value="${TODAY}" />
</replacetokens>
<tabstospaces />
</filterchain>
</copy>
Here's the code:
<loadfile file="token.txt" property="token-file">
<filterchain>
<replacetokens>
<token key="NOW" value="${datetime::now()}" />
</replacetokens>
</filterchain>
</loadfile>
The official NAnt docs for <loadfile> element contain the exact sample you need. See the bottom of the page.
Here's how I did it.
<loadfile file="${file}" property="file.content">
<filterchain>
<replacestring from="StringToMatch" to="StringToReplace" ignorecase="true" />
</filterchain>
</loadfile>
<echo file="${file}">${file.content}</echo>
So you are trying to modify a .wxs file which is XML, right?
In this particular case you might use <xmlpoke> if you are able to determine the position of the strings to replace via XPath.
I found a solution for you here: http://frank.overseakids.com/?p=182
<loadfile file=”${dir.template}\template.db_name.sql” property=”restore.db.sql.db_name”>
<filterchain>
<replacetokens>
<!– this looks for tokens like #blah.blah# in the file being loaded and replaces them–>
<token key=”restore.db.prefix” value=”${restore.db.prefix}” />
<token key=”backup.file.path” value=”${backup.file.path}” />
</replacetokens>
</filterchain>
</loadfile>
<property name=”current.db” value=”db_name” />
<property name=”current.log” value=”${dir.log}\${restore.db.logfile.prefix}_db_name.log” />
<property name=”current.file” value=”${dir.template}\restore.db_name.tmp.sql” />
<delete if=”${file::exists(current.file)}” file=”${current.file}” />
<echo file=”${current.file}”>${restore.db.sql.db_name}</echo>
You can wrap this in a <foreach /> element.
I never managed to get the filterchain and replacetokens to work properly. I ended up using this and it works great.
<replacetext filename="${filename}" src="stringToBeReplaced" replacement="replacementString" />
All these answers did not work for me, maybe because I needed to replace a string with spaces in it. Loading a file content with filterchain/replacetokens did nothing to the contents of the associated property. Maybe I'm using it wrong.
The tasks "replacestring" and "replacetext" suggested by #Ally and #John Sterne do not exist.
It's included in a Jenkins build process, thus the ENVIRONMENT variable must be set to the working dir.
<loadfile file="./my/batch.bat" property="file.content" />
<property name="file.content"
value="${string::replace(file.content, 'D:\path to\the working\space', environment::get-variable('WORKSPACE'))}" />
<property name="file.content"
value="${string::replace(file.content, 'Cd C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin', 'CD /D C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin')}" />
<echo file="./my/batch.bat">${file.content}</echo>
I had that problem today. To solve it I used the move command instead of loadfile or copy. This worked for me because since my file was pretty small. The other caution about this is that replacetokens needs a start identifier and end identifier of the token; begintoken and endtoke respectively. If those are not set the default values are the # symbol. So if you want to replace a value such as MY_SERVER_PLACE_HOLDER that means the value in your file must be #MY_SERVER_PLACE_HOLDER#. If you want your token to start with something different than you should specify the begintoken and endtoken values. That should give you an idea of the problems the begin token and endtoken will bring you.
So here is what I did in a nutshell
Moved the file to a temporary location. In that move I used
filterchain with removetokens to change the values in the file.
In step 2, I moved the file back to it's original location.
I then used the delete command to delete the temp folder I created.
Here is a what I did. (May not be syntactically correct since I am not in front of the code at the moment)
<move todir="temp">
<fileset basedir="in">
<include name="myfile.dat" />
</fileset>
<filterchain>
<replacetokens>
<token key="MY_SERVER_PLACE_HOLDER" value="http://www.someserver.com" />
</replacetokens>
<tabstospaces />
</filterchain>
</move>
<move todir="in">
<fileset basedir="temp">
<include name="myfile.dat" />
</fileset>
</move>
<delete dir="temp" />
In my cspex I have action that creates product
<public name="create.product" actor="ant">
<actorProperties>
<property key="buildFile" value="build/product.ant" />
<property key="targets" value="create.product" />
</actorProperties>
<properties>
<property key="profile" value="iitProfile" />
<property key="iu" value="iit.product" />
</properties>
<prerequisites alias="repository">
<attribute name="site.p2" />
</prerequisites>
<products alias="destination" base="${buckminster.output}">
<path path="product.${target.ws}.${target.os}.${target.arch}/" />
</products>
</public>
When the final product is being build, folder created looks like this product.${target.ws}.${target.os}.${target.arch}. How can I append qualifier replacement that I set via qualifier.replacement property? I thought I could do something like product.${target.ws}.${target.os}.${target.arch}_{qualifier.replacement} where qualifier.replacement is the property that was set during execution of buckminster.versionQualifier.
I know when I execute action site.p2.zip qualifier replacement is being appended to the name of the file, so how can I use this in my other actions? Do I have execute buckminster.versionQualifier task myself?
thanks!
Opened enhancement about this on eclipse bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=321753