When I'm compiling project via PowerShell:
PS C:\Windows\Microsoft.NET\Framework64\v4.0.30319> .\MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
then it fails
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(2015,5): error MSB3091: ask failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK. 2) Install Visual Studio 2010. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the "ToolPath" parameter of the task."
but when I do it via VS Developer Command Prompt for VS2019
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.4.3
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
C:\Windows\System32>MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
then it works perfectly fine!
But, as you see Current Path (folder of MS Build) is quite different, so I tried executing this in PowerShell once again with VS Dev CMD's location:
PS C:\Windows\System32> cd "C:\Windows\System32"
PS C:\Windows\System32> MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
MSBuild.exe : The term 'MSBuild.exe' is not recognized as the name of a cmdlet, function, script file, or operable prog
ram. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj" ...
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSBuild.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Windows\System32>
What's going on? Why I can compile my projects perfectly fine from Developer CMD meanwhile I cannot do it with Power Shell and it screams that I do not have Windows SDK?
Or which MS Build (apparently there's a few of them) should I use?
MSBuild
is shipped together with VS or BuildTools. You should this one, not from .NET Framework – Pavel Anikhouski