<p>I got this error today when trying to open a Visual Studio 2008 <strong>project</strong> in Visual Studio 2005:</p>

<blockquote>
  <p>The imported project "C:\Microsoft.CSharp.targets" was not found.</p>
</blockquote>

[{'answer_id': 5695, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 8, 'selected': True, 'text': '<p>Open your csproj file in notepad (or notepad++)\nFind the line: </p>\n\n<pre><code>&lt;Import Project="$(MSBuildToolsPath)\\Microsoft.CSharp.targets" /&gt;\n</code></pre>\n\n<p>and change it to</p>\n\n<pre><code>&lt;Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" /&gt;\n</code></pre>\n'}, {'answer_id': 876831, 'author': 'Oleg Sakharov', 'author_id': 87057, 'author_profile': 'https://Stackoverflow.com/users/87057', 'pm_score': 4, 'selected': False, 'text': '<p>This <a href="http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/4c8249db-85ad-4356-9313-5d47411f1a1a" rel="noreferrer">link on MSDN</a> also helps a lot to understand the reason why it doesn\'t work. $(MSBuildToolsPath) is the path to Microsoft.Build.Engine v3.5 (inserted automatically in a project file when you create in VS2008). If you try to build your project for .Net 2.0, be sure that you changed this path to $(MSBuildBinPath) which is the path to Microsoft.Build.Engine v2.0.</p>\n'}, {'answer_id': 2912317, 'author': 'Andre Luus', 'author_id': 323071, 'author_profile': 'https://Stackoverflow.com/users/323071', 'pm_score': 2, 'selected': False, 'text': '<blockquote>\n  <p>ok so what if it say this: between the\n  gt/lt signs</p>\n  \n  <p>Import\n  Project="$(MSBuildExtensionsPath)\\Microsoft\\Silverlight\\v3.0\\Microsoft.Silverlight.CSharp.targets"\n  /</p>\n  \n  <p>how do i fix the targets error?</p>\n</blockquote>\n\n<p>I also found that import string in a demo project (specifically "Build your own MVVM Framework" by Rob Eisenburg).</p>\n\n<p>If you replace that import with the one suggested by lomaxx VS2010 RTM reports that you need to install <a href="http://go.microsoft.com/fwlink/?LinkId=168436" rel="nofollow noreferrer">this</a>.</p>\n'}, {'answer_id': 7042664, 'author': 'Peter', 'author_id': 15349, 'author_profile': 'https://Stackoverflow.com/users/15349', 'pm_score': 2, 'selected': False, 'text': "<p>I got this after reinstalling Windows. Visual Studio was installed, and I could see the Silverlight project type in the New Project window, but opening one didn't work. The solution was simple: I had to install the Silverlight Developer runtime and/or the Microsoft Silverlight 4 Tools for Visual Studio. This may seem stupid, but I overlooked it because I thought it should work, as the Silverlight project type was available.</p>\n"}, {'answer_id': 7239367, 'author': 'stack247', 'author_id': 661900, 'author_profile': 'https://Stackoverflow.com/users/661900', 'pm_score': 2, 'selected': False, 'text': '<p>For errors with <code>Microsoft.WebApplications.targets</code>, you can:</p>\n\n<ol>\n<li>Install Visual Studio 2010 (or the same version as in development machine) in your TFS server.</li>\n<li>Copy the “<code>Microsoft.WebApplication.targets</code>” from development machine file to TFS build machine.</li>\n</ol>\n\n<p><a href="http://stack247.wordpress.com/2011/08/29/the-imported-project-microsoft-webapplications-targets-was-not-found/" rel="nofollow">Here\'s</a> the post.</p>\n'}, {'answer_id': 13995747, 'author': 'appenthused', 'author_id': 1017156, 'author_profile': 'https://Stackoverflow.com/users/1017156', 'pm_score': 3, 'selected': False, 'text': '<p>I used to have this following line in the csproj file:</p>\n\n<pre><code>&lt;Import Project="$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v10.0\\WebApplications\\Microsoft.WebApplication.targets" /&gt;\n</code></pre>\n\n<p>After deleting this file, it works fine.</p>\n'}, {'answer_id': 18078170, 'author': 'Greg Gum', 'author_id': 425823, 'author_profile': 'https://Stackoverflow.com/users/425823', 'pm_score': 1, 'selected': False, 'text': '<p>This error can also occur when opening a Silverlight project that was built in SL 4, while you have SL 5 installed.</p>\n\n<p>Here is an example error message: The imported project "C:\\Program Files (x86)\\MSBuild\\Microsoft\\Silverlight\\v4.0\\Microsoft.Silverlight.CSharp.targets" was not found.</p>\n\n<p>Note the v4.0.</p>\n\n<p>To resolve, edit the project and find:  </p>\n\n<pre><code>&lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;\n</code></pre>\n\n<p>And change it to v5.0.</p>\n\n<p>Then reload project and it will open (unless you do not have SL 5 installed).</p>\n'}, {'answer_id': 38782270, 'author': 'Alf Moh', 'author_id': 5138921, 'author_profile': 'https://Stackoverflow.com/users/5138921', 'pm_score': 3, 'selected': False, 'text': '<p>If you are to encounter the error that says <code>Microsoft.CSharp.Core.targets not found</code>, these are the steps I took to correct mine:</p>\n\n<ol>\n<li><p>Open any previous working projects folder and navigate to the link showed in the error, that is <code>Projects/(working project name)/packages/Microsoft.Net.Compilers.1.3.2/tools/</code> and search for <code>Microsoft.CSharp.Core.targets</code> file. </p></li>\n<li><p>Copy this file and put it in the non-working project <code>tools folder</code> (that is, navigating to the tools folder in the non-working project as shown above)</p></li>\n<li><p>Now close your project (if it was open) and reopen it. </p></li>\n</ol>\n\n<p>It should be working now.</p>\n\n<p>Also, to make sure everything is working properly in your now open Visual Studio Project, Go to <code>Tools &gt; NuGetPackage Manager &gt; Manage NuGet Packages For Solution</code>. Here, you might find an error that says, CodeAnalysis.dll is being used by another application. </p>\n\n<p>Again, go to the <code>tools folder</code>, find the specified file and delete it. Come back to <code>Manage NuGet Packages For Solution</code>. You will find a link that will ask you to Reload, click it and everything gets re-installed. </p>\n\n<p>Your project should be working properly now.</p>\n'}, {'answer_id': 40190795, 'author': 'Bharat', 'author_id': 5816119, 'author_profile': 'https://Stackoverflow.com/users/5816119', 'pm_score': 6, 'selected': False, 'text': "<blockquote>\n<p>This is a global solution, not dependent on particular package or bin.</p>\n</blockquote>\n<p>In my case, I removed <strong>Packages</strong> folder from my root directory.</p>\n<blockquote>\n<p>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.</p>\n</blockquote>\n<p>Steps to <strong>Add new packages</strong></p>\n<ul>\n<li>First remove, packages folder (<strong>it will be near by or one step up to your current project folder</strong>).</li>\n<li>Then restart the project or solution.</li>\n<li>Now, Rebuild solution file.</li>\n<li>Project will get new references from nuGet package manager. And your issue will be resolved.</li>\n</ul>\n<p>This is not proper solution, but <strong>I posted it here because I face same issue.</strong></p>\n<p>In my case, <strong>I  wasn't even able to open my solution in visual studio and didn't get any help with other SO answers.</strong></p>\n"}, {'answer_id': 42238377, 'author': 'Gichamba', 'author_id': 487030, 'author_profile': 'https://Stackoverflow.com/users/487030', 'pm_score': 2, 'selected': False, 'text': '<p>In my case, I opened my .csproj file in notepad and removed the following three lines. Worked like a charm:</p>\n\n<pre><code>&lt;Import Project="..\\packages\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\\build\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists(\'..\\packages\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\\build\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props\')" /&gt;\n&lt;Import Project="..\\packages\\Microsoft.Net.Compilers.1.0.0\\build\\Microsoft.Net.Compilers.props" Condition="Exists(\'..\\packages\\Microsoft.Net.Compilers.1.0.0\\build\\Microsoft.Net.Compilers.props\')" /&gt;\n&lt;Import Project="..\\packages\\Microsoft.Net.Compilers.1.3.2\\build\\Microsoft.Net.Compilers.props" Condition="Exists(\'..\\packages\\Microsoft.Net.Compilers.1.3.2\\build\\Microsoft.Net.Compilers.props\')" /&gt;\n</code></pre>\n'}, {'answer_id': 43467560, 'author': 'user2042930', 'author_id': 2042930, 'author_profile': 'https://Stackoverflow.com/users/2042930', 'pm_score': 5, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 46618902, 'author': 'Atron Seige', 'author_id': 375114, 'author_profile': 'https://Stackoverflow.com/users/375114', 'pm_score': 0, 'selected': False, 'text': '<p>I deleted the obj folder and then the project loaded as expected.</p>\n'}, {'answer_id': 47452127, 'author': 'Vojta', 'author_id': 2524260, 'author_profile': 'https://Stackoverflow.com/users/2524260', 'pm_score': 4, 'selected': False, 'text': '<p>In my case I could not load <strong>one</strong> out of <strong>5 projects</strong> in my solution.</p>\n\n<p>It helped to <strong>close Visual Studio</strong> and I had to <strong>delete</strong> <code>Microsoft.Net.Compilers.1.3.2</code> nuget folder under <code>packages</code> folder.</p>\n\n<p><strong>Afterwards, open your solution again and the project loaded as expected</strong></p>\n\n<p><em>Just to be sure, close all instances of VS before you delete the folder.</em></p>\n'}, {'answer_id': 49113817, 'author': 'WholeLifeLearner', 'author_id': 1528883, 'author_profile': 'https://Stackoverflow.com/users/1528883', 'pm_score': 0, 'selected': False, 'text': '<p>Sometimes the problem might be with hardcoded VS version in .csproj file. If you have in your csproj something like this:</p>\n\n<pre><code>[...]\\VisualStudio\\v12.0\\WebApplications\\Microsoft.WebApplication.targets"\n</code></pre>\n\n<p>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:</p>\n\n<pre><code>[...]\\VisualStudio\\v$(VisualStudioVersion)\\WebApplications\\Microsoft.WebApplication.targets"\n</code></pre>\n'}, {'answer_id': 54716193, 'author': 'Alex', 'author_id': 6146387, 'author_profile': 'https://Stackoverflow.com/users/6146387', 'pm_score': 0, 'selected': False, 'text': '<p>I ran into this issue while executing an Ansible playbook so I want to add my 2 cents here. I noticed a warning message about missing Visual Studio 14. Visual Studio version 14 was released in 2015 and the solution to my problem was installing Visual Studio 2015 Professional on the host machine of my Azure DevOps agent.</p>\n'}, {'answer_id': 55723368, 'author': 'Worthy7', 'author_id': 1079267, 'author_profile': 'https://Stackoverflow.com/users/1079267', 'pm_score': 0, 'selected': False, 'text': '<p>After trying to restore, closing VS, deleting the failed package, reopening, trying to restore, multiple times I just deleted everything in packages and when I did a restore and it worked perfectly.</p>\n'}, {'answer_id': 66758114, 'author': 'Andreas', 'author_id': 6344387, 'author_profile': 'https://Stackoverflow.com/users/6344387', 'pm_score': 0, 'selected': False, 'text': '<p>For me, the issue was the path.. When cloning the project that had a space in the name. The project folder was named <code>&quot;Sample%20-%205&quot;</code> instead of what it should be: <code>&quot;Sample - 5&quot;</code></p>\n<p>Opening the project was fine, but building failed with</p>\n<blockquote>\n<p>Could not find the file:\n/packages/Microsoft.Net.Compilers.1.3.2/tools/Microsoft.CSharp.Core.targets</p>\n</blockquote>\n'}, {'answer_id': 71736175, 'author': 'Mark Homer', 'author_id': 2316129, 'author_profile': 'https://Stackoverflow.com/users/2316129', 'pm_score': 0, 'selected': False, 'text': '<p>it seems now that the nuget packages folder has moved to a machine wide global cache, using VS2022</p>\n<p><a href="https://i.stack.imgur.com/7bz2y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7bz2y.png" alt="visual studio 2022 global nuget packages" /></a></p>\n'}, {'answer_id': 73687669, 'author': 'vsarunov', 'author_id': 3574176, 'author_profile': 'https://Stackoverflow.com/users/3574176', 'pm_score': 0, 'selected': False, 'text': '<p>For me the issue was that the solution was to deep into the documents folder and on windows 10 there is a path character limit which was reached. As soon as I moved the solution folder up couple of folders this fixed the issue.</p>\n'}]
['https://Stackoverflow.com/questions/5694', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/493/']