How to call MSBuild from C#

后端 未结 5 1929
庸人自扰
庸人自扰 2020-12-24 12:46

Is there a better way to call MSBuild from C#/.NET than shelling out to the msbuild.exe? If yes, how?

5条回答
  •  伪装坚强ぢ
    2020-12-24 13:33

    If all you want is the path to the MSBuild tools folder, you can use the ToolLocationHelper class from the Microsoft.Build.Utilities.Core assembly:

    var toolsetVersion = ToolLocationHelper.CurrentToolsVersion;
    var msbuildDir = ToolLocationHelper.GetPathToBuildTools(toolsetVersion);
    

提交回复
热议问题