Retargeting Visual Studio Test Projects for .NET 4 Platform Update 1.

If you are using .NET 4 Platform Update 1 to do unit testing you may encounter this dialog box when you try to change the target framework of your test project

SNAGHTML7365d6

Tip: You can press Ctrl+C on a message box to copy the text to the clipboard.  If you want to go to the link mentioned in the message box this makes it much easier.  Here is the text from the clipboard.

---------------------------
Microsoft Visual Studio
---------------------------
Attempted re-targeting of the project has been canceled. To be able to target your test project to .NET Framework 3.5, you must use the steps documented at the following Microsoft Web site:  https://go.microsoft.com/fwlink/?LinkId=201405.
---------------------------
OK  
---------------------------

This link takes you to a page that gives you instructions on how to retarget for .NET Framework 3.5.  Of course you aren’t trying to do that so here are the correct instructions.

How To Retarget Visual Studio Test Projects for .NET 4 Platform Update

  1. Right click on the project and select Unload Project
  2. Right click on the unloaded project and select Edit (name of project)
  3. Change the target framework version to v4.0.1
 <TargetFrameworkVersion>v4.0.1</TargetFrameworkVersion>

Reload the project and you are good to go.

If You Are Using NuGet

After you retarget your project, you should change your references to Microsoft.Activities and Microsoft.Activities.UnitTesting if you previously referenced them.  Nuget detects the target framework and automatically references the correct version.  The best way to do this is to uninstall/resinstall both.

uninstall-package Microsoft.Actvities.UnitTesting

uninstall-package Microsoft.Activities

followed by an install-package for both.

Happy Coding!

Ron Jacobs

https://blogs.msdn.com/rjacobs

Twitter: @ronljacobs https://twitter.com/ronljacobs