public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath) { if (_msbuildPath == null) { return(buildEngine.BuildProjectFile(projectFilePath, null, null, null)); } Directory.CreateDirectory(_logDir); var process = Process.Start(new ProcessStartInfo() { FileName = _msbuildPath, Arguments = $@"""{projectFilePath}"" /bl:""{binLogPath}""", UseShellExecute = false, WorkingDirectory = TempDir, }); process.WaitForExit(); if (process.ExitCode != 0) { _log.LogError($"Failed to execute MSBuild on the project file {projectFilePath}"); return(false); } return(true); }
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath) { if (TestSign) { return(buildEngine.BuildProjectFile(projectFilePath, null, null, null)); } else { return(true); } }
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, int round) { if (_msbuildPath == null) { return(buildEngine.BuildProjectFile(projectFilePath, null, null, null)); } Directory.CreateDirectory(_logDir); var process = Process.Start(new ProcessStartInfo() { FileName = _msbuildPath, Arguments = $@"""{projectFilePath}"" /bl:""{Path.Combine(_logDir, $"Signing{round}.binlog")}""", UseShellExecute = false, WorkingDirectory = TempDir, }); process.WaitForExit(); return(process.ExitCode == 0); }
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath) => buildEngine.BuildProjectFile(projectFilePath, null, null, null);
public async Task <MsBuildProjectInformation> LoadProject(string solutionDirectory, string projectFile, string targetFramework = null) { Console.WriteLine($"Loading Project: {Path.GetFileName(projectFile)}"); var outputs = new Dictionary <string, ITaskItem[]>(); var props = new Dictionary <string, string> { { "DesignTimeBuild", "true" }, { "BuildProjectReferences", "false" }, { "_ResolveReferenceDependencies", "true" }, { "SolutionDir", solutionDirectory }, { "ProvideCommandLineInvocation", "true" }, { "SkipCompilerExecution", "true" } }; /*bool fullFramework = true; * * using (var textReader = XmlReader.Create(projectFile)) * { * if (textReader.ReadToFollowing("Project")) * { * fullFramework = textReader.GetAttribute("Sdk") == null; * } * }*/ var document = XDocument.Load(projectFile); var projectReferences = document.Descendants("ProjectReference").Select(e => e.Attribute("Include").Value).ToList(); if (targetFramework == null) { var frameworks = await GetTargetFrameworks(projectFile); targetFramework = frameworks.FirstOrDefault(); if (targetFramework != null) { Console.WriteLine($"Automatically selecting {targetFramework} as TargetFramework"); props.Add("TargetFramework", targetFramework); } } else { Console.WriteLine($"Manually selecting {targetFramework} as TargetFramework"); } if (_buildEngine.BuildProjectFile(projectFile, new[] { "ResolveAssemblyReferences", "GetTargetPath", "Compile" }, props, outputs)) { Console.WriteLine("Project loaded successfully"); var metaDataReferences = new List <MetaDataReference>(); if (outputs.ContainsKey("ResolveAssemblyReferences")) { foreach (var item in outputs["ResolveAssemblyReferences"]) { var reference = new MetaDataReference { Assembly = item.ItemSpec }; foreach (string metaData in item.MetadataNames) { var metaDataObj = new ProjectTaskMetaData { Name = metaData.Replace("\0", ""), Value = item.GetMetadata(metaData).Replace("\0", "") }; reference.MetaData.Add(metaDataObj); } metaDataReferences.Add(reference); } } string targetPath = null; if (outputs.TryGetValue("GetTargetPath", out var targetPathOutput) && targetPathOutput.Length > 0) { targetPath = targetPathOutput[0].ItemSpec; } return(new MsBuildProjectInformation { MetaDataReferences = metaDataReferences, ProjectReferences = projectReferences, TargetPath = targetPath }); } else { Console.WriteLine("Project load failed."); return(null); } }
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, int round) => buildEngine.BuildProjectFile(projectFilePath, null, null, null);
public bool BuildProjectFile(string projectFileName, string[] targetNames, System.Collections.IDictionary globalProperties, System.Collections.IDictionary targetOutputs) { return(_buildEngine.BuildProjectFile(projectFileName, targetNames, globalProperties, targetOutputs)); }
/// <inheritdoc cref="IBuildEngine.BuildProjectFile"/> public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => _buildEngine.BuildProjectFile(projectFileName, targetNames, globalProperties, targetOutputs);