The imported project “C:\Microsoft.CSharp.targets” was not found

后端 未结 16 1922
挽巷
挽巷 2020-11-29 21:46

I got this error today when trying to open a Visual Studio 2008 project in Visual Studio 2005:

The imported project \"C:\\Microsoft.C

相关标签:
16条回答
  • 2020-11-29 22:30

    For me the issue was that the path of the project contained %20 characters, because git added those instead of spaces when the repository was cloned. Another problem might be if the path to a package is too long.

    0 讨论(0)
  • 2020-11-29 22:30

    In my case I could not load one out of 5 projects in my solution.

    It helped to close Visual Studio and I had to delete Microsoft.Net.Compilers.1.3.2 nuget folder under packages folder.

    Afterwards, open your solution again and the project loaded as expected

    Just to be sure, close all instances of VS before you delete the folder.

    0 讨论(0)
  • 2020-11-29 22:33

    I deleted the obj folder and then the project loaded as expected.

    0 讨论(0)
  • 2020-11-29 22:33

    Sometimes the problem might be with hardcoded VS version in .csproj file. If you have in your csproj something like this:

    [...]\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets"
    

    You should check if the number is correct (the reason it's wrong can be the project was created with another version of Visual Studio). If it's wrong, replace it with your current version of build tools OR use the VS variable:

    [...]\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets"
    
    0 讨论(0)
  • 2020-11-29 22:35

    For errors with Microsoft.WebApplications.targets, you can:

    1. Install Visual Studio 2010 (or the same version as in development machine) in your TFS server.
    2. Copy the “Microsoft.WebApplication.targets” from development machine file to TFS build machine.

    Here's the post.

    0 讨论(0)
  • 2020-11-29 22:36

    This is a global solution, not dependent on particular package or bin.

    In my case, I removed Packages folder from my root directory.

    Maybe it happens because of your packages are there but compiler is not finding it's reference. so remove older packages first and add new packages.

    Steps to Add new packages

    • First remove, packages folder (it will be near by or one step up to your current project folder).
    • Then restart the project or solution.
    • Now, Rebuild solution file.
    • Project will get new references from nuGet package manager. And your issue has been resolved.

    This is not proper solution, but I posted it here because I face same issue.

    In my case, I wasn't even able to open my solution in visual studio and didn't get any help with other SO answers.

    0 讨论(0)
提交回复
热议问题