I have some batch codes:
Path=C:\Windows\Microsoft.NET\Framework64\v4.0.30319
ECHO Trying TFS build...
msbuild D:\WORK\project\project.sln /p:Config="Debug" /p:Platform="Any CPU" /flp1:logfile=BuildLogProject.txt
That is working right. And I want to use MSBuild in my C# application.
I added Microsoft.Build.Engine reference and I'm using Engine class. I wrote some codes. But it is not working.
When I build project with Visual Studio or batch program "build succeeded" . When I build the project with my program it finds errors and warnings that are not in the project.
Engine engine = new Engine();
engine.BinPath = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319";
FileLogger logger = new FileLogger();
logger.Parameters = @"logfile=D:\WORK\project\BuildLogProject.txt";
engine.RegisterLogger(logger);
string projectPath = @"D:\WORK\project\project.sln";
try
{
bool success = engine.BuildProjectFile(projectPath);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
finally
{
engine.UnregisterAllLoggers();
engine.UnloadAllProjects();
}