Download Lumia 925 Emulator Skin

Have you seen this feature demo video of Avirall? (jump to 00:50)

Do you like the emulator? This is Visual Studio Windows Phone Nokia Lumia 925 emulator skin, i created :D.

Nokia925_UP

You can also create your own app demo video with this skin! Download this skin from here.

Instructions about how to apply skin to your emulator are here.

Happy skinning, oops!

Visual Studio: Auto-increment Build Number – Part 1/3

Sharp Snippets

There have been two continuous coding focused posts related to DateTime (here and here). I am changing gear in this post to project configuration in Visual Studio.

What

 

Some points to note before we start. I will keep this example to VS2010  (but i don’t see any reason why this trick can’t be applied to VS2012 or 2013) . This setup does not involve any add-ins or installations. I will provide complete code which requires to just make a little change in target project setup and the setup will be ready to go. This setup should work whether or not you have any sourcecontrol – GIT, VSS, TFS – connected to your project.

If you are my type you would wish to tag your builds and deliverable incrementally. For large teams and pro grade development environment there are advanced solutions available to automate the process. But what…

View original post 228 more words

Visual Studio: Auto-increment Build Number – Part 3/3

Follow this link for Part 1
Follow this link for part 2

Code Download

Download the zip file with example project and scripts here.

Unzip the package in a temporary folder and read and follow Readme.txt.

First Run

Read the Readme.txt file unzipped from the package downloaded above, and follow all the instruction carefully. Open Visual Studio project properties’ Build Event tab and update the path to PostBuild.Bat, as shown highlighted in the image below. Be cautious to have drive letter included and the full path is enclosed in quotes. Only update path inside the quotes.
VSProperty

Once you F6-build the test project, and if your project builds smoothly you will see Output (show output in Visual Studio from View menu) of the build has messages from auto-increment script. Messages will look something like this:


------ Build started: Project: AutoIncrementBuild, Configuration: Debug x86 ------
AutoIncrementBuild -> J:\Demo\Example\AutoIncrementBuild\bin\Debug\AutoIncrementBuild.exe
------------------------------ Post-build event started -------------------
Configuration:
--------------
MyParam
ManageBLD
"J:\Demo\Example\AutoIncrementBuild\"
-------------------------------------
Updating Build information...
Managing build...
--------------
Configuration:
--------------
"J:\Demo\Example\AutoIncrementBuild\\"
"J:\Demo\Example\AutoIncrementBuild\bin\Debug\AutoIncrementBuild.exe"
Debug
J:\Demo\DevTools\AutoBuild\UpdateBuildLog.ps1
-------------------------------------
Updating build log...
Log File Location: J:\Demo\Example\AutoIncrementBuild\BuildLog.txt
Dll File: J:\Demo\Example\AutoIncrementBuild\bin\Debug\AutoIncrementBuild.exe
Current Output Dll File Version: 1.7.3669.0
Build log entry for this build - 1.7.3669.0 - 16-10-2013 01:15:11 Debug XXX
Write version 1.7.3670.0 in VersionInfo file.
Written version 1.7.3670.0 in VersionInfo file
Confirmed version 1.7.3670.0 is written in VersionInfo file!
Build log updated successfully.
Build log updated
-----------------
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

Messages above are self explanatory and does the commentary of all major tasks performed by the script. If there is any issue with the script, the error will be listed in output window.

On successful build of the project, BuildLog.txt file in your project directory should have a new entry with an incremented build number.

Customization

Let’s have a look at the Post-build event command line:
“J:\Demo\DevTools\AutoBuild\”PostBuild.bat MyParam ManageBLD “$(ProjectDir)” “$(TargetPath)” $(ConfigurationName)
Following are the details about each parameter and what you can do about them:

  • MyParam – In example, this is placeholder parameter. It does not affect auto-increment process, but you can pass some value for this parameter and in PostBuild.bat file, you can have some procedure called on the basis of value in this field. You can leave it as it is
  • ManageBLD – There are two recognizable values for this parameter: ManageBLD and NO_ManageBLD. If this parameter has any value other than ManageBld, Auto-increment will not kick in. You can pass NO_ManageBLD, if you want to skip auto-increment process.
  • $(ProjectDir) – Do not make any changes to this param
  • $(TargetPath) – Do not make any changes to this param
  • $(ConfigurationName) – Sends current configuration value; Debug or Release

You manage Major, Minor, and Revision fields of your project from project properties, Assembly Info section. Auto-increment procedure does not change Major, Minor, or Revision section of the version. It only updates Build part of project version. If you want to reset/renew build number, simply update the build field in File Version section of Assembly Information of project properties. The next auto-increment will take this new number as the base for next increment.

I hope you find this utility useful and productive.

Feedback + Follow = Fuel.

Happy F6-ing.

Visual Studio: Auto-increment Build Number – Part 2/3

Visual Studio: Auto-increment Build Number – Part 2/3

Part 1

Concept || Real

I am using the setup, we are discussing here, for last 8000+ builds I compiled on my dev box with Visual Studio. I can tell you that this is a robust code and pretty smoothly working setup.

What & How?

We will leverage powerful post-build event + PowerShell script (full script is discussed below) to have Visual Studio build process do what we want. We will do following:

  • Write aPowerShell script which does following tasks:
      Pick just-compiled dll from calling project’s folder
      Read File Version field
      Increment Build number field in the version by 1
      Write the new Version number with incremented Build number to AssemblyInfo.cs of the calling project
  • Write a wrapper batch file to call aforesaid PowerShell script
  • Configure project to call the batch file with appropriate params
  • Let Visual Studio know when to run the post-build event

After every build we will have our read-only BuildLog.txt file in project folder updated, like so:

BuildLog

Note: The highlighted header is manually inserted, script does not write the header automatically. If you want header in your BuildLog.txt, edit it manually once and insert header at the top.

So, the conceptual diagram of setup looks like this:

Setup

The Script

I wrote this PowerShell script using NotePad++. You will find script very similar to c# because PowerShell utilizes a lot of .NET.  If you wish to edit the script to extend its functionality, you can use any editor of your choice, e.g. PowerShell GUI Editor, which provides excellent debug support.
We will call our PowerShell script file UpdateBuildLog.ps1. Here is the outer structure of our script:

ScriptStructure

  1. File Header
  2. We will wrap our script in try catch block so as to ensure we know the reason of the script failure in our build output windows. We will see how.
  3. Parameter:projectPath – Path of the project, defaulted to c:\temp\
  4. Parameter:targetDLLFullPath – Where project’s dll is located, defaulted to c:\temp\
  5. Parameter:extraAttribute – Any extra text attribute for build log entry, defaulted to XXX
  6. Parameter:buildConfig – Build configuration, Debug|Release, defaulted to Debug

Let’s have a look at the internals of the script:

ScriptWorking

  1. Prepare AssemblyInfo.cs path from supplied project location. Write the prepared information to Project’s build output window.
  2. Read just created dll file from the supplied path and file name, and extract version and build number. Write version and build number to build output window. Increment build number by 1 in the extracted version number.
  3. Prepare Build log entry, write the entry into build log text file, make the build log text file readonly again.
  4. Update the AssemblyInfo file with the new version number.
  5. Confirm proper version number is written to AssemblyInfo file and write to build output window.
  6. If there is any issue while updating new version number, write to build output window.

The Batch

We will call our batch file PostBuild.bat.  We will setup our project’s post build event in Visual Studio to call PostBuild.bat with appropriate parameters. Following are important parts of the batch file:

BatchFile

  1. File Header
  2. Prepare parameters received from Visual Studio build events
  3. Call procedures on the basis of supplied switches
  4. Customize the batch file and write your code (by default, this section does nothing)
  5. Customize the batch file and write your code (by default, this section does nothing)
  6. Procedure to call PowerShell script to update build log with incremental build number.

We now have a decent idea of the nuts and bolts, and we  are clear about the structure of the setup, script and the batch file.

Code download and customization in – Part 3

Hope you are still with me.

Visual Studio: Auto-increment Build Number – Part 1/3

Visual Studio: Auto-increment Build Number – Part 1/3

There have been two continuous coding focused posts related to DateTime (here and here). I am changing gear in this post to project configuration in Visual Studio.

What

 

Some points to note before we start. I will keep this example to VS2010  (but i don’t see any reason why this trick can’t be applied to VS2012 or 2013) . This setup does not involve any add-ins or installations. I will provide complete code which requires to just make a little change in target project setup and the setup will be ready to go. This setup should work whether or not you have any sourcecontrol – GIT, VSS, TFS – connected to your project.

If you are my type you would wish to tag your builds and deliverable incrementally. For large teams and pro grade development environment there are advanced solutions available to automate the process. But what about indie developers? I don’t know why “*” in build field in Project setting does not auto-increment it but it did not work for me in VS2010 pro, WP project. Even if it did, it serves no practical purpose for the lack of control. Also, for no-frill setup there are some VS Add-ins available which provide auto-increment build capabilities. I tried them and some totally did not work (VS broke) and others had severe lack of functionality. So let’s see what I want this setup to do.

Increment My Build Number

  • Automatically, transparently increment build number of my project, any project.
  • Let me control, through setting, when to increment build – Debug | Release | (other)
  • Ability to start from a custom number
  • Let me reset the build number

Report me

  • Complete Version Number
  • Date and time of the build
  • Configuration – Release | Debug
  • Special property
  • Life expectancy on Mars. (Really? No, just kidding)

Record It

  • Keep the history of all my builds
  • Easily edit/clear the history
  • Manageable text file

Fill It | Shut It | Forget It

(If you are not from India or below 25, you might not get this title. And it does not make any difference)

  • Easy to setup
  • Easy control
  • Extensible
  • Bare, no frill code

Ok, enough of all this requirement overload. Show me the code.

[contd…Part 2]

Happy increment-ing!

Outline – Focus On Spot, Define Boundaries

it takes all kinds to make this world


Original image credits – left, right

To be, or not to be, that is the question

It is indeed a personal choice (or your company’s directives) to use block outlining, aka regions, in your code. i have had my share of arguments, for and against the topic. If you want to get enlightened(?) on use of block outlining, tap here, here. This post is not about discussing whether or not you should use regions, this is only about why to use them in your code and how.

Why?
It is true that when your code grows bigger you should think about restructuring/refactoring, but a real-world class/method with only a slightly complex functionality has multiple physical/logical code blocks. i find outlining very handy and productive here. It helps me give a bird’s-eye view of my code and i can jump right in where i intend to, quickly and precisely. A visually structured code file makes it easier to focus on the area you are concerned with. Such code is more readable, comprehensive, and easy to update.

How?
When you are using Outlining feature of Visual Studio, it outlines classes, methods, conditions, etc for you. With #region you can make a block of code participate in outlining and you can expand or collapse it as you would other outlined sections of your code. Following is the syntax for outlining a block of your code:

#region [name]
#endregion

i personally prefer the style where #endregion also has the name repeated, like this:

#region [name]
#endregion [//name]

Though optional, but having name to describe the block of code with #region and #endregion makes it easier to resolve issues related to mismatched outlining. To avoid typing #region #endregion syntax repetitively and enforce standards, i suggest to have a code snippet to insert block outlining. This is my version of the code snippet, it prompts for name and automatically fills the name in #region and #endregion lines:

<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
          <Shortcut>RegionWrapper</Shortcut>
            <Title>
                RegionWrapper
            </Title>
        </Header>
        <Snippet>
          <Declarations>
            <Literal>
              <ID>RegionName</ID>
              <Type>string</Type>
              <ToolTip>Type region name</ToolTip>
              <Default>"region name"</Default>
            </Literal>
          </Declarations>
		
          <Code Language="CSharp">
    <![CDATA[        #region $RegionName$
        #endregion //$RegionName$
]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

If you want to first write your code and then select the code block and wrap it within region, you can use macro.

Following two keyboard shortcuts are most important while dealing with outlining:

ctrl+m+m Toggle Outlining Expansion
ctrl+m+l Toggle All Outlining
(For other shortcuts see the menu item Edit > Outlining in VS.)

To give you an idea about how outlining makes code less daunting, see following VS Snips of the same class (a dummy class derived from a real-world class), collapsed and expanded on regions:

VS Snip – Regions Expanded(this snip is also equivalent to having no outlining at all)

The same code in the above Snip, when collpased looks more accesible and cleaner.
VS Snip – Regions Collapsed

Crave for more, go here, here.

Enjoy #region-ing!