RSS

GIT: allow push to master only if build succeeds

It may be a requirement of companies, that the master and develop branch contains only code that is always compilable. Therefore we need to ensure that every push, or merge on a master branch results not in breaking the build of the application. This can be achieved with git-hook file that has the Name pre-commit and is copied into .git\hooks directory.

#!/bin/sh
branch=$(git rev-parse --abbrev-ref HEAD)

if [ "master" != "$branch" ] && [ "develop" != "$branch" ]; then
    exit 0;
fi

echo "To commit on a master or develop branch we need to check whether msbuild compiles successful."

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" /consoleloggerparameters:"ErrorsOnly;PerformanceSummary"
status=$?

if [ "$status" != "0" ]; then
    echo "Build failed. If you publish to the $branch branch you should ensure that the solution builds correctly"
fi
exit $status
 
Leave a comment

Posted by on December 18, 2014 in C-Sharp, Git

 

Tags:

GIT: push every commit immediately to origin

If I am working not on my primary PC I sometimes forget to push commits to the origin remote. Therefore next day I am in company I miss commits that are local on the other PC. To avoid that problem I wrote a git-hook that pushes every commit instantly to the origin-remote.

For this you need to create the file post-commit with following content

#!/bin/sh
#With this git-hook every commit is immeditely pushed to origin

branch=$(git rev-parse --abbrev-ref HEAD)
echo Pushing commit to origin/$branch
git push -u origin $branch

Save the file to the .git\hooks directory. Now after each git commit the commit is pushed to the remote.

 
Leave a comment

Posted by on December 17, 2014 in Git

 

Tags:

Found conflicts between different versions of the same dependent assembly

warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

First of all Change build log verbosity to detailed. This is done by changing the value for Tools>Options>Project and Solutions>Build and Run>MSBuild project outbut verbosity to detailed.

After that you can rebuild the solution. During build time MSBuild writes a lot of information to the Output-View. After build completition you have to search the whole log file for the corresponding assembly conflict. You can do this by using CTRL+F to open the search-view, entering “conflict” and hitting the search button. Visual Studio highlights all corresponding matches. Search for a message that states a sentence like the following:

There was a conflict between “System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ and “System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″.
“System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ was chosen because it was primary and “System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ was not.

Just remove the reference to the wrong assembly from the current built project System.Windows.Interactivity, Version=4.0.0.0 and add the reference to the correct assembly System.Windows.Interactivity, Version=4.5.0.0 and the warning is gone when you build the Project the next time.

After that you are free to change the build verbosity back to the previous value.

 
Leave a comment

Posted by on November 10, 2014 in C-Sharp

 

Tags: ,

Thank you all for the 100.000th view.

 
Leave a comment

Posted by on November 4, 2014 in Uncategorized

 

WMI Filter for laptops

For filtering laptops in a WMI query there are several different approaches to find out if a system is a laptop or not. A suggested way found on the internet is following WMI query

SELECT * FROM Win32_Battery WHERE (BatteryStatus <> 0)

This works, but if you remove the battery from your laptop and keep the lLaptop on the power chord only this will not work. Then the laptop seems to be a desktop machine. A better approach is to use the following WMI-query:

SELECT * FROM Win32_ComputerSystem WHERE PCSystemType = "2";
 
Leave a comment

Posted by on September 29, 2014 in Windows Server

 

Tags: ,

Inlines and Run in TextBlock does not follow Language override

If you want to localize your application you generally override the LanguageProperty with your desired language:

FrameworkElement.LanguageProperty.OverrideMetadata(
    typeof(FrameworkElement), 
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

As stated in the documentation every control should now use the – in this case – German culture. Well this is not the case. If you have a TextBlock and set the Text property then this works, but if you have a TextBlock with Inline elements, then the en-us culture is used.
This is very stange. Why is that the case? TextBlock inherits from FrameworkElement and because you have overridden the FrameworkElement.LanguageProperty this works. But if you use Inlines, such as Run, Italic, Underline, … those controls inherits from FrameworkContentElement and not from FrameworkElement for which you do not have overridden the corresponding DependencyProperty. This is the only reason why Inlines do not follow the application wide culture. As solution for that you have to override the LanguageProperty for FrameworkContentElements.

FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(FrameworkElement),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")))

This does not work because it says that is is already registered. So a workaround is to override if for every class that is one inheritance hierarchy lower than FrameworkContentElement:

 FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(DefinitionBase),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

            FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(FixedDocument),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

            FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(FixedDocumentSequence),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

            FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(FlowDocument),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

            FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(TableColumn),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

            FrameworkContentElement.LanguageProperty.OverrideMetadata(
    typeof(TextElement),
    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

Now the Inlines in TextBlock follows the culture that you have specified

 
Leave a comment

Posted by on September 25, 2014 in C-Sharp

 

Tags:

Done Building Project “X” (default targets) — FAILED.

If you use Team Foundation Server as build server and have a Database Project that is build on the server there is a chance that the build output succeeds without errors but the build result is “failed”. If you execute msbuild on the build server you can see that the DatabaseProject build succeeds with following output:

Done Building Project “X” (default targets) — FAILED.

Based on the documentation of the TFS-Build-Server any build output containing ERROR, FAILED,… is interpreted as a failed build, even though the msbuild script succeeded.
The problem is that you have not updated the SQL Server Data Tools. If you install the update on your build machine then the MsBuild-Script will succeed

 
Leave a comment

Posted by on September 19, 2014 in Team Foundation Server

 

Tags:

 
Follow

Get every new post delivered to your Inbox.