The imported project C:\Microsoft.CSharp.targets was not found
Open your csproj file in notepad (or notepad++)
Find the line:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
and change it to
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
\MSBuild\16.0\Bin\Microsoft.CSharp.targets file not found
Please check the way it imports Microsoft.CSharp.targets
in Kamban.csproj:
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
According to the content of Kamban.csproj
, it uses $(VisualStudioVersion)
to locate Microsoft.CSharp.targets
file.It works well for VS2017 and earlier versions, but not recommended in VS2019 since the location of msbuild has changed in VS2019.
See this document: Starting in VS2019 preview, MSBuild will use "Current" instead of the major version number as part of its path.
So the Microsoft.CSharp.targets
file which you need for build process actually exists in path ...\2019\Community\MSBuild\Current\Bin\Microsoft.CSharp.targets
instead of ...\2019\Community\MSBuild\16.0\Bin\Microsoft.CSharp.targets
.
That's why it said file is missing
in error message, cause it tried to find the targets file from wrong path.
As a Workaround:
Use the $(MSBuildToolsVersion)
instead of $(VisualStudioVersion)
to locate the .targets file.
Open and edit the Kamban.csproj file, change the value of LanguageTargets
to:
<LanguageTargets>$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
Then the build engine can get correct path to find missing file.
(Note:This change works for both VS2017 and VS2019)
In addition:I've checked the open-source solution, it seems to target .net framework and .net standard, I'm not sure why this error message comes from SDK.targets, I suggest you rebuild the project in Visual Studio IDE
or by msbuild command-line.
Microsoft.CSharp.Core.targets missing
I updated to TFS2018 and the problem got solved.
Is there a way to fix the imported project error for Microsoft.CSharp.targets, other than changing the reserved property to $(MSBuildBinPath)?
Errors you're receiving might indicate .NET framework installation issues.
Create simple MSBuild file which will show you if that's the case:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PrintInfo">
<Message Text="MSBuild tools path is:$(MSBuildToolsPath)" />
</Target>
</Project>
Related Topics
Get Connectionstring from Appsettings.JSON Instead of Being Hardcoded in .Net Core 2.0 App
.Net Core 3 Yields Different Floating Point Results from Version 2.2
Visual Studio 2015 Break on Unhandled Exceptions Not Working
Is Idisposable.Dispose() Called Automatically
Write to CSV File and Export It
Why Can't C# Use Inline Anonymous Lambdas or Delegates
How to Access Session in a Webmethod
The Source Was Not Found, But Some or All Event Logs Could Not Be Searched
Is Dbcontext the Same as Datacontext
Drawing on Top of Controls Inside a Panel (C# Winforms)
How to Use Acrylic Accent in Windows 10 Creators Update
Multiple Where Clauses with Linq Extension Methods
How to Change the Button Text for 'Yes' and 'No' Buttons in the Messagebox.Show Dialog
How Is Gethashcode() Implemented for Int32
Overriding Gethashcode for Mutable Objects
C#: How to Convert a List of Objects to a List of a Single Property of That Object
Read a Xml (From a String) and Get Some Fields - Problems Reading Xml
Can a Tcp C# Client Receive and Send Continuously/Consecutively Without Sleep