Configuration Preprocessor and conditional statements - cruisecontrol.net

I am trying to set a conditional statement to use an attribute depending on its value.
I am not sure ccnet-config supports conditions
For example:
<cb:define project-name="$(name)" />
<cb:if test:"$(project-name == '')">
<cb:define project-name="$(name)" />
</cb:if>

The CruiseControl.NET pre-processor, as of version 1.5, doesn't support conditional statements, so this is not possible.

1.6 support this, and a few other new constructs (see the preprocessor documentation, new features are towards the bottom)

Related

How to specify version of language to be scanned in sonarqube?

I am new to Sonarqube. I want to scan my python files on sonarqube with rules of Python 2.7 and not Python 3. I am specifying sonar.language=py while scanning. Is there any way to specify version of python? Also how to know what version of Python rules are set in sonarqube?
There's no way to specify that.
A few rules are tagged with "python3", but they can still be relevant for you.
You can define which rules are applied by managing "quality profiles": have a look at the documentation.

How to modify codecoverage.config to specify which module to include during VS2012 dynamic code coverage?

I am trying to use VS2012 dynamic code coverage tool to do code coverage analysis for my application.
I find an example that I can use it like follows:
CodeCoverage.exe collect /output:C:\test.coverage c:\aut.exe
This works well however, my aut.exe will load many dlls and I simply don't want to get code coverage information for every dll. So I need to modify the CodeCoverage.config file in VS2012 dynamic code coverage Tools folder to only include some dlls I want.
I look at the config file, it looks like:
<SymbolSearchPaths />
<!--
The module include/exclude list by the full path from where the module loaded.
Entries in this list are case-insensitive.
-->
<ModulePaths />
This file is a little bit different with the previous .runsettings file. I tried adding following code in the config file:
<ModulePaths>
<Include>
<!-- Include modules of interest, by their name / path -->
<ModulePath>SomeSpecial.dll</ModulePath>
</Include>
<Exclude>
<!—- Do not specify any excludes. Anything not included will get excluded -->
</Exclude>
</ModulePaths>
But it did not work. I guess the grammar here is a little different with the .runsetting file.
So can anyone guide me on how to modify the codecoverage.config file to only include specific dlls for code coverage?
OK, I finally solved the problem myself...
Actually there is a way to only include some dlls for code coverage. I should use regular expressions when defining the module path for include.
For example:
<ModulePaths>
<Include>
<ModulePath>.*SomeSpecial\.dll$</ModulePath>
<ModulePath>.*Special\.dll$</ModulePath>
</Include>
</ModulePaths>
The key is add ".*" before your dll name and add "\" before "." because the node for Module path here only allows for regular expression. Using this method, I successfully include the dlls I want for code coverage.

Exclude file from stylecop checking

I want to exclude /Properties/AssemblyInfo.cs from stylecop checking.
Can we do that?
the problem is that i have integrated stylecop with nant. In nant i am stamping product version so the information from Assembly info changes and it gives warning in nant email. I am using stylecopcmd
for nant integration.
There are a couple of ways to do this. The recommended method is with file lists. Here is an example:
<StyleCopSettings Version="4.3">
<SourceFileList>
<SourceFile>AssemblyInfo.cs</SourceFile>
<Settings>
<GlobalSettings>
<BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty>
</GlobalSettings>
</Settings>
</SourceFileList>
</StyleCopSettings>
Alternatively you can use the ExcludeFromStyleCop setting in the project file as documented here:
<Compile Include="AssemblyInfo.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>

got subsonic compile error

I use visual studio 2010 and tried to use subsonic and i am getting the following error.
Error 2 Compiling transformation: Metadata file 'MySql.Data' could not be found D:\TradingTools\CODE\ConsoleApplication8\subsoniccomponents\Structs.tt 1 1 backtester
As you can see from the screenshot, i do have mysql.data in my references. i dunno how to fix this. Can you help fixing this problem.
http://postimage.org/image/s1es0mr79/
SubSonic uses the DbProviderFactory pattern.
The DbProviderFactory approach allows the creation of Connections/Commands/... without knowning the concrete type.
// without factory
var con = new MySqlConnection();
var cmd = new MySqlCommand();
// with factory
var factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
var con = factory.CreateConnection();
var cmd = factory.CreateCommand();
which is a way more generic approach.
However, in order for this to work, you have to install MySql.Data (the msi-Package) which makes some entries in the machine.config file.
That said,
I also prefer my build environment not to rely on installed software, which makes it a lot easier to switch to a new machine without installing multiple dependencies.
But this requires a little bit work:
Modify your app.config/web.config file and place this somewhere between <configuration> and </configuration>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
I just copied and pasted the snippet from
%windir%\Microsoft.NET\Framework\<version>\Config
after installing the MSI.
If your solution has multiple projects, you have to do this for the main project (so subsonic can find your provider at runtime) and in your DAL project (so subsonic can find your provider during code generation).
If you use another MySQL Version you can change that.
The second thing you have to do is to tell the templates where to find the MySql.Data.dll (if it is not in the GAC).
You can do this by editing the MySQL.ttinclude file (look at the assembly directive)
<## include file="Settings.ttinclude" #>
<## assembly name="$(SolutionDir)\Dependencies\MySql.Data.dll" #>
<## import namespace="MySql.Data.MySqlClient" #>
<#+
With these changes my solution runs find and template generation also works find on a clean install without any MySql Components installed.

How to load a text file from within an XQuery?

Is there an XQuery command to load a text file?
I can load an xml document by doing the following;
declare variable $text := doc("test.xml");
But it only seems to work if test.xml is a well-formed xml document. What I want is to load a plain test.txt file into a string variable. Something like this;
declare variable $str as xs:string := fn:loadfile("test.txt");
Can it be done?
I'm using the Saxon engine but I can't find an answer in the saxon documentation.
Indeed you can find one implementation of the file functions in Zorba: http://www.zorba-xquery.com/doc/zorba-1.4.0/zorba/xqdoc/xhtml/www.zorba-xquery.com_modules_file.html
XQuery 3.0 has the function fn:unparsed-text (which was originally defined in XSLT), which does exactly what you want. XQuery 3.0 is still a work in progress though, but whilst there are not many XQuery 3.0 processors available, many XQuery processors already support this function (including Saxon).
There is a standardization effort for this on EXPath. A spec already exists for an XQuery File module that is capable of doing what you describe: EXPath File Module Spec.
Yet, I don't know how many implementations are out there. Saxon doesn't seem to implement it unfortunately (Or, please point me to it). An example implementation is shipped with zorba (see XQDoc Site of Zorba). If you want to know how to get started with zorba, you can check out this tutorial: Get Started with XQuery and Zorba.
XQuery by default( means fn: namespace ) doesn;t have any file-access methods.
MarkLogic :
xdmp:filesystem-file()
xdmp:filesystem-directory()
Zorba:
already mentioned by user457056
Exist
Exist File Module
Saxon since version 9.2 has an extension of fn:collection that can be used to read unparsed text. Here is an example:
collection('file:///c:/TEMP?select=text.txt;unparsed=yes')
This is described under "Changes in this Release" for 9.2. Apparently it is not mentioned in the function library documentation. However it works well and I have been using it a lot.

Resources