public static void GenerateHtmlTestReports() { if (NUnitToHtmlTransformation == null) { return; } foreach (var projectWithPlatform in BuildConfig.Config.ProjectsByPlatform) { foreach (var project in projectWithPlatform.Value) { var output = BuildConfig.ComputeOutputPath("reports/html", project); var testPath = UnitTestActions.ComputeProjectUnitTestPath(project).FullPath; var pattern = testPath + "/*.nunit2.xml"; foreach (var file in Context.Globber.GetFiles(pattern)) { Context.CreateDirectory(output); var outputHtmlFile = output.CombineWithFilePath(file.GetFilenameWithoutExtension() + ".html") .MakeAbsolute(Context.Environment); Context.Log.Information("Creating report file " + Context.Environment.WorkingDirectory.GetRelativePath(outputHtmlFile)); Context.XmlTransform(NUnitToHtmlTransformation, file, outputHtmlFile, new XmlTransformationSettings { ConformanceLevel = ConformanceLevel.Fragment, Indent = true, NewLineHandling = NewLineHandling.None }); } } } }
public static DirectoryPath ComputeProjectUnitTestPath(ParsedProject project) { return(BuildConfig.ComputeOutputPath("tests", project)); }
/// <summary> /// Thanks to NuGet being an extension of VisualStudio instead of a proper standalone /// tool (just look at the tight binding of 'nuget pack .xxproj' into MSBuild internals /// and the massive amount of code just to manage that stuff), we cannot build NuGet /// packages from existing binaries by just looking at the project and nuspec files. /// Therefore we preemtively produce nuget packages as soon as the compiler finished /// building the project (and before any testing has been done). We then copy the /// NuGet package into a safe place before eventually pushing it to a server or achiving /// the files by other means. /// </summary> /// <param name="project"></param> public static void ProduceNuGetPackage(ParsedProject project) { var nuspec = project.ProjectFile.ChangeExtension(".nuspec"); if (!Context.FileExists(nuspec)) { Context.Log.Verbose("Skipping package as there is no *.nuspec file for project " + BuildConfig.AsRelativePath(project.ProjectFile)); return; } var settings = new NuGetXPackSettings(PackSettings); if (PackSettingsCustomisation != null) { settings = PackSettingsCustomisation.Invoke(settings, project); } var nugetSettings = new NuGetPackSettings(); XBuildHelper.ApplyToolSettings(nugetSettings, settings); nugetSettings.Verbosity = settings.Verbosity; nugetSettings.Symbols = settings.Symbols.GetValueOrDefault(); nugetSettings.IncludeReferencedProjects = settings.IncludeReferencedProjects.GetValueOrDefault(); nugetSettings.Properties = new Dictionary <string, string>(settings.Properties); nugetSettings.ArgumentCustomization = settings.ArgumentCustomization; if (NuGetPackSettingsCustomisation != null) { nugetSettings = NuGetPackSettingsCustomisation.Invoke(nugetSettings, project); if (nugetSettings.Properties == null) { nugetSettings.Properties = new Dictionary <string, string>(); } } var targetPath = BuildConfig.ComputeOutputPath("packages", project); Context.CreateDirectory(targetPath); nugetSettings.WorkingDirectory = targetPath; nugetSettings.Properties["Configuration"] = BuildConfig.Configuration; nugetSettings.Properties["Platform"] = BuildConfig.ConvertPlatformTargetToString(project.Platform); if (!string.IsNullOrEmpty(Version)) { Context.Log.Information("Publishing package as version " + Version); nugetSettings.Properties["version"] = Version; nugetSettings.Version = Version; } if (settings.Tool.GetValueOrDefault()) { var argCustomization = nugetSettings.ArgumentCustomization; nugetSettings.ArgumentCustomization = args => { if (argCustomization != null) { args = argCustomization.Invoke(args); } args.Append("-Tool"); return(args); }; } Context.NuGetPack(project.ProjectFile, nugetSettings); var assembly = LoadZipAssembly(); if (assembly != null) { Context.Log.Information("Unzipping nuget package: " + targetPath.FullPath + "/*.nupkg"); foreach (var file in Context.Globber.GetFiles(targetPath.FullPath + "/*.nupkg")) { Context.Log.Information("Unzipping " + file); Unzip(file, targetPath, assembly); } } }
internal static DirectoryPath ComputeProjectBinPath(ParsedProject project) { return(BuildConfig.ComputeOutputPath("compiled", project)); }