Monday, July 21, 2014

TFS Best Practice Analyzer fails with “Cannot validate the URL provided”

The Team Foundation Server Power Tools contain a great tool called the Best Practice Analyzer. This tool helps you in automatically checking your Team Foundation Server installation and advising you on any problems that it may find.

So every time I install a new TFS environment, I use the BPA tool to validate any prerequisites and make sure the TFS environment is functioning correctly.

Running into some problems

After running BPA on a Windows Azure VM running Windows Server 2012 R2, the scan finished very quickly and showed the following:

BPA TFSServerURLValidated

To view more details, you can click on View a report of the Best Practices scan. This will generate a report that clearly shows something is wrong:

BPA Cannot validate the URL provided

To view a detailed log of what’s going wrong you can click on Other Reports. This will show you a Run-Time log that contains detailed information on the error BPA is encountering:

BPA Error Log

As you can see in the log file, there is an error stating that you are running the incorrect version of PowerShell. It’s looking for version 2.0, but Windows Server is running version 4.0.

Fixing the TFSServerURLValidated error

So how you can make sure that the BPA runs on a machine with a newer version of PowerShell?

You can add a configuration file that makes sure the supported runtime is set to .NET 4.0. Switching to .NET 4.0 also switches PowerShell to version 3 or later. Since BPA is a .NET application, adding a configuration file is easy. Just create a file <NameOfExe>.exe.config. When running the application, .NET will automatically load the config file with a corresponding name and apply any configuration settings in it to your application.

By default, BPA is installed in C:\Program Files(x86)\Microsoft Team Foundation Server 2013 Power Tools\Best Practices Analyzer. In here, you’ll find TfsBpa.exe which is the executable file that runs the BPA.

Now you need to create a corresponding config file called TfsBpa.exe.config. If User Account Control kicks in and doesn’t allow you to create a file, the easiest solution is to run Notepad as an administrator and save the file directly to the correct location.

Inside your new configuration file you put the following:

<configuration>
     <startup>
          <supportedRuntime version=”v4.0.30319″/>
      </startup>
</configuration>

And that’s it. Now BPA will run great operating systems like Windows 8 and Windows Server 2012.

Feedback? Questions? Please leave a comment!

Wednesday, July 16, 2014

TF30063 error while updating NuGet packages

A customer started using the Ordina Team Foundation Server to host their project. Everything seemed to work fine. They can connect, check-in code and get the latest changes.
However, they could not update NuGet packages! When running the command

Update-Package

from the NuGet console, an error popped up:

TF30063: You are not authorized to access collection

The Package Manager Console shows the same error, mentioning something about access denied errors.

Fixing TF30063: You are not authorized to access collection


The problem has to do with security restrictions at my customer. They have strict policies for which websites can be accessed. The solution for this NuGet error is simple:

Add the URL of your TFS server to the trusted sites list in Internet Explorer and drop the security for the trusted sites zone to low.

Add TFS server to trusted sites

And that’s it. Visual Studio will now connect to NuGet and update your packages without any issues.

Monday, July 14, 2014

Licensing and TFS

Are there things in life you just can’t remember? Maybe the name of a colleague, your wedding anniversary or how TFS licensing works?

Well, as you’ve probably guessed I’m having some problems with remembering TFS licensing. And one great way to make sure I don’t forget something or that I can find it easily when I do forget, is blogging about it.

So what’s the problem?

At Ordina we are running a large Team Foundation Server environment which is used for our own projects but also for external customers. We strive to implement the complete ALM toolset for our projects and make sure they get trained in all the latest best practices. So, how about licensing?

Our internal developers have MSDN subscriptions that give them access to TFS. This is because Visual Studio includes a Client Access License for TFS so having Visual Studio automatically grants you access to TFS.

However, that’s not true when it comes to external people. If customers have MSDN subscriptions, they off course have a Visual Studio license. But notice the following paragraph from the Visual Studio and MSDN Licensing White Paper (page 20):

Additionally, if the contractor is using the client’s Team Foundation Server then the client must supply a Team Foundation Server CAL for the contractor’s use. This could be a CAL purchased separately or a CAL that is included with the MSDN subscription that the client assigns to the contractor temporarily. Team Foundation Server CALs are only valid for accessing a Team Foundation Server acquired by the same organization.

So what does this mean? It means that the MSDN subscriptions our customers have do give them access to Visual Studio but don’t give them a CAL for accessing a TFS environment hosted by Ordina. Instead, Ordina is required to purchase separate CALs for all external customers.

As you can see, licensing is still some form of a black art. Fortunately, you can (and should!) contact partners like Ordina with all licensing questions you have and we will help you out.

Comments? Feedback? Licensing questions? Please leave a comment, contact me on Twitter (@wouterdekort) or send me an email at wouter.dekort@seizeit.nl.

And my new book is finished!

The last couple of months I’ve been very busy writing my new book:

Essentials of Developing Windows Store Apps Using HTML5 and JavaScript

After writing, editing, reviewing and repeating this a couple of times, my new book is now officially finished! You can preorder it and it will start shipping on 8/1/2014.

The last year, I’ve worked on three books that help students get their Microsoft certification. Writing a book is a daunting tasks but the moment your book is finished and you hold the first print in your hand is still very cool.

Getting started with Windows Store development

If you want to get into Windows Store development, getting certified is a good first step. Why? For me, studying for an exam helps me to get a broad overview of what’s possible and deepen my knowledge on the essential areas. This is also true for the Windows Store exam. You will learn all the basics you need to start developing your apps and know what’s possible with apps on the Microsoft platform. My new book focuses on helping you get the Microsoft exam 70-481 to prove that you’re capable of developing Windows Store apps.

One thing to be aware of is that Microsoft Exam Reference books are completely aligned with the exam certifications. This means that the chapters exactly follow the objectives of the exam. Sometimes this means that the book jumps from one topic to another. If that’s the case, it’s because the Exam objectives are organized in that way. You will get most out of the book if you start with carefully reading the Exam objectives and then choose those chapters that you want to learn more about.

So if you are into app development get my new book now!

If you have any questions or feedback feel free to leave a comment, reach me at twitter (@wouterdekort) or send me an email at wouter.dekort@seizeit.nl

Monday, July 7, 2014

Why I am a Microsoft ALM Ranger

Do you know who the ALM Rangers are? Here is a snippet describing what mission the ALM Rangers have:

The Visual Studio ALM Rangers provide professional guidance, practical experience and gap-filling solutions to the ALM community.

This means that we as Rangers try to help you implement a professional Application Lifecycle Management strategy. We do this by creating guidance such as the TFS Planning and Disaster Avoidance and Recovery Guide which helps you in installing Team Foundation Server, tooling like the Unit Test Generator and articles and whitepapers like this one Feature Toggles at MSDN Magazine.

As you can see, the Rangers provide a lot of resources! You can find the complete list at ALM Rangers Solutions.

Proud to be an Active ALM Ranger!

The Rangers are a large group of Microsoft and non-Microsoft people who have a strong passion for ALM and TFS. When you join the Rangers, you start out as an associate Ranger. At the end of every year, all ALM Rangers contributions are counted and Rangers are promoted or scrubbed depending on their activity.

This process happens during the month June at the end of the year at Microsoft. So you can understand I was very happy to receive the following email:

clip_image001COWABUNGA!

The following Associate ALM Rangers have been moved to the Active ALM Rangers group on http://aka.ms/vsarindex based on FY13/14 achievements:

Wouter de Kort

And there was my name! As of that moment I am an Active ALM Ranger.  

 

So why would you want to be an ALM Ranger?

The Rangers are volunteers who use their own time and resources to work together to produce all the guidance and tooling to help others work with ALM solutions.

Why would you want to spend your own time voluntarily? Well, I can’t speak for others but I think most of the Rangers have the following reasons:

We love helping others. Writing guidance, giving presentations, responding to questions. All those activities and more are very popular with the Rangers.

We love learning new things. When joining the Rangers, you join a large group (at this moment 182!) of enthusiastic and very knowledgeable people.You work together on researching new stuff and creating guidance and tooling. You also work directly with the Visual Studio Product Group which opens up an enormous amount of knowledge. For example, when working with Release Management I ran into a couple of issues. A few quick emails later, I was in direct contact with someone at Microsoft who works on Release Management!

Do you want to be a Ranger?

If you look at the ALM Rangers Flight plan you see that we are currently working on a Windows 8 app, guidance for running TFS on Azure, researching SAFe, Config as Code and a bunch of other projects.

vsarFlightPlan

As you can understand, we can always use help of passionate individuals who love ALM! If you are interested in becoming a Ranger, check out the blog post Understanding the Visual Studio ALM Rangers and leave a comment, reach me at Twitter (@wouterdekort) or send send me an email (wouter.dekort@seizeit.nl).

Thursday, March 27, 2014

Build here we come!

Only six more days and then Microsoft //Build 2014 will start! The schedule still only shows the begin and end times but slowly some details are coming out.
So here are my personal hopes and speculations on what Microsoft is going to show us next week.
One source of inspiration is the schedule for the Dutch TechDays that will be held two weeks after Build. This week a 16 sessions showed up on the schedule with the following entrigung title:
 

to be announced after //Build

The following speakers will be presenting those sessions:
  • Marcel de Vries (ALM MVP and Microsoft Regional Director for the Netherlands)
  • Alex Thissen (.NET architect at a Dutch company)
  • Rajen Kishna (Microsoft Technical Evangelist focused on Windows 8 and Windows Phone)
  • Maarten Struys (Microsoft Account Technology Strategist focusing on Windows Embedded, Windows Phone and Windows Store apps)
  • Andy Wigley (Microsoft Technical Evangelist focused on Windows Phone)
  • Matthijs Hoekstra (Senior Product Marketing Manager focused on Windows Phone)
  • Bart de Smet (Microsoft Software Development Engineer focused on C#/Reactive Extensions and cloud)
  • Robert Green (Microsoft Technical Evangelist focused on Visual Studio)
So what can we conclude from this list?
There is definitely going to be Windows Phone news. This shouldn’t be a surprise since Windows Phone 8.1 rumors are all over the internet. Other rumors focus on the merge of Windows Store for Windows Phone, Xbox and Windows 8 Store. Will this be announced this year or do we have to wait to 2015? We will see!
The other interesting sessions will revolve around ALM, C# and Visual Studio. Since those are the areas I really look forward to here some hopes of mine:
  • Roslyn! I really hope we get at least a new CTP or maybe even a beta.
  • Brian Harry already mentioned on his blog they did a huge update to Visual Studio Online that’s still hidden behind feature flags. In his ALM Summit keynote in Germany he mentioned that Release Management will be added to Visual Studio Online so that’s at least one thing we can expect. The other feature I really hope for is the merging of Lab Management and Release Management. Currently there is a lot of overlap between those services and it’s hard to explain this to customers other then ‘wait and see’. Let’s hope Build will clear this.
  • Project N: at the Visual Studio 2013 launch a brief demo was shown on compiling C# directly to machine code. Maybe we are going to hear more about it.
  • C# 6: Mads Torgersen already demoed some expected new C# 6 features at the NDC and I hope that together with Roslyn we will get our hands on those new features.
  • Visual Studio 2013 and Team Foundation Server 2013 Update 2 will probably be released. Currently in CTP 2, I wouldn’t be surprised if we got a new beta with a Go Live license.
  • I’m also wondering if we will be seeing anything new related to Azure. At least the name change to Microsoft Azure is scheduled for Thursday during Build so maybe that will be live and we will get some new features?
So that are my hopes and speculations. New ALM and new C# stuff would make my Build great. It would also be nice to see Satya Nadella in person and maybe we can even get some Developers Developers Developers.
So what are your thoughts? Any new speculations? Any things you hope for? Or want to grab a cup of coffee during Build? Just leave a comment!




Monday, October 28, 2013

Desugaring foreach

When working with data you often work with collections. This could be an array, one of the .NET Framework collections or maybe even a custom collection type.

Iterating over the elements in a collection is such a common task that the creators of C# added some syntactic sugar to make this task even easier in the form of the foreach statement. Understanding what’s going on behind the scenes can help you when working with collections and it can show you new ways to improve your own collection types.

What if there was no syntactic sugar?

Let’s say you have an array containing some integers and you where asked to display them on screen without using the foreach statement. What would you use?

Well, you could use a for loop like this:

   1:  using System;
   2:   
   3:  namespace Foreach
   4:  {
   5:      class Program
   6:      {
   7:          static void Main(string[] args)
   8:          {
   9:              int[] numbers = { 1, 1, 2, 3, 5, 8, 13 };
  10:   
  11:              for (int index = 0; index < numbers.Length; index++)
  12:              {
  13:                  int current = numbers[index];
  14:                  Console.WriteLine(current);
  15:              }
  16:   
  17:              Console.ReadLine();
  18:          }
  19:      }
  20:  }

By keeping track of where you are in the collection and finding the current element you can iterate quite easily over all the elements in the array.

Another way would be to use a while loop:


   1:  using System;
   2:   
   3:  namespace Foreach
   4:  {
   5:      class Program
   6:      {
   7:          static void Main(string[] args)
   8:          {
   9:              int[] numbers = { 1, 1, 2, 3, 5, 8, 13 };
  10:              
  11:              int index = 0;
  12:              while (index < numbers.Length)
  13:              {
  14:                  int current = numbers[index];
  15:                  Console.WriteLine(current);
  16:                  index++;
  17:              }
  18:   
  19:              Console.ReadLine();
  20:          }
  21:      }
  22:  }

Under the covers, a for statement is usually implemented using a while loop. If you compare both statements, you see a couple of similarities. Both use an index to keep track of where they are in the collection and check the length of the collection. They also fetch the current item for you so you can use it. Because of these similarities, it would be nice to have a language construct that made it easier to use collections. Fortunately, that’s exactly what the foreach statement does.

Using some syntactic sugar: foreach

The foreach statement is syntactic sugar that allows you to easily work with collections. The previous examples can be rewritten to use foreach:


   1:  using System;
   2:   
   3:  namespace Foreach
   4:  {
   5:      class Program
   6:      {
   7:          static void Main(string[] args)
   8:          {
   9:              int[] numbers = { 1, 1, 2, 3, 5, 8, 13 };
  10:   
  11:              foreach (int current in numbers)
  12:              {
  13:                  Console.WriteLine(current);
  14:              }     
  15:   
  16:              Console.ReadLine();
  17:          }
  18:      }
  19:  }

When you are working on an array, the compiler is smart enough to translate your code to a basic for loop. This gives you the best performance when working with arrays.

When you are working with a more complex collection, like a List<int> you get a different behavior. When working with such a collection, the IEnumerable and IEnumerator interfaces are used to implement the iterator pattern.

In essence, foreach translates into the following C# code:


   1:  List<int>.Enumerator e = numbers.GetEnumerator();
   2:   
   3:  try
   4:  {
   5:      int v;
   6:      while (e.MoveNext())
   7:      {
   8:          v = e.Current;
   9:          Console.WriteLine(v);
  10:      }
  11:  }
  12:  finally
  13:  {
  14:      IDisposable d = e as IDisposable;
  15:      if (d != null) d.Dispose();
  16:  }

Your collection exposes a method called GetEnumerator. The enumerator object keeps track of where it is in the collection and offers you access to the current item. By using the while loop, you can move trough all elements in the collection. The try/finally block is added to make sure that you always dispose of the enumerator if it implements IDisposable.

And that’s how the foreach statement works. As you can understand, there is a whole lot more to creating your own enumerator objects and making sure that your collection can be used in a foreach statement. This concerns things like implementing a GetEnumerator method, the IEnumerable interface, using dynamic and using some other syntactic sugar: yield.

But that’s a topic for next time!

Questions? Feedback? Please leave a comment!