/// <summary> /// Executes package restore and executes build using the test solution. /// </summary> /// <param name="targetsToBuild">The targets to build. If not specified, the project's default target will be invoked.</param> /// <param name="properties">Build properties to pass to MSBuild.</param> /// <param name="scenarioName">The name of the scenario to build. If omitted, it will be the name of the calling method.</param> public static async Task <BuildResultAndLogs> RestoreAndExecuteAsync(string targetToBuild = null, IDictionary <string, string> properties = null, ITestOutputHelper testLogger = null, [CallerMemberName] string scenarioName = null) { var projectFullPath = Assets.GetScenarioSolutionPath(scenarioName); var projectDirectory = Path.GetDirectoryName(projectFullPath); await NuGetHelper.RestorePackagesAsync(projectDirectory); var result = await MSBuild.ExecuteAsync(projectFullPath, targetToBuild, properties, testLogger); return(result); }
/// <summary> /// Executes package restore and builds the test solution, asserting build failure. /// </summary> /// <param name="scenarioName">The name of the scenario to build. If omitted, it will be the name of the calling method.</param> /// <param name="projectName">The leaf name of the project to be built or rebuilt.</param> /// <param name="properties">Build properties to pass to MSBuild.</param> public static async Task RestoreAndFailBuildAsync([CallerMemberName] string scenarioName = null, string projectName = null, IDictionary <string, string> properties = null, ITestOutputHelper testLogger = null) { var projectFullPath = Assets.GetScenarioSolutionPath(scenarioName); var projectDirectory = Path.GetDirectoryName(projectFullPath); await NuGetHelper.RestorePackagesAsync(projectDirectory); var result = await MSBuild.RebuildAsync(projectFullPath, projectName, properties, testLogger); result.AssertUnsuccessfulBuild(); }
/// <summary> /// Executes package restore and builds the test solution. /// </summary> /// <param name="scenarioName">The name of the scenario to build. If omitted, it will be the name of the calling method.</param> /// <param name="projectName">The leaf name of the project to be built or rebuilt.</param> /// <param name="properties">Build properties to pass to MSBuild.</param> /// <returns>A collection of the built packages.</returns> public static async Task <IReadOnlyCollection <IPackage> > RestoreAndBuildPackagesAsync([CallerMemberName] string scenarioName = null, string projectName = null, IDictionary <string, string> properties = null) { var projectFullPath = Assets.GetScenarioSolutionPath(scenarioName); var projectDirectory = Path.GetDirectoryName(projectFullPath); await NuGetHelper.RestorePackagesAsync(projectDirectory); var result = await MSBuild.RebuildAsync(projectFullPath, projectName, properties); result.AssertSuccessfulBuild(); return(NuPkg.GetPackages(projectDirectory)); }