Software Architect / Microsoft MVP (AI) and Technical Author

C#, Developer Life, General Development, Git

Resolving The “Imported Project “C:\Microsoft.CSharp.targets Was Not Found” Error in VS2022

I recently had a mega-merge with a load of conflicts to resolve for a SaaS I built and run.  After resolving each conflict, the web project in the solution failed to load.

 

Here was the error:

Imported Project "C:\Microsoft.CSharp.targets Was Not Found

 

Everything I read suggested changing this line in the project file from this:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

 

To this:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

 

That didn’t work.

~

Git-Fu

In the end, I had to run the following Git command:

git clean -xdf

 

I had a feeling temp files, merge conflict files, and other build artefacts were causing the issue.

This command removes unwanted files from your working directory.

It worked.

Learn more about the client command the respective parameters here.

~

The Lesson Learned

I should know better than to let a feature branch run for so long.

 

JOIN MY EXCLUSIVE EMAIL LIST
Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.

Leave a Reply