how i can build c# project using Microsoft.Build.Evaluation

216 views Asked by At

I have a C# project in VS. I want to build it using Microsoft.Build.Evaluation in other project.

i try this(find here)

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

but on 1 line have error

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

then i try

        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";

but it just give me fail

0

There are 0 answers