Need to remove white spaces and PS dir when running from ant using filterchain and replaceregex pattern - regex

Here is a sample log file that I am trying to parse through
Added Change Sets
Component PS
9476: Build changes to make for Ant task [Nov 12, 2015 12:02 PM]
Work Item 9476: Build changes to make for Ant task
/PS/build/AntTaskHelper.xml
9582: Testing for EBF and migration script changes [Nov 12, 2015 12:02 PM]
Work Item 9582: Testing for EBF and migration script changes
/PS/database/ebf-migration/EBF-RTC-9582.sql
/PS/database/sif-internal-migration-scripts/RTC-9582.sql
9583: PKB PKG and Image File testing [Nov 12, 2015 12:02 PM]
Work Item 9583: PKB PKG and Image File testing
/PS/database/src/program-units/RTC-9583-PKG_CDT.pkb
/templates/Images/RTC-9583-ABAKER.TIF
/templates/Templates/RTC-9583-A100_1_20090101.xdp
Ultimately I need the results to show the following:
/database/ebf-migration/EBF-RTC-9582.sql
/database/sif-internal-migration-scripts/RTC-9582.sql
/database/src/program-units/RTC-9583-PKG_CDT.pkb
/templates/Images/RTC-9583-ABAKER.TIF
/templates/Templates/RTC-9583-A100_1_20090101.xdp
My regular expression works perfectly well when testing with a sample reg exp tester but not quite what I need when running in the build.
Here's my target
<target name="Parse">
<loadfile property="textFile" srcfile="${deployDir}\buildChanges1.txt">
<filterchain>
<linecontainsregexp>
<regexp pattern="((/database/(ebf-migration|sif-internal-migration-scripts/|src/program-units/))|(/templates/)).*" />
</linecontainsregexp>
<replaceregex pattern="((/database/(ebf-migration|sif-internal-migration-scripts/|src/program-units/))|(/templates/)).*" replace="\0"/>
</filterchain>
</loadfile>
<echo message= "value based on regex =${textFile}"/>
</target>
Here's the output from the build.
Parse:
[echo] value based on regex = /PS/database/ebf-migration/EBF-RTC-9582.sql
[echo] /PS/database/sif-internal-migration-scripts/RTC-9582.sql
[echo] /PS/database/src/program-units/RTC-9583-PKG_CDT.pkb
[echo] /templates/Images/RTC-9583-ABAKER.TIF
[echo] /templates/Templates/RTC-9583-A100_1_20090101.xdp
Any help on getting this to run would be greatly appreciated.

Related

Wix Bootstrapper will not open wpf ui

I have been attempting to write a WPF UI for the WiX installer that chains multiple msis from our company together.
I have followed This Link to do so, however, I cannot get the ui app tp open at all.
I have gotten the command line to run the MyBootstrapper.exe file and save the logs to the desktop.
[1CAC:1CB0][2020-08-06T08:31:55]i001: Burn v3.11.2.4516, Windows v10.0 (Build 18362: Service Pack 0),
path: C:\Users\james\AppData\Local\Temp\{75974D4E-F6FC-4A63-8B17-9C40D549A877}\.cr\MyBootstrapper.exe
[1CAC:1CB0][2020-08-06T08:31:55]i009: Command Line: '-burn.clean.room=C:\Users\james\Desktop\MyBootstrapper.exe -burn.filehandle.attached=632 -burn.filehandle.self=688 -l log.log'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\james\Desktop\MyBootstrapper.exe'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Setting string variable 'WixBundleOriginalSourceFolder' to value 'C:\Users\james\Desktop\'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\james\Desktop\log.log'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Setting string variable 'WixBundleName' to value 'MyBootstrapper'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Setting string variable 'WixBundleManufacturer' to value 'James'
[1CAC:1CB0][2020-08-06T08:31:55]i000: Loading managed bootstrapper application.
[1CAC:1CB0][2020-08-06T08:31:56]e000: Error 0x80131508: Failed to create the managed bootstrapper application.
[1CAC:1CB0][2020-08-06T08:31:56]e000: Error 0x80131508: Failed to create UX.
[1CAC:1CB0][2020-08-06T08:31:56]e000: Error 0x80131508: Failed to load UX.
[1CAC:1CB0][2020-08-06T08:31:56]e000: Error 0x80131508: Failed while running
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleAction = 5
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleElevated = 0
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleLog = C:\Users\james\Desktop\log.log
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleManufacturer = James
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleName = MyBootstrapper
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleOriginalSource = C:\Users\james\Desktop\MyBootstrapper.exe
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleOriginalSourceFolder = C:\Users\james\Desktop\
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleProviderKey = {3d87621d-9ee8-4412-843e-67b7d5da8dd5}
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleSourceProcessFolder = C:\Users\james\Desktop\
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleSourceProcessPath = C:\Users\james\Desktop\MyBootstrapper.exe
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleTag =
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleUILevel = 4
[1CAC:1CB0][2020-08-06T08:31:56]i410: Variable: WixBundleVersion = 1.0.0.0
[1CAC:1CB0][2020-08-06T08:31:56]e000: Error 0x80131508: Failed to run per-user mode.
[1CAC:1CB0][2020-08-06T08:31:56]i007: Exit code: 0x80131508, restarting: No
What I don't understand is why this never attempts to open the WixBootstrapper.Run method. I know this because, the very first line I have a log message that says Engine.Log(LogLevel.Verbose, "Starting Custom UI");
so I would assume that this has to be in the Bundle.wxs file that looks like.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="MyBootstrapper" Version="1.0.0.0" Manufacturer="James" UpgradeCode="c59306b1-bc3d-4aa0-9936-53f2a3484343">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
<Payload SourceFile="$(var.InstallerUI.TargetDir)BootstrapperCore.config"/>
<Payload SourceFile="$(var.InstallerUI.TargetDir)InstallerUI.dll"/>
<Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.11\bin\Microsoft.Deployment.WindowsInstaller.dll"/>
</BootstrapperApplicationRef>
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="Netfx45Full"/>
<WixVariable Id="WixMbaPrereqPackageId" Value="NetFxLicense.rtf"/>
<Chain>
<MsiPackage Id="WPFInstaller" SourceFile="$(var.Installer.TargetPath)" />
</Chain>
</Bundle>
</Wix>
On to my question, Can someone please explain what I am doing wrong, and why this doesn't open bootstrapper class in cs?
Also, I have extracted the MyBootstrapper.exe file and all of my dependencies are in it.
I was able to get past this point where it is now attempting to install the application, it still doesn't open the WPF UI, but it does now at least attempt it.
I had to change the BootstrapperCore.config From
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
To
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.5" />
</startup>

Robot Framework parsing for Notepad++ Function List

I'm trying to create a Notepad++ function list for Robot Framework scripts using the class structure to encapsulate the 4 different sections in a robot file:
Settings
Variables
Test Cases
Keywords
Using the documentation and some experimentation I created a simple filter that will return the keywords and test cases based on the fact that they start at the beginning of the line. But the more complex class grouping I need some regex help with. It seems that the *** should help with clear marking.
This is what I have thusfar:
I have installed the User Defined Robot Syntax Highlighting and have added the following section to the %app%\notepad++\functionList.xml
<association userDefinedLangName="Robotframework" id="robot_function"/>
And then in the parser section:
<parser
id="robot_function"
displayName="Robot Section"
commentExpr="((#.*?$)|(^Documentation*\w.*?$)|(^Meta*\w.*?$))|(^Library*\w.*?$)">
<function
mainExpr="^(\w.*?$)"
displayMode="$functionName">
<functionName>
<nameExpr expr="^(\w.*?$)"/>
</functionName>
</function>
</parser>
So, the part I'm having trouble with and I'd appreciate some help is:
<classRange mainExpr="^(\*).*(?=\n\S|\Z)">
<className>
<nameExpr expr="^(\w.*?$)"/>
</className>
<function mainExpr="^(\w.*?$)">
<functionName>
<nameExpr expr="^(\w.*?$)"/>
</functionName>
</function>
</classRange>
Below is an example robot file
*** Variables ***
${variable} variable value
*** Settings ***
Documentation multi
... line
... documentation.
Metadata Version 0.1
Library LibraryName some variable
Library String
*** Test Cases ***
Test Case RF 01
Run Keyword ${TEST_NAME}
Test Case RF 02
Run Keyword ${TEST_NAME}
*** Keywords ***
Test Case RF ${tc}
Sleep 30ms
Test Keyword
Sleep 300ms
I'm sure that if I can make it work for one of the sections, for example test cases, then that will allow me to also apply it to the other sections. Predominantly I'm interested in the test cases and keywords.
With the settings below I am able to use Notepad++ Function List for Robot Framework keywords and test cases:
<association id="robot_syntax" userDefinedLangName="Robotframework" />
<association id="robot_syntax" ext=".robot" />
<parser
displayName="Robot Framework"
id ="robot_syntax"
commentExpr="(^(\h*)|(#.*?)|(\[\w.*?)|(Documentation*\w.*?)|(Library*\w.*?)|(Metadata*\w.*?)|(Resource*\w.*?)|(Test (Setup|Teardown|Template|Timeout)*\w.*?)||(Suite (Setup|Teardown)*\w.*?)|((Force|Default) Tags*\w.*?))$"
>
<function mainExpr="(?m-s:(?:^)[A-Za-z0-9].*$)"/>
</parser>

xbuild with [System.Text.RegularExpressions.Regex]::Match(string,string) parameters doesn't work properly (MSBuild is fine)

I have a target that reads a .proj file with ReadLinesFromFile and then try to match a version number (e.g. 1.0.23) from the contained lines like:
<Target Name="GetRevision">
<ReadLinesFromFile File="$(MyDir)GetStuff.Data.proj">
<Output TaskParameter="Lines" ItemName="GetStuffLines" />
</ReadLinesFromFile>
<PropertyGroup>
<In>#(GetStuffLines)</In>
<Out>$([System.Text.RegularExpressions.Regex]::Match($(In), "(\d+)\.(\d+)\.(\d+)"))</Out>
</PropertyGroup>
<Message Text="Revision number [$(Out)]" />
<CreateProperty Value="$(Out)">
<Output TaskParameter="Value" PropertyName="RevisionNumber" />
</CreateProperty>
</Target>
The result is always empty.. Even if I try to do a simple Match($(In), "somestring") its not working correctly in linux/xbuild. This does work on windows/msbuild
Any tricks/ideas? An alternative would be to get the property version out of the first .proj file, instead of reading all lines and matching the number with a regex, but I don't even know if that is possible.
I am running versions:
XBuild Engine Version 12.0
Mono, Version 4.2.1.0
EDIT:
I've been able to trace it further down into the parameters that go into Match(), there is something wrong with the variables evaluation. The function actually works with for example Match("foobar","bar") I will get bar
But weird things happen with other inputs, e.g. Match($(In), "Get") will match Get because it is actually matching against the string "#(GetStuffLines)"
When I do Match($(In), "#..") I will get a match of #(G
But then, when I do Match($(In), "#.*") I actually get the entire content of the input file GetStuff.Data.proj which indicates that the variable was correctly expanded somewhere and the matching matched the entire input string.
I needed to circumvent Match() because it seems to be bugged at this point.
The ugly solution I came up with was to use Exec and grep the pattern like:
<Exec Command="grep -o -P '[0-9]+[.][0-9]+[.][0-9]+' $(MyDir)GetStuff.Data.proj > extractedRevisionNumber.tmp" Condition="$(OSTYPE.Contains('linux'))"/>
<ReadLinesFromFile File="$(ComponentRootDir)extractedRevisionNumber.tmp" Condition="$(OSTYPE.Contains('linux'))">
<Output TaskParameter="Lines" ItemName="GetExtractedRevisionNumber" />
</ReadLinesFromFile>
I couldn't even use the properties ConsoleToMSBuild and ConsoleOutput (https://msdn.microsoft.com/en-us/library/ms124731%28v=VS.110%29.aspx) because xbuild didn't recognize those.. That's why I grep the pattern and save it into a temp file which can be read with ReadLinesFromFile into the ItemName="GetExtractedRevisionNumber" that I use later.

Symfony2 unit tests produces Fatal Error: Declaration of ContainerAwareEventManager::removeEventListener() must be compatible with

When calling phpunit on a very simple standard test, it produces the following output and error:
Command (in symfony2 root):
phpunit -c build/ src
Output:
PHPUnit 4.1.6-6-g43914fa by Sebastian Bergmann.
Configuration read from /srv/xxxxxxxxx/build/phpunit.xml
PHP Fatal error: Declaration of Symfony\Bridge\Doctrine\ContainerAwareEventManager::removeEventListener() must be compatible with Doctrine\Common\EventManager::removeEventListener($events, $listener = NULL) in /srv/xxxxxxxxx/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php on line 141
PHP Stack trace:
PHP 1. {main}() /usr/local/composer/vendor/phpunit/phpunit/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/composer/vendor/phpunit/phpunit/phpunit:57
PHP 3. PHPUnit_TextUI_Command->run() /usr/local/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:132
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/local/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:179
PHP 5. PHPUnit_Framework_TestSuite->run() /usr/local/composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:426
PHP 6. PHPUnit_Framework_TestSuite->run() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestSuite.php:699
PHP 7. PHPUnit_Framework_TestCase->run() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestSuite.php:699
PHP 8. PHPUnit_Framework_TestResult->run() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestCase.php:760
PHP 9. PHPUnit_Framework_TestCase->runBare() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestResult.php:686
PHP 10. PHPUnit_Framework_TestCase->runTest() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestCase.php:826
PHP 11. ReflectionMethod->invokeArgs() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestCase.php:962
PHP 12. Syw\Admin\CoreBundle\Tests\Controller\DebugControllerTest->testIndex() /usr/local/composer/vendor/phpunit/phpunit/src/Framework/TestCase.php:962
PHP 13. Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient() /srv/xxxxxxxxx/src/Syw/Admin/CoreBundle/Tests/Controller/DebugControllerTest.php:13
PHP 14. Symfony\Component\HttpKernel\Kernel->boot() /srv/xxxxxxxxx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:47
PHP 15. Symfony\Component\HttpKernel\Kernel->initializeContainer() /srv/xxxxxxxxx/app/bootstrap.php.cache:2300
PHP 16. Symfony\Component\DependencyInjection\ContainerBuilder->compile() /srv/xxxxxxxxx/app/bootstrap.php.cache:2521
PHP 17. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() /srv/xxxxxxxxx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:619
PHP 18. JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->process() /srv/xxxxxxxxx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:117
PHP 19. JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->processInlineDefinitions() /srv/xxxxxxxxx/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:66
PHP 20. JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->processDefinition() /srv/xxxxxxxxx/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:85
PHP 21. class_exists() /srv/xxxxxxxxx/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:110
PHP 22. spl_autoload_call() /srv/xxxxxxxxx/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:110
PHP 23. Composer\Autoload\ClassLoader->loadClass() /srv/xxxxxxxxx/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:0
PHP 24. Composer\Autoload\includeFile() /usr/local/composer/vendor/composer/ClassLoader.php:301
This is the phpunit.xml in [symfony-root]/build:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "../app/bootstrap.php.cache" >
<php>
<server name="KERNEL_DIR" value="app/" />
</php>
<testsuites>
<testsuite name="Onlinexxxxxxxxx Test Suite">
<directory>src/*/*Bundle/Tests</directory>
<directory>src/*/*/*Bundle/Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
<exclude>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Tests</directory>
<directory>src/*/*/*Bundle/Resources</directory>
<directory>src/*/*/*Bundle/Tests</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Tests</directory>
</exclude>
</whitelist>
<blacklist>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Tests</directory>
<directory>src/*/*/*Bundle/Resources</directory>
<directory>src/*/*/*Bundle/Tests</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Tests</directory>
</blacklist>
</filter>
<logging>
<log type="coverage-html" target="../build/coverage" title="GMS" charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="../build/logs/clover.xml"/>
<log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
And this is the very simple Test class:
<?php
namespace Syw\Admin\CoreBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DebugControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/debug');
}
public function testDetail()
{
$client = static::createClient();
$crawler = $client->request('GET', '/detail');
}
}
Any help with this would be highly aprecciated.
By the way, the
Symfony\Bridge\Doctrine\ContainerAwareEventManager::removeEventListener()
and the
Doctrine\Common\EventManager::removeEventListener($events, $listener = NULL)
are of course still the original ones from the bundles/Symfony2.
Generally nothing in symfony2 or the corebundles were changed, just only our own bundle.
By the way (#2): We are using Symfony 2.4 (but I've just also tried to upgrade to Symfony 2.6 which didn't solve this problem)
Edit:
Like mentioned in the comments below, I've also tried the following things:
Upgrade Symfony from 2.4 to 2.6 -> no success, same error
Downgrade some doctrine bundles -> no success, same error
The composer.json actually looks this way (for the requirements):
"require": {
"ali/datatable": "dev-master",
"doctrine/data-fixtures": "dev-master",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/doctrine-migrations-bundle": "2.1.*#dev",
"doctrine/migrations": "1.0.*#dev",
"doctrine/orm": "~2.2,>=2.2.3",
"dropbox/dropbox-sdk": "1.1.*",
"friendsofsymfony/rest-bundle": "#dev",
"gedmo/doctrine-extensions": "dev-master",
"google-api-php-client": "0.6.7",
"hybridauth/hybridauth": "3.0.0.*#dev",
"incenteev/composer-parameter-handler": "~2.0",
"jms/i18n-routing-bundle": "dev-master",
"jms/security-extra-bundle": "dev-master",
"jms/serializer-bundle": "#dev",
"knplabs/knp-paginator-bundle": "dev-master",
"languagedetect": "1.0",
"languagetool": "2.8",
"lexik/maintenance-bundle": "dev-master",
"misd/guzzle-bundle": "~1.0",
"nelmio/api-doc-bundle": "#dev",
"nelmio/cors-bundle": "~1.0",
"php": ">=5.3.3",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"stfalcon/tinymce-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "~1.1#dev",
"symfony/assetic-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/symfony": "2.4.*",
"twig/extensions": "1.0.*"
},
Okay... after many, many hours of testing and trying with downgrades, upgrades and all these things, I've now found out, that the problem simply is phpunit itself.
I had "PHPUnit 4.1.6-6-g43914fa" installed, as you can see in my output above.
I've now downgraded to 3.7.13 ("phpunit/phpunit": "~3.6") and this is working without any problems.

msbuild c++ : how do I supply desired version info as command line parameter?

I'm building a C++ application on a CruiseControl.Net buildserver.
The build itself is done by msbuild and through cruisecontrol.net I have the desired version available - but I can't get it to be stamped into the c++ output.
Below is my msbuild project file.
Any comments are appreciated,
Anders, Denmark
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="FullBuild" ToolsVersion="3.5">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<UsingTask TaskName="NCover.MSBuildTasks.NCover" AssemblyFile="C:\Program Files\NCover\Build Task Plugins\NCover.MSBuildTasks.dll"/>
<UsingTask TaskName="NCover.MSBuildTasks.NCoverReporting" AssemblyFile="C:\Program Files\NCover\Build Task Plugins\NCover.MSBuildTasks.dll"/>
<ItemGroup>
<MyBinaries Include="Build\*.*"/>
</ItemGroup>
<PropertyGroup>
<CCNetLabel Condition="$(CCNetLabel)==''">2.0.0.0</CCNetLabel>
</PropertyGroup>
<ItemGroup>
<Projects Include="$(vsproject)" />
</ItemGroup>
<Target Name="Rebuild">
<MSBuild Projects="#(Projects)" StopOnFirstFailure="true" ContinueOnError="false" Targets="Rebuild" Properties="version=$(CCNetLabel)" />
</Target>
</Project>
In your buildscript, create a file (version.info) which will look like this:
#define BINVERSION 1,2,3,4
#define STRVERSION "1.2.3.4"
You might need to create a small utility to do that.
In your resourcefile, you will have a versioninfo rescource, the start will look like this:
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
(...)
VALUE "FileVersion", "1.2.3.4"
VALUE "ProductVersion", "1.2.3.4"
Replace that with something like this:
VS_VERSION_INFO VERSIONINFO
FILEVERSION BINVERSION
PRODUCTVERSION BINVERSION
(...)
VALUE "FileVersion", STRVERSION
VALUE "ProductVersion", STRVERSION
Don't forget to add #include "version.info" at the top of the resource file
When you now compile your application, it will have the correct versionnumber. (if you correctly created the version.info).
Also take a look at Automatic Build Versioning in Visual Studio (codeproject)
I ended up just doing a search & replace on the .rc file.
Wimmels suggestion was good, but if I need to write a custom tool I might as well keep the rest simple. I tried out a single freeware search and replace tool, but it messes up the format of the rc file and it's really simple to do the replace yourself. For completeness, I include the code for search-replace below.
Thanks all!
Anders, Denmark
Target in msbuild project file:
<Target Name="UpdateVersion">
<Exec Command="..\CCNetConfig\tools\SearchReplace\SearchReplace.exe project\project.rc $(CCNetLabel)"/>
</Target>
Search & Replace:
class Program
{
static void Main(string[] args)
{
if (args.Length!=2)
{
Console.WriteLine("Must call with two args:");
Console.WriteLine("1 - File");
Console.WriteLine("2 - Version");
Environment.Exit(1);
}
var fileName = args[0];
var version = args[1];
var commaVersion = version.Replace(',', '.');
var allLines = File.ReadAllLines(fileName).ToList();
for (int i = 0; i < allLines.Count(); i++)
{
allLines[i] = allLines[i].Replace("1.0.0.1", version);
allLines[i] = allLines[i].Replace("1,0,0,1", commaVersion);
}
File.WriteAllLines(fileName, allLines);
}
}
From the CruiseControl.Net standpoint everything looks fine. The CCNetLabel property should have the correct value. You could print it out with the Message task just to be sure.
I don't have any experience with C++ projects, but if you're not using Visual Studio 2010, MSBuild is only delegating the build to VCBuild which could be the reason why the version you pass in is not being used (the same should happen if you manually call MSBuild with e.g. /p:version=1.2.3.4).
You might want to take a look at this question. Maybe you could solve your problem as well by overriding the vsprops file.