我正在尝试从生成两个版本的同一项目的外部应用程序中编译我的项目(使用编译常量)。
我使用以下代码执行MsBuild:
string msBuildPath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "msbuild.exe");
string projectPath = @"D:\NSM\NSM.csproj";
var startInfo = new ProcessStartInfo(msBuildPath)
{
Arguments = string.Format(@"/t:rebuild /p:Configuration=Release /p:DefineConstants=INTVERSION ""{0}""", projectPath),
WorkingDirectory = Path.GetDirectoryName(msBuildPath),
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
Console.WriteLine("> msbuild " + startInfo.Arguments);
var process = Process.Start(startInfo);
Console.Write(process.StandardOutput.ReadToEnd());
process.WaitForExit();
但是当我运行程序时,出现了这个错误:
无法找到导入的项目“C:\Microsoft.CSharp.targets”
我该怎么解决?
谢谢