【发布时间】:2020-08-23 12:29:07
【问题描述】:
我想设置一个 Visual C++ 工具链以在我的 C# 应用程序中使用。对于工具链,建议调用vcvarsall(或一些子变体)。我的问题是调用进程——我的应用程序——将无法保持vcvarsall 设置的环境。这能以某种方式实现吗?
// First set up the toolchain with vcvarsall
var vcvarsallProc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = vcvarsallPath,
Arguments = "x86",
UseShellExecute = false,
}
};
vcvarsallProc.Start();
vcvarsallProc.WaitForExit();
// Invoke the linker for example
var linkerProc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "LINK.exe",
Arguments = " foo.obj /OUT:a.exe",
UseShellExecute = false,
}
};
linkerProc.Start();
linkerProc.WaitForExit();
// ERROR: 'LINK' is not recognized as an internal or external command
【问题讨论】:
标签: c# process environment-variables