Microsoft.CompactFramework.CSharp.targets was not found while opening projects

30,050

Solution 1

It is poorly documented.

Both .NET Compact Framework Redistributable and Power Toys must be installed for all necessary files (such as MSBuild targets files) to be available for compilation.

Solution 2

For all those who end up here as a result of the Windows 10 "anniversary update" note that the file Microsoft.Compactframework.CSharp.Targets can be found in the C:\Windows.old\WINDOWS\Microsoft.NET\Framework\v3.5 directory and copied back to where it belongs!

(Same with Microsoft.CompactFramework.Common.targets, Microsoft.CompactFramework.VisualBasic.targets)

Solution 3

It also happened to me, and more than just once, with two projects for Visual Studio 2008 Professional.

It's quite easy for me to solve this problem: just re-install (I use the "Repair" option that seems to work great) the Power Toys for .NET Compact Framework 3.5. You can find this tool here: http://www.microsoft.com/en-us/download/details.aspx?id=13442

I think that sometimes, maybe after some Windows/.NET framework automatic updates, this problem can still occur. But the solution is quite easy in this case, and there is no need to edit the .vbproj/.csproj file!

Solution 4

I met the same mistake . Solution vs2008 repair.

Solution 5

For people landing here via a Google search and using Jetbrains Ryder:

I'm using both VS2008 and Jetbrains Ryder next to each other for development. My VS2008 was working fine whilst Ryder was not. I had to manually copy a few files from one folder to another to make it work.

To fix it you'll have to copy a few targets files from one folder to another.

Go to the folder C:\Windows\Microsoft.NET\Framework\v3.5 and copy the following files:

  • Microsoft.CompactFramework.Common.targets
  • Microsoft.CompactFramework.CSharp.targets
  • Microsoft.CompactFramework.VisualBasic.targets

Now go to C:\Program Files (x86)\MSBuild\14.0\Bin and paste the copied files here.

Finally, restart Ryder and you're good to go!

The above steps did the trick for me for the Ryder IDE but if you're having the same troubles with VS2008 it might be worth a shot as well.

Share:
30,050
MARKAND Bhatt
Author by

MARKAND Bhatt

Updated on February 05, 2021

Comments

  • MARKAND Bhatt
    MARKAND Bhatt almost 3 years

    I tried to create a smart device project in Visual Studio 2008.

    Target Platform: Windows Mobile 5.0 Pocket PC SDK.

    .NET Compact Framework version: .NET Compact Framework 3.5

    But I get the following error:

    enter image description here

  • MARKAND Bhatt
    MARKAND Bhatt over 7 years
    Can not find csproj file. from the error, it seems that the csproj file is somewhere in temp folder
  • Kendall Bennett
    Kendall Bennett almost 7 years
    Basically this got nuked in Windows 10 Anniversary update, but if you re-install the Power Toys again it fixes it. microsoft.com/en-us/download/details.aspx?id=13442
  • Kendall Bennett
    Kendall Bennett almost 7 years
    I had already nuked that directory when I ran into this after Anniversary handily decided to install itself. Doh! But I quickly discovered I could recover it by reinstalling the power toys. microsoft.com/en-us/download/details.aspx?id=13442
  • eli
    eli over 6 years
    To me it happened on Creators Update. Reinstalling .NET Compact Framework Redistributable and Power Toys as in this answer stackoverflow.com/a/36385715/2614479 did the trick.
  • Mike W
    Mike W over 5 years
    "April Update" does the same.
  • bvdb
    bvdb over 5 years
    Indeed, the "Repair" option is enough. - I am considering to try my future builds with a docker: gist.github.com/ashalkhakov/cc2bc798caecb52ed123f9a8ed0e575d
  • Murat Özbayraktar
    Murat Özbayraktar over 4 years
    Power Toys fix my problem. Thanks.
  • Suncat2000
    Suncat2000 about 4 years
    @KendallBennett After the latest Windows update a few minutes ago, your link saved my bacon. Much appreciated!
  • Kendall Bennett
    Kendall Bennett about 4 years
    @ Suncat2000 we thankfully ported all our code to Android so finally got rid of Compact Framework, but glad it helped! It took years to finally get that done on our end.
  • Matt
    Matt almost 3 years
    The file you're looking for is "NETCFv35PowerToys.msi". Above link no longer works but is currently available here: web.archive.org/web/20080726091821/https://…
  • Belmiris
    Belmiris over 2 years
    Matt - Thanks! You are a lifesaver. Google was failing me big time.
  • Peter-Yu
    Peter-Yu over 2 years
    I can't find Windows.old folder, finally copy from my coworker's pc, then it works.
  • Mołot
    Mołot about 2 years
    For archived compact framework 3.5 you can use web.archive.org/web/20200811074848/https://www.microsoft.com‌​/…