I created a C# console application with Visual Studio 2022 that just prints a hello world on the console for testing purposes. Now I am trying to build the project using MSBuild directly on the command line.
As far as I understood, Visual Studio uses MSBuild as well, so at first I tried to just execute:
"c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" LeoBuildToolsTest.sln
which reports an error regarding wrong XML namespace. After I fixed that, there's a problem regarding missing targets, which is obvious, as there are none:
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</Project>
I was able to get the project build by MSBuild but only with my manually written testproject.proj
file. So I want to ask whether there is a way to automatically generate a MSBuild proj file by VS that be used directly as input? Or do I always have to write it by myself?