I have a C# class library (4.7 framework) which builds without any errors in visual studio 2019. When I build the same library project using msbuild, it shows errors in the project.
Error codes are: error CS1002:, error CS1056, error CS1001
"C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe" "TestProject.Common.csproj"
Any thoughts or anyone can help me on this.
VS 2019 Release build Success, MSBuild Fails
The issue is quite clear. You just use MSBuild 12.0
to build a VS2019 net framework 4.7 lib project.
"C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe"
is MSBuild of VS2013
rather than VS2019.
You cannot use a lower version of MSBuild to build a higher version project.
Note:
MSBuild 12.0
=>VS2013
MSBuild 15.0
=>VS2017
MSBuild 16.0/Current
=>VS2019
Suggestion
So you should use MSBuild of VS2019 to build your project since it builds well in VS2019 IDE.
Use this path to build your project:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community or Professional or Enterprise\MSBuild\Current\Bin\MSBuild.exe