Grunt-Deploy-WPXap: Using Grunt to deploy your Windows Phone application

I like Grunt.js, I think it is pretty easy to use and I think creating custom tasks for it are pretty easy. But I am also currently building Windows Phone applications. Seems like these 2 things do not really mix too well, like oil and water. But I like a good challenge, I also like trying out new things.

One thing I wanted to do as I am building out my tasks for Grunt has been to take a xap and launch it to either a emulator or to a physical device. I had thought this would be a royal PITA, but honestly it was pretty easy.

The result of my effort is a grunt plugin called Grunt-Deploy-WPXap, you can get this off of Github or from NPMJS.org. I hope the Readme has enough information, if not let me know and I will make changes to it.

Keep in mind that I have only tested this on my laptop, with MY project. If this package does not meet your needs let me know and I can fix it, or I take pull requests.

Till next time,

Posted in Grunt, Windows Phone | Tagged , | Leave a comment

Sublime is Sublime 11

So we are now into the 11th post. There are only two more to go after this one. One with some more functionality and one as a summary. In the last post we installed OpenIDE and showed the very basics of its functionality, adding a file to an existing project.

OpenIDE can do much more than this. It has most support for sln/prj that you will need. Let’s start by making a new project.

greg@goblin:~/src/foo$ oi create console src/HelloConsole
Created src/HelloConsole
greg@goblin:~/src/foo$ ls
src
greg@goblin:~/src/foo/src$ ls
HelloConsole.csproj  Program.cs  Properties

This will create a proejct from a template. The following are the available templates (listed from help).

	create : Uses the create template to create what ever project related specified by the template
		console : Creates a new C# console application
			ITEM_NAME : The name of the Project/Item to create
		library : Creates a new C# library project
			ITEM_NAME : The name of the Project/Item to create
		service : Creates a new C# windows service
			ITEM_NAME : The name of the Project/Item to create

You could remove Program.cs with oi deletefile foo/Program.cs if you wanted and it would also be removed from the project as well.

You can create your own templates as well they are just scripts. This applies to both new items and project templates. If for example you wanted to make a custom item for a new item (say a custom xunit testfixture).

Go to your OpenIDE release. cd .OpenIDE/languages/C#-files/

You will see here there is create and new. These hold the templates for the create and new commands they are implemented as python but can be scripted in any language

As an example here is the template for a new interface

#!/usr/bin/env python
import sys

if __name__ == "__main__":
	if sys.argv[1] == 'get_file_extension':
		print(".cs")
	elif sys.argv[1] == 'get_position':
		print("6|3")
	elif sys.argv[1] == 'get_definition':
		print("Creates an new C# interface")
	else:
		classname = sys.argv[1]
		namespace = sys.argv[2]
		parameterfile = sys.argv[3]
		print("using System;")
		print("")
		print("namespace " + namespace)
		print("{")
		print("	interface " + classname)
		print("	{")
		print("	}")
		print("}")

and here is the template for a new Console Application.

#!/usr/bin/env python
import sys
from files.copydir import copy as copydir

if __name__ == "__main__":
	if sys.argv[1] == 'get_file':
		print("Program.cs")
	elif sys.argv[1] == 'get_position':
		print("8|3")
	elif sys.argv[1] == 'get_definition':
		print("Creates a new C# console application")
	else:
		copydir("console", sys.argv[1])

There is still much that can be added to OpenIDE (and it does a ton of other things we have not covered). But in general it can get you around the issues of dealing with project and solution files including references.

Posted in Uncategorized | Leave a comment

Fixing a side effect w/ the Expander Control in Windows Phone

I am a huge fan of the Telerik Windows Phone UI controls, I think they are simple to use and they ‘JUST WORK’.

When building a large list of items performance can become an issue. Because of this the RadJumpList will attempt to recycle objects as you are scrolling rather than create new ones. This is great as it reduces the memory footprint and generally means better performance.

However, this recycling is not without some side effects. Once such side effect pops up when you are using the ExpanderControl to allow your users to expand and collapse data.

Here is the side effect.
Lets say you have a list of 1000 items. If you expand the 1st item in the list and then start scrolling at some point you will see another item which is expanded. This is annoying because your users did not expand that item, well directly that is. This item will be expanded because the underlying object was recycled from the original item you expanded.

Solving this side effect is trivial and easy.
The easiest way to solve this is to setup your ExpanderControl as below
Expander

Notice that ExpanderControl has a binding setup for IsExpanded, this is key. This binding should be bound to a property on your VM, making sure the VM property raises property changed.

Once you have this setup your issues should be solved.

Hope this helps.

Till next time,

Posted in C#, Windows Phone | Tagged | Leave a comment

Grunt-Bump-WMAppManifest: Updating Version Information for Windows Phone via Grunt

In a previous post showed how to use Grunt.js to update the version number inside the Windows Phone WPAppManifest.xml file. In that post shows you how to create a custom task in grunt to accomplish this. This works great but I wanted to turn this logic into an NPM package for Grunt.

I have created the following Grunt NPM package (called grunt-bump-wmappmanifest) which will perform this same action but without you having to create a custom task.

You can find this code in my Github Repo
You can find the NPM package on npmjs.org

To use this plugin you only need to do 2 things
1) Install the package ‘npm install grunt-bump-wmappmanifest’
2) Configure your grunt script as seen below (this is the bare usage, check out the github Readme for more details

bump_wmappmanifest: {
    wpapp: {
        options: {
            debug: true,
            usePackageVersion: true,
        },
        src: "../pathToFile/WMAppManifest.xml",
        dest: "../pathToFile/WMAppManifest.xml"
    }
},

Hope this helps and makes life a bit simpler.

Till next time,

Posted in Grunt | Tagged , , | Leave a comment

Sublime is Sublime 10

Ok we have been moving right along through the sublime features and getting setup for .net development. I have been half saving the next few posts deliberately until the end as they will be covering the largest arguments I hear against the use of other editors than VS when dealing with .NET code.

But my team uses Visual Studio, I can’t just give up on using project/solution files and use some hipster editor.

This has for a long time been the single largest hurdle in using non-VS editors. If you want to get an idea of how bad it is and you have been following along the posts, try adding a file to a project or reference another project in Sublime. Ouch manually editing project files. How do you know that your manual edit will work when opened in Visual Studio?

To be fair even if it took you 15 seconds per file/reference that you added in Sublime the overall time on the project would be minimal but it is a serious pain in the ass. Nothing makes you feel slower than having to manually edit xml that was automatically done for you previously.

To get some of this functionality we will install a new tool though a whole new tool is not really needed for this. It could be done with some basic shell scripts. The tool is OpenIDE by @ackenpacken. OpenIDE does a whole lot more than what we need it to. I have been chatting with him recently about maybe making it more modular hell even Mighty Moose is contained within it as of now.

OpenIDE supports some of the generic things you would want when working with .NET code. The ability to edit project/solution files. The ability to handle templating for new additions. Reference management. There are also some other tools out there as well such as omnisharp https://github.com/nosami/Omnisharp but I fear all of them are too complex and not modular enough as there hasn’t been much of a push for that kind of tooling. Part of this post series is to help mold demand for these kinds of tools.

Now for OpenIDE install. You can grab the sources for OpenIDE here https://github.com/continuoustests/OpenIDE. Svein has recently added a binary repository here https://github.com/continuoustests/OpenIDE.binaries.git. Pull the binaries repository or build from sources. Put the output into your $PATH. OpenIDE also comes with bash completion if you want to install it which can help greatly! Now you are good to start.

Let’s make sure OpenIDE works: oi

You should get help.

oi package install C-Sharp

In the root of your project type oi init C#

Now oi is setup and ready to go. From the command line let’s try

greg@goblin:~/src/EventStore/src/EventStore$ oi new class esquery/bar
Created class esquery.bar
Full path /home/greg/src/EventStore/src/EventStore/esquery/bar.cs

Note that I did not put bar.cs just esquery/bar and yes you get tab completion on this.

If I now look at what changed.

greg@goblin:~/src/EventStore/src/EventStore$ git status
# On branch dev
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   esquery/esquery.csproj
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	esquery/bar.cs
greg@goblin:~/src/EventStore/src/EventStore$ git diff esquery/esquery.csproj
diff --git a/src/EventStore/esquery/esquery.csproj b/src/EventStore/esquery/esqu
index dec282f..9f3c95f 100644
--- a/src/EventStore/esquery/esquery.csproj
+++ b/src/EventStore/esquery/esquery.csproj
@@ -84,6 +84,7 @@
     <Compile Include="CommandProcessor.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="bar.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />

You can also run this command directly inside of sublime. Just use ctrl+shift+c and type in your command. This is just the beginning though. OpenIDE and such tools can support most of your integration with things like project/solution files.

Posted in Uncategorized | Leave a comment