The following code tries to build a Solution programmatically, using BuildManager
:
ProjectCollection pc = new ProjectCollection();
pc.DefaultToolsVersion = "12.0";
pc.Loggers.Add(fileLogger);
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
BuildRequestData buildRequest = new BuildRequestData(solutionName, globalProperty, null, new[] { "Build" }, null);
BuildParameters buildParameters = new BuildParameters(pc)
{
DefaultToolsVersion = "12.0",
OnlyLogCriticalEvents = false,
DetailedSummary = true,
Loggers = new List<Microsoft.Build.Framework.ILogger> { fileLogger }.AsEnumerable()
};
var result = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);
When I run this code, it doesn't build anything. I can see that the following compiler csc.exe
is being used, in addition to one particular version of winmdexp.exe
:
C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Csc.exe
ExportWindowsMDFile:
C:Program Files (x86)Microsoft SDKsWindowsv8.0AinNETFX 4.0 Toolswinmdexp.exe
But when I successfully build a solution using VS IDE, the following information comes up:
C:Program Files (x86)MSBuild12.0inCsc.exe
ExportWindowsMDFile:
C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolswinmdexp.exe
Why is this happening in my code & how can I change it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…