Showing posts with label Best tools ever. Show all posts
Showing posts with label Best tools ever. Show all posts

Thursday, March 5, 2015

Windows -> Unix convert line endings with Git

Recently we met a problem, that files we fetch from TFVC to Linux build agents fail the build.

Problem was good old line endings - all our files had CRLF, since they were checked in from Windows.
Problem never appeared before, previously people were using Perforce clients, which can fix line ending for the "host" operating system. With Team Explorer everywhere that was not a case anymore.
So long story short, I ended up with need to fix line ending for the set of files, located in the same directory. Massive convertion of file endings... I need a tool... Git! So I created a script which convert line endings for all files in a specific directory (and subdirectories) and checks in to TFVC.

Configure Git line endings to unix style :
git config --global core.autocrlf input

Go into folder which need to be converted:
cd MYFOLDER

Make Folder a git repo, checkin all files:
git init
git add *
git commit -m "make it a unix, baby..."

At this moment in repository files are with Unix line endings, but locally on disk - still unchanged. Let's fix that.

Delete all files and then undo change so it will fetch back from repository:
git rm *
git reset
git checkout *

Now all files have correct line endings, we need to checkin to TFVC. So, delete .git in  your folder:
rd .git /S /Q

Go up one level and checkout your folder and all under:
cd ..
tf checkout MYFOLDER /recursive

Checkin to TFS forcibely (it does not see the difference if only line endings changed, so we need to force):
tf checkin MYFOLDER /recursive /force /noprompt


Voila :)

What is extra nice,  Visual Studio is clever enougth to deal with Linux style line endings. So I still can build my solution with devenv.exe. 
And even msbuild had nothing against unix style line endings.

PS: some more reading on subject

PPS: Of course, if you want to checkin changes or new files to TFVC, you need to watch line endings. It is possibel to configure your TFVC client to be aware. See more information here:
or here:


Saturday, March 2, 2013

Best tools ever: LINQPad

I thought to make serie of posts about tools I use daily, and can't imagine life without.
And I start with my very favourite - LINQPad.

So often there is a code snippet we just want to try, and starting all the hussle with opening Visual Studio, creating project, etc etc... uff, it is just too much. Life should be easy - write & run!

And that is exactly what LINQPad allowes me to do.

So start LINQPad - and you get a window to write your code:

 
Select a C# statement, and - write your code. In this particular example I query for build definitions, and if I press Run, it will show me the result in nice format:


Of course, there are dlls I need to reference. To add references required by your code - right click on the code field and choose Query Properties.


And look - there is even NuGet there.

 Best news ever - you can get it for free. If you would like to have code autocompletion - it will cost you some, otherwise - totally free of charge.

I have to add that LINQPad can do much more than what I mostly use it for, so - try it and I am 100% sure you will love it.

Official site, download and examples here: http://www.linqpad.net/