28 January 2009 - 6:25 PM
I came across a knowledge base article by Microsoft Support that describes how to move files between projects in TFS in a way that keeps their history. In short, to keep your history you need to perform the move in the Source Control Explorer and then fix up your project files. Performing the move in the Solution Explorer causes the project files to be updated immediately, but the history will not be kept because it results in a delete and add operation.
Strangely, the article recommends that you perform the move and check in your changes before fixing up the affected projects. That would put your version control database into an invalid state, and anyone who performed a Get Latest Version would find themselves with a solution that does not compile.
You can easily perform all the actions required to complete the move in one Change Set. These are the steps I find work well for me:
- In the Solution Explorer, right-click the files (or folders) you want to move and select Exclude From Project. This will check out the project file and remove any references to the items you are about to move.
- Use the Source Control Explorer to move the items to the new location. The moved items will be checked out and have a pending rename operation.
- Back in the Solution Explorer, go the the project you moved the items into and click the Show All Files button.
- You will now see the items you moved marked with a plain white document icon. Right-click the items and select Include In Project. This will check out the project file and add a reference to the items you moved.
- In your Pending Changes window you will see the two project files have edit operations pending, and the moved items have a rename operation pending.
- Make sure the solution builds, your unit tests pass and that the changes look correct in your favourite diff tool.
- Check in your Pending Changes. These changes will all go into one Change Set and your version control database will never be in an invalid state. You will of course also have kept your history.
This simple process allows you to keep your source control operations atomic while ensuring you keep your valuable history.
15 January 2009 - 7:04 PM
You may have noticed that after renaming a computer running SQL Server that the value returned for
@@SERVERNAME has not been updated. It returns the computer name as it was during installation of SQL Server. The
SERVERPROPERTY function does take into consideration changes made to the computer name when the
ServerName property is requested.
To fix the server name you need to run the
sp_addserver stored procedures. Instead of typing in the computer and instance names you can use the current
@@SERVERNAME value for the old name, and
SERVERPROPERTY('ServerName') for the new. The TSQL below fixes the name of your local SQL Server and works for default and named instances. You will need to restart the service for the change to take affect.
EXEC sp_dropserver @@SERVERNAME
DECLARE @server nvarchar(128)
SELECT @server = CAST(SERVERPROPERTY('ServerName') AS nvarchar(128))
EXEC sp_addserver @server, 'local'
Here are some links if your keen further information.
The last link refers to a KB article for SQL Server 2000 but still contains relevant information.
14 January 2009 - 2:21 PM
I made a simple Windows Live Writer plugin that allows you to easily surround text with the
<code> HTML phrase tag. Writing a plugin for WLW is fairly straightforward and everything you need to know can be found in the Windows Live Writer SDK documentation on MSDN. The default browser rendering of text inside a
<code> tag is to display it using a fixed-width font. You can of course alter its appearance using CSS to make it a little more interesting.
If no text is selected in the editor and the plugin is activated, a small dialog is presented into which you can enter the text that is to be placed inside the tag. You can also select text in the editor and have it immediately placed inside the tag when the plugin is activated. Trailing whitespace in the selected text will not be included inside the tag. Any trailing whitespace inside the tag would also be fixed-width, causing the spacing before and after the text inside the tag to appear uneven.
To install the plugin simply drop the AlexMG.CodeTagPlugin.dll file into the C:\Program Files\Windows Live\Writer\Plugins folder. When building from source code the plugin will be copied to the WLW plugin folder during the post-build event.
<code> Tag Plugin (3.67 kb)
<code> Tag Plugin - Source (5.45 kb)