If you open your NSM.csproj file, you will see a line like this:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
The problem is that $(MSBuildToolsPath) proprety is not installed, so your project path becomes \Microsoft.CSharp.targets , so you see the error you described. This is not a problem when creating a project from the Visual Studio IDE or VS Command Prompt, because the appropriate environment that invokes this property will be automatically configured for you.
Therefore, outside of the VS environment, you need to make sure that MSBuildToolsPath installed before msbuild . msbuild will display the specified environment variables as properties, so one way to do this is to set the environment variable by that name before msbuild , for example:
Environment.SetEnvironmentVariable("MSBuildToolsPath", RuntimeEnvironment.GetRuntimeDirectory());
source share