public void PublishOptionsTest(string framework, string runtime, string config, string outputDir) { // create unique directories in the 'temp' folder var root = Temp.CreateDirectory(); var testAppDir = root.CreateDirectory("TestApp"); var testLibDir = root.CreateDirectory("TestLibrary"); //copy projects to the temp dir CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestApp"), testAppDir); CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibrary"), testLibDir); RunRestore(testAppDir.Path); RunRestore(testLibDir.Path); // run publish outputDir = string.IsNullOrEmpty(outputDir) ? "" : Path.Combine(root.Path, outputDir); var testProject = GetProjectPath(testAppDir); var publishCommand = new PublishCommand(testProject, output: outputDir); publishCommand.Execute().Should().Pass(); // verify the output executable generated var publishedDir = publishCommand.GetOutputDirectory(); var outputExe = publishCommand.GetOutputExecutable(); var outputPdb = Path.ChangeExtension(outputExe, "pdb"); // lets make sure that the output exe is runnable var outputExePath = Path.Combine(publishedDir.FullName, publishCommand.GetOutputExecutable()); var command = new TestCommand(outputExePath); command.Execute("").Should().ExitWith(100); // the pdb should also be published publishedDir.Should().HaveFile(outputPdb); }
public void PublishOptionsTest(string testIdentifier, string framework, string runtime, string config, string outputDir) { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary", identifier: testIdentifier) .WithLockFiles() .WithBuildArtifacts(); string testRoot = _getProjectJson(instance.TestRoot, "TestApp"); outputDir = string.IsNullOrEmpty(outputDir) ? "" : Path.Combine(instance.TestRoot, outputDir); var publishCommand = new PublishCommand(testRoot, output: outputDir); publishCommand.Execute().Should().Pass(); // verify the output executable generated var publishedDir = publishCommand.GetOutputDirectory(); var outputExe = publishCommand.GetOutputExecutable(); var outputPdb = Path.ChangeExtension(outputExe, "pdb"); // lets make sure that the output exe is runnable var outputExePath = Path.Combine(publishedDir.FullName, publishCommand.GetOutputExecutable()); var command = new TestCommand(outputExePath); command.Execute("").Should().ExitWith(100); // the pdb should also be published publishedDir.Should().HaveFile(outputPdb); }
public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool forceRunnable) { var runnable = forceRunnable || string.IsNullOrEmpty(runtime) || (DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier().Contains(runtime)); var testInstance = GetTestInstance() .WithLockFiles(); // Prevent path too long failure on CI machines var projectPath = Path.Combine(testInstance.TestRoot, project); var publishCommand = new PublishCommand(projectPath, runtime: runtime, output: Path.Combine(projectPath, "out")); var result = await publishCommand.ExecuteAsync(); result.Should().Pass(); // Test the output var outputDir = publishCommand.GetOutputDirectory(portable: false); outputDir.Should().HaveFile(libuvName); outputDir.Should().HaveFile(publishCommand.GetOutputExecutable()); Task exec = null; if (runnable) { var outputExePath = Path.Combine(outputDir.FullName, publishCommand.GetOutputExecutable()); var command = new TestCommand(outputExePath); try { exec = command.ExecuteAsync(url); NetworkHelper.IsServerUp(url).Should().BeTrue($"Unable to connect to kestrel server - {project} @ {url}"); NetworkHelper.TestGetRequest(url, url); } finally { command.KillTree(); } if (exec != null) { await exec; } } }
public async Task DesktopApp_WithRuntimes_PublishedSplitPackageAssets() { var testInstance = _testAssetsManager.CreateTestInstance("DesktopAppWithRuntimes") .WithLockFiles(); var publishCommand = new PublishCommand(testInstance.TestRoot, runtime: "win7-x64"); var result = await publishCommand.ExecuteAsync(); result.Should().Pass(); // Test the output var outputDir = publishCommand.GetOutputDirectory(portable: false); System.Console.WriteLine(outputDir); outputDir.Should().HaveFile("api-ms-win-core-file-l1-1-0.dll"); outputDir.Should().HaveFile(publishCommand.GetOutputExecutable()); }
public async Task DesktopApp_WithDependencyOnNativePackage_ProducesExpectedOutput(string runtime, string expectedOutputName) { if (string.IsNullOrEmpty(expectedOutputName)) { expectedOutputName = $"the-win-{RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()}-version.txt"; } var testInstance = _testAssetsManager.CreateTestInstance("DesktopAppWithNativeDep") .WithLockFiles(); var publishCommand = new PublishCommand(testInstance.TestRoot, runtime: runtime); var result = await publishCommand.ExecuteAsync(); result.Should().Pass(); // Test the output var outputDir = publishCommand.GetOutputDirectory(portable: false); outputDir.Should().HaveFile(expectedOutputName); outputDir.Should().HaveFile(publishCommand.GetOutputExecutable()); }