下午好
在构建包含我正在使用的第三方 krypton 组件的 .licx 文件的项目时,我遇到了 BuildManager 类的问题。
我的编译器是用 .Net 4.5 编写的,而目标构建项目是 .Net 2.0。
尝试通过构建管理器进行构建时,目标项目会产生以下消息。
无法解析类型 'ComponentFactory.Krypton.Navigator.KryptonNavigator, ComponentFactory.Krypton.Navigator, Version=2.6.1.0, Culture=neutral, PublicKeyToken=[Licence]
它从 Visual Studio 构建得很好,我已经将组件放入 .Net 4.5 应用程序中,并且它也构建了,所以我假设问题是与 .Net 2 上的组件冲突。我无法升级这个项目。
我希望它只是所需的构建管理器的一个属性,但我找不到太多关于它的文档。
这是我的构建代码
String[] args = (String[])e.Argument;
String SolutionFile = args[0];
String TargetPath = args[1];
String LogFilePath = args[2];
ProjectCollection pc = new ProjectCollection();
Dictionary<String, String> GlobalProperty = new Dictionary<String, String>();
BasicFileLogger log = new BasicFileLogger();
log.Parameters = LogFilePath;
log.register();
GlobalProperty.Add("Configuration", "Release");
GlobalProperty.Add("Platform", "Any CPU");
GlobalProperty.Add("OutputPath", TargetPath);
GlobalProperty.Add("AllowUnsafeBlocks", "true");
GlobalProperty.Add("Optimize", "true");
BuildManager.DefaultBuildManager.BeginBuild(new BuildParameters(pc) { MaxNodeCount = Environment.ProcessorCount,Loggers = new List<ILogger>(){log} });
BuildRequestData BuildRequest = new BuildRequestData(SolutionFile, GlobalProperty, null, new string[] { "Clean", "Rebuild" }, null);
BuildSubmission Submission = BuildManager.DefaultBuildManager.PendBuildRequest(BuildRequest);
Stopwatch watch = new Stopwatch();
watch.Start();
Submission.Execute();
while (!Submission.IsCompleted)
{
if (isCancelled || watch.Elapsed==new TimeSpan(0,5,0))
{
e.Cancel = true;
}
worker.ReportProgress(0, "Building");
}
String output = String.Empty;
System.IO.File.WriteAllText(LogFilePath, log.getLogoutput());
BuildManager.DefaultBuildManager.EndBuild();
e.Result = new Docs_Creator.Classes.Build.BuildSuccessArgs(
SolutionName: SolutionFile,
Success: Submission.BuildResult.OverallResult == BuildResultCode.Success,
Error: null);