Reputation: 1664
I'm trying to build multiple solutions in parallel across different threads and it isn't working.
The code looks like:
var buildParameters = new BuildParameters(new ProjectCollection())
{
MaxNodeCount = 1,
Loggers = loggers
};
var buildRequest = new BuildRequestData(
solutionFilePath,
new Dictionary<string, string> { {"Configuration", "Release"} },
"14.0",
new[] { "Build" },
null);
var result = new BuildManager().Build(buildParameters, buildRequest);
When executing this sequentially for each solution it works perfectly. When this is executed simultaneously across multiple threads it fails with errors like:
'StartUp.cs', line: 10, column: 12, error: 'The type or namespace name 'OwinStartupAttribute' could not be found (are you missing a using directive or an assembly reference?)'
'StartUp.cs', line: 10, column: 12, error: 'The type or namespace name 'OwinStartup' could not be found (are you missing a using directive or an assembly reference?)'
'Controllers\CacheController.cs', line: 2, column: 18, error: 'The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)'
'Controllers\LogController.cs', line: 2, column: 18, error: 'The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)'
'Controllers\LogController.cs', line: 3, column: 24, error: 'The type or namespace name 'Communication' does not exist in the namespace 'MyNamespace' (are you missing an assembly reference?)'
Initially this code used BuildManager.DefaultBuildManager
which seems to be the most common useage however it is a singleton and this failed because a single instance of BuildManager
can't only build 1 thing at a time. Creating a new instance of BuildManager
gets past that problem but fails with the above errors. I have tried setting the hostName parameter to a unique value for each thread or not providing it but this makes no difference (and I can find no documentation about what it means either).
Does this just have some static shared resources that prevent this from being possible or am I doing something wrong? If there is any documentation that might help on this I'd appreciate a pointer in the right direction (every search I've done on this just comes up with results for parallelizing project builds within a solution).
Upvotes: 1
Views: 234