Galin Iliev's blog

Software Architecture & Development

VS2010: Cannot change the specified .NET framework version or profile for a test project

I received the error message "attempted re-targeting of the project has been canceled. You cannot change the specified .NET framework version or profile for a test project" when trying to target the .NET 3.5 framework after upgrading to Visual Studio 2010.

And this was tricky – we want to move to VS 2010 but still compile against .NET .3.5. Although having tests target .NET 4 is not critical is not very nice. We don’t want to have bugs slipped out because production code and test code are compiled against different .NET versions.

Luckily there is a solution – manually editing .csproj file and trick VS2010 to think it is not a test class library but simply class library:

  1. Open .csproj file with notepad.
  2. Search for this line:
  3. <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};
  4. Remove {3AC096D0-A1C2-E12C-1390-A8335801FDAB} guid
  5. Save file and Open in VS 2010
  6. It is ready to be re-targeted

Hope this helps

Comments (7) -

  • Colin Farr

    10/6/2010 8:59:50 PM | Reply

    Nice one mate! I couldn't believe it when I couldn't find a workaround even from MS! Good work

  • Dave

    11/26/2010 11:52:27 AM | Reply

    Dude, you're a star! Thank you for posting this, I've been banging my head against this MS shaped brick wall for the past hour.

  • Patrick Kalkman

    1/20/2011 9:19:59 PM | Reply

    Thanks, just converted a lot of test projects. They were all converted to .Net 4.0 and I couldn't convert them back. Your solution works!!

  • l-r

    2/8/2011 6:44:05 PM | Reply

    Thanks, it saved me a lot of time!

  • make money online philippines

    4/18/2011 6:09:27 AM | Reply

    thanks, this is a great reference.. do you suggest we look for some more? do you have a website you are recommending? thanks!

  • Zyah

    7/16/2011 1:46:03 AM | Reply

    Always the best content from these prodigious wrteirs.