public async Task PublishingPrintsParseErrors(RuntimeFlavor flavor) { // Arrange var applicationPath = ApplicationPaths.GetTestAppDirectory("ApplicationWithParseErrors"); var indexPath = Path.Combine(applicationPath, "Views", "Home", "Index.cshtml"); var viewImportsPath = Path.Combine(applicationPath, "Views", "Home", "About.cshtml"); var expectedErrors = new[] { indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.", viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.", }; var testSink = new TestSink(); var deploymentParameters = ApplicationTestFixture.GetDeploymentParameters(applicationPath, flavor); var loggerFactory = new TestLoggerFactory(testSink, enabled: true); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { // Act await Assert.ThrowsAsync <Exception>(() => deployer.DeployAsync()); // Assert var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList(); foreach (var expectedError in expectedErrors) { Assert.Contains(logs, log => log.Contains(expectedError)); } } }
public void CrossPublishingWorks() { using (StartLog(out var loggerFactory)) { // Arrange var applicationName = nameof(SimpleApp); var applicationPath = ApplicationPaths.GetTestAppDirectory(applicationName); var deploymentParameters = ApplicationTestFixture.GetDeploymentParameters( applicationPath, applicationName, RuntimeFlavor.CoreClr); // Deploy for a rid that does not exist on the current platform. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { deploymentParameters.AdditionalPublishParameters = "-r debian-x64"; } else { deploymentParameters.AdditionalPublishParameters = "-r win7-x86"; } var deployer = new DotNetPublishDeployer(deploymentParameters, loggerFactory); // Act deployer.DotnetPublish(); // Act var expectedFile = Path.Combine( deploymentParameters.PublishedApplicationRootPath, $"{applicationName}.PrecompiledViews.dll"); Assert.True(File.Exists(expectedFile), $"Expected precompiled file {expectedFile} does not exist."); } }