0

我在 VS 中有一个 C# 项目。我想在其他项目中使用 Microsoft.Build.Evaluation 构建它。

我试试这个(在这里找到)

Project pr = new Project(@"path\to\.sln");
pr.SetGlobalProperty("Release", "x86");
if (pr.Build())
    Logs = $"{DateTime.Now}: success";
else
    Logs = $"{DateTime.Now}: fail";

但在 1 行有错误

The project file could not be loaded. Data at the root level is invalid, Line 2, position 1

那我试试

        Project pr = new Project();
        pr.FullPath = @"path\to\.sln";
        pr.SetGlobalProperty("Release", "x86");
        if (pr.Build())
            Logs = $"{DateTime.Now}: success";
        else
            Logs = $"{DateTime.Now}: fail";

但这只是让我失败

4

0 回答 0