Reputation: 71
I am getting this error while trying to build my ASP.Net solution using a C# console application:
MSBUILD : warning MSB4056: The MSBuild engine must be called on a single-threaded-apartment. Current threading model is "MTA". Proceeding, but some tasks may not function correctly.
This is my code:
Engine engine = new Engine();
engine.BinPath = @"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319";
FileLogger logger = new FileLogger();
logger.Parameters = @"logfile=C:\temp\build.log";
engine.RegisterLogger(logger);
bool success = engine.BuildProjectFile(ConfigurationSettings.AppSettings["ProjectPath"]);
engine.UnregisterAllLoggers();
if (success)
Console.WriteLine("Build succeeded.");
else
Console.WriteLine(@"Build failed. View C:\temp\build.log for details");
Upvotes: 3
Views: 965
Reputation: 117250
Just decorate the main method with [STAThread]
.
That said, the only issues that could cause if you can tasks that calls into COM methods. In other words, it is generally safe to ignore it.
Upvotes: 1