I am currently reading the Mango (Windows Phone OS 7.1) version of my Phoney Tools project. But I have a particular problem: I need to maintain both a 7.0 and a 7.1 version of the project builds. You might have the same issue with your own project so I thought it’d be a good way to show off some special features that Visual Studio has to help you solve these sorts of situations. Essentially my goal was to maintain one set of code but build both sets from the same source.
First off, I took my original project and created two solution folders and created the 7.1 projects as shown here:
To build the 7.1 versions, I linked the source code between the projects. If you haven’t done this before, this means that the 7.1 projects would use the same physical file as the 7.0 versions but be built against the Windows Phone OS 7.1 project settings. To created a linked file, when you add an existing file, you have to pick “Add as Link” in the Existing File dialog:
Using the small dropdown on the “Add” button, you can add the files to your project as a link to the original file. You can see these links in the Solution Explorer so you know which files are linked:
You can see the icon shows a small overlay of an arrow to indicate the linked files. This way I can have a single set of code that can build both versions. Key here is that the underlying references and project types all point at the two versions of the phone libraries. But what about code differences? That’s where project defines come in. In my 7.1 project settings dialog under the build tab, I added a new define called “MANGO”:
With this new project define (again, only in the 7.1 projects), I can edit the code where necessary using this define:
#if MANGO
[Obsolete("Class is no longer required in Windows Phone 7.1.")]
#endif
public class GameTimer
{
...
With these two tricks, I now have both 7.0 and 7.1 building in the same solution. I hope this helps you trying to do the same thing!
I've had my phone a couple of days now and been playing with the development experience on the device. As some of you remember, I've been creating a new Moon Phase application for the phone (called "Moon Phaser"). I'll be releasing the source and you'll be able to install it on your phone (for free) once the Marketplace launches.
I've recorded a little video showing using Visual Studio 2010 and the actual device to debug directly on the device. Yes it works...and yes its fast. I am really happy with the experience. Debugging with the emulator is fast too, but there are times when you want to make sure it works on the device and that the performance is what you expect on the device. Watch the video here:
Let me know what you think!
(Kudos to Laurent Bugnion for helping me with the phase animation!)
I've been speaking at user groups and conferences for a long time now. Usually at these short talks I don't get asked much about how I use Visual Studio. But now that I am teaching Silverlight, my students are never shy about asking what I am doing while in Visual Studio. I am often amazed by how people use Visual Studio without learning some of my favorite hotkeys/snippets. Here are some of mine:
Keyboard ShortCuts
Ctrl-Shift-B: Build Solution
Ctrl-. (period): Show "Add Using/Imports" dropdown for unknown types.
Ctrl-K, C: Comment Selection
Ctrl-K, U: Uncomment Selection
Ctrl-K, F: Format Section
Ctrl-K, D: Format Document
Ctrl-Space: Show Intellisense List
Ctrl-Shift-V: Paste Loop - Hit Multiple Times to paste through the list of recent 'copies'
Ctrl-F: Simple Find
Ctrl-Shift-F: Find in Files
Ctrl-H: Simple Replace
Ctrl-Shift-H: Replace in Files
Ctrl-N: New->Project Item
Ctrl-Shift-N; New Project
F9: Set Breakpoint
Ctrl-Shift-R: Start/End Temporary Macro Recording
Ctrl-Shift-P: Play Temporary Macro Recording
F12; Navigate to Type (or metadata for Type) under the cursor
Snippets
(To use these snippets, type the phrase and hit Tab twice)
prop: Create a simple property in a class
propg: Create a simple property with a public get and a private set
I am here at DevTeach and having a great time. I got in a discussion with several of the speakers about the common complaint of some Silverlight/WPF folks that they want Blend to be in Visual Studio; or why Cider has always been disabled by most dev's.
I hear the complaint a lot that developers want the functionality of Blend hosted in Visual Studio. While I understand the desire, I've never been bothered by the dual programs. In fact, I think its better. Blend needs to be separate because its primarily for a Designer/UX role that isn't comfortable with the breadth of Visual Studio.
We have plenty of other solutions that have two overlapping tools: I can insert an Excel spreadsheet in Word but when I need to do an if/then analysis I use excel. A single Office App would be silly. Finally (I think the most compelling example) is SQL Server. When I am in Visual Studio, I can open a database connection and run queries, create stored proces and more. But if I want to manage users, create backup plans or other DBA-like tasks, I go to SQL Server Management Studio. I can do many of the same tasks in both, but developers never ask for Microsoft to remove SQL Server Management Studio and fold it all into Visual Studio. Different roles mean different tools (roles != people btw).
I've made a small change in Amy's batch file to uninstall and install the right runtime, but there is a hitch. You need to download the runtimes yourself (as they are downloaded during installation and since Amy's batch is opening up the Setup package, they aren't there).
To use the batch file you'll need to download the file (here) and unzip it into an empty directory. Into that directory copy the following files:
If you haven't done so already, run the Silverlight 2 Tools Package and the Silverlight 3 Tools Package. Finally you can run the Setup_SLTools_Util.bat file that is in the zip file. This will create new batch files for moving two and from SL2/SL3 for Visual Studio and Visual Web Developer Express. Please see Amy Dullard's post about it for more information about how the batch files are used:
I am working on a hybrid ASP.NET MVC and MVC Dynamic Data project. To work on it I started with the MVC Dynamic Data project assuming this would be a Dynamic Data Project and an MVC project. As Scott Hanselman recently posted, you can mix and match pretty easily so the code was working but I was missing an important piece of functionality in Visual Studio:
My project wasn't being showing these items (or other menu options specific to MVC apps). I suspected it was some magic in the project file so I opened it up in my favorite editor:
The missing bit was a special ProjectTypeGuid: {603c0e0b-db56-11dc-be95-000d561079b0}. You need to add this to the existing ASP.NET project's ProjectTypeGuid list in the project file and magically the project item types appear.
After 382 Visual Studio Tips and a book, Sara is retiring the series. Those tips have been hitting my RSS Feed for a long time now. They've been helpful to me and my students. I really appreciate all her hard work helping us in the community.
I am surprised when I talk to developers these days and they don't know who Sara Ford is. She's responsible for CodePlex and many open source initiatives at Microsoft. In addition, her blog is an excellent source of information on Visual Studio tricks and features that most of us have never noticed. It is well worth a read. Just announced today, her blog is now available in Russian and Spanish so if English isn't your native tongue, you're in luck there too.
Wonder how I get someone to translate my blog into other languages ;)
Something I never noticed before is the Document Outline window in Visual Studio (2008?). When editing large XAML files this is particularly useful to help navigate the tree of elements.
If you've never noticed it like me, you can make it show up by using the menu's when a XAML file is open: View->Other Windows->Document Outline. Alternatively, the default key command is Ctrl-Alt-T.
This is *not* a Silverlight specific feature. It works with WPF as well (but not ASP.NET pages). Nice....
I've been using a LINQ for SQL model for a project for a few months now. The project has been compiling fine forever now. Suddenly it was failing to build the .dbml file for no apparent reason. A quick search for the problem turned up an issue with Regionate and LINQ for SQL. Uninstalled Regionate and its back to compiling.
I like the tool but until they fix the issue, i'll have to live without it for a while.