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 void PublishTestAppWithContentPackage() { var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithContentPackage") .WithLockFiles(); var publishCommand = new PublishCommand(testInstance.TestRoot); var publishResult = publishCommand.Execute(); publishResult.Should().Pass(); var publishDir = publishCommand.GetOutputDirectory(portable: false); publishDir.Should().HaveFiles(new[] { $"AppWithContentPackage{publishCommand.GetExecutableExtension()}", "AppWithContentPackage.dll", "AppWithContentPackage.deps.json" }); // these files come from the contentFiles of the SharedContentA dependency publishDir .Sub("scripts") .Should() .Exist() .And .HaveFile("run.cmd"); publishDir .Should() .HaveFile("config.xml"); }
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 PublishExcludesBuildDependencies() { var testInstance = TestAssetsManager.CreateTestInstance("AppWithDirectDependencyAndTypeBuild") .WithLockFiles(); var publishCommand = new PublishCommand(testInstance.TestRoot); var publishResult = publishCommand.Execute(); publishResult.Should().Pass(); var publishDir = publishCommand.GetOutputDirectory(portable: true); publishDir.Should().HaveFiles(new[] { // This one is directly referenced "xunit.core.dll" }); // But these are brought in only by the type:build dependency, and should not be published publishDir.Should().NotHaveFiles(new [] { "xunit.assert.dll" }); // Check the deps file var reader = new DependencyContextJsonReader(); DependencyContext context; using (var file = File.OpenRead(Path.Combine(publishDir.FullName, "AppWithDirectDependencyAndTypeBuild.deps.json"))) { context = reader.Read(file); } context.RuntimeLibraries.Should().NotContain(l => string.Equals(l.Name, "xunit.assert")); context.CompileLibraries.Should().NotContain(l => string.Equals(l.Name, "xunit.assert")); }
public void FailWhenNoRestoreTest() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary"); string testProject = _getProjectJson(instance.TestRoot, "TestApp"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Fail(); }
private DirectoryInfo Publish(TestInstance testInstance) { var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, "StandaloneApp")); var publishResult = publishCommand.Execute(); publishResult.Should().Pass(); return publishCommand.GetOutputDirectory(portable: false); }
public void CompilationFailedTest() { TestInstance instance = TestAssetsManager.CreateTestInstance("CompileFail") .WithLockFiles(); var testProject = _getProjectJson(instance.TestRoot, "CompileFail"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Fail(); }
public void ProjectWithContentsTest() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithContents") .WithLockFiles() .WithBuildArtifacts(); var testProject = _getProjectJson(instance.TestRoot, "TestAppWithContents"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("testcontentfile.txt"); }
public void PublishTestFullClr() { var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppFullClr"); var testProject = Path.Combine(testProjectPath, "project.json"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); var result = TestExecutable(publishCommand.GetOutputDirectory().FullName, publishCommand.GetOutputExecutable(), string.Empty); ValidateRuntimeLibrariesFullClr(result, "TestAppFullClr"); ValidateCompilationLibrariesFullClr(result, "TestAppFullClr"); }
private void Setup(string project, ref string projectDir, ref string buildDir, ref string publishDir) { projectDir = Path.Combine(_testInstance.TestRoot, project); buildDir = Path.Combine(projectDir, _buildRelativePath); publishDir = Path.Combine(projectDir, "publish"); var buildCommand = new BuildCommand(projectDir, framework: Framework, runtime: _Runtime); buildCommand.Execute().Should().Pass(); var publishCommand = new PublishCommand(projectDir, output: publishDir, framework: Framework, runtime: _Runtime); publishCommand.Execute().Should().Pass(); }
public void CompilationFailedTest() { var testDir = Temp.CreateDirectory(); var compileFailDir = Path.Combine(_testProjectsRoot, "CompileFail"); CopyProjectToTempDir(compileFailDir, testDir); var testProject = GetProjectPath(testDir); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Fail(); }
public void BeforeRestoreTest() { // 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); var testProject = GetProjectPath(testAppDir); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Fail(); }
public void PublishTest(string appname, bool portable, bool checkCompilation) { var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", appname); var testProject = Path.Combine(testProjectPath, "project.json"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); var exeName = portable ? publishCommand.GetPortableOutputName() : publishCommand.GetOutputExecutable(); var result = TestExecutable(publishCommand.GetOutputDirectory(portable).FullName, exeName, string.Empty); ValidateRuntimeLibraries(result, appname); if (checkCompilation) { ValidateCompilationLibraries(result, appname); } }
public void PortableAppWithIntentionalDowngradePublishesDowngradedManagedCode() { var testInstance = TestAssetsManager.CreateTestInstance("PortableTests") .WithLockFiles(); var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, "PortableAppWithIntentionalManagedDowngrade")); var publishResult = publishCommand.Execute(); publishResult.Should().Pass(); var publishDir = publishCommand.GetOutputDirectory(portable: true); publishDir.Should().HaveFiles(new[] { "PortableAppWithIntentionalManagedDowngrade.dll", "PortableAppWithIntentionalManagedDowngrade.deps.json", "System.Linq.dll" }); }
public void PublishTestAppWithReferencesToResources() { var testInstance = TestAssetsManager.CreateTestInstance("ResourcesTests") .WithLockFiles(); var projectRoot = Path.Combine(testInstance.TestRoot, "TestApp"); var publishCommand = new PublishCommand(projectRoot); var publishResult = publishCommand.Execute(); publishResult.Should().Pass(); var publishDir = publishCommand.GetOutputDirectory(portable: true); publishDir.Should().HaveFiles(new[] { "TestApp.dll", "TestApp.deps.json" }); foreach (var culture in new[] { "de", "es", "fr", "it", "ja", "ko", "ru", "zh-Hans", "zh-Hant" }) { var cultureDir = publishDir.Sub(culture); // Provided by packages cultureDir.Should().HaveFiles(new[] { "Microsoft.Data.Edm.resources.dll", "Microsoft.Data.OData.resources.dll", "System.Spatial.resources.dll" }); // Check for the project-to-project one if (culture == "fr") { cultureDir.Should().HaveFile("TestLibraryWithResources.resources.dll"); } } }
public void StandaloneAppHasResourceDependency() { // WindowsAzure.Services brings in en, zh etc. resource DLLs. // The host has to be able to find these assemblies from the deps file // from the standalone app base under the ietf tag directory. var testName = "TestAppWithResourceDeps"; TestInstance instance = TestAssetsManager .CreateTestInstance(testName) .WithLockFiles() .WithBuildArtifacts(); var publishCommand = new PublishCommand(instance.TestRoot); publishCommand.Execute().Should().Pass(); var publishedDir = publishCommand.GetOutputDirectory(); var extension = publishCommand.GetExecutableExtension(); var outputExe = testName + extension; publishedDir.Should().HaveFiles(new[] { $"{testName}.dll", outputExe }); var command = new TestCommand(Path.Combine(publishedDir.FullName, outputExe)); command.Execute("").Should().ExitWith(0); }
public void PublishFailsWhenProjectNotBuiltAndNoBuildFlagSet() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppCompilationContext") .WithLockFiles(); var testProject = _getProjectJson(instance.TestRoot, "TestApp"); var publishCommand = new PublishCommand(testProject, noBuild: true); publishCommand.Execute().Should().Fail(); }
public void TestLibraryBindingRedirectGeneration() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestBindingRedirectGeneration") .WithLockFiles() .WithBuildArtifacts(); var lesserTestProject = _getProjectJson(instance.TestRoot, "TestLibraryLesser"); var publishCommand = new PublishCommand(lesserTestProject, "net451"); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.exe"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.pdb"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.exe.config"); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibraryLesser.deps.json"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); publishCommand.GetOutputDirectory().Delete(true); publishCommand = new PublishCommand(lesserTestProject, "netcoreapp1.0", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier()); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.pdb"); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibraryLesser.dll.config"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.deps.json"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); }
public void RefsPublishTest() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppCompilationContext") .WithLockFiles() .WithBuildArtifacts(); var testProject = _getProjectJson(instance.TestRoot, "TestApp"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestApp.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibrary.dll"); var refsDirectory = new DirectoryInfo(Path.Combine(publishCommand.GetOutputDirectory().FullName, "refs")); // Should have compilation time assemblies refsDirectory.Should().HaveFile("System.IO.dll"); // Libraries in which lib==ref should be deduped refsDirectory.Should().NotHaveFile("TestLibrary.dll"); }
public void PublishesWhenPrebuildWithBuildBasePath() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary") .WithLockFiles(); string basePath = Path.Combine(instance.TestRoot, "build"); string testProject = _getProjectJson(instance.TestRoot, "TestApp"); var buildCommand = new BuildCommand(testProject, buildBasePath: basePath); buildCommand.Execute().Should().Pass(); var publishCommand = new PublishCommand(testProject, buildBasePath: basePath, noBuild: true); publishCommand.Execute().Should().Pass(); }
public void PublishedLibraryWithoutRIDShouldFail() { TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine("TestAppWithLibrary")) .WithLockFiles(); var testProject = _getProjectJson(instance.TestRoot, "TestLibrary"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Fail(); }
public void ProjectWithPublishOptionsTest() { var instance = TestAssetsManager.CreateTestInstance("EndToEndTestApp") .WithLockFiles() .WithBuildArtifacts(); var testProject = _getProjectJson(instance.TestRoot, "EndToEndTestApp"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("testpublishfile.txt"); publishCommand.GetOutputDirectory().Should().HaveFile("publishfiles/anotherpublishfile.txt"); }
public void CrossPublishingSucceedsAndHasExpectedArtifacts() { TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine("PortableTests")); var testProject = Path.Combine(instance.TestRoot, "StandaloneApp", "project.json"); var workingDirectory = Path.GetDirectoryName(testProject); var testNugetCache = Path.Combine(workingDirectory, "packages_cross_publish_test"); var restoreCommand = new RestoreCommand(); restoreCommand.WorkingDirectory = workingDirectory; restoreCommand.Environment["NUGET_PACKAGES"] = testNugetCache; restoreCommand.Execute().Should().Pass(); foreach (var testData in CrossPublishTestData) { var buildCommand = new BuildCommand(testProject, runtime: testData.Rid); buildCommand.WorkingDirectory = Path.GetDirectoryName(testProject); buildCommand.Environment["NUGET_PACKAGES"] = testNugetCache; buildCommand.Execute().Should().Pass(); var publishCommand = new PublishCommand(testProject, runtime: testData.Rid, noBuild: true); publishCommand.Environment["NUGET_PACKAGES"] = testNugetCache; publishCommand.WorkingDirectory = Path.GetDirectoryName(testProject); publishCommand.Execute().Should().Pass(); var publishedDir = publishCommand.GetOutputDirectory(); publishedDir.Should().HaveFile("StandaloneApp"+ testData.HostExtension); foreach (var artifact in testData.ExpectedArtifacts) { publishedDir.Should().HaveFile(artifact); } } }
public void LibraryPublishTest() { // create unique directories in the 'temp' folder var root = Temp.CreateDirectory(); var testLibDir = root.CreateDirectory("TestLibrary"); //copy projects to the temp dir CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibrary"), testLibDir); var testProject = GetProjectPath(testLibDir); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibrary.exe"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibrary.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibrary.pdb"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("System.Runtime.dll"); }
public void PublishSucceedsWhenProjectPreviouslyCompiledAndNoBuildFlagSet() { TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppCompilationContext") .WithLockFiles() .WithBuildArtifacts(); var testProject = _getProjectJson(instance.TestRoot, "TestApp"); var publishCommand = new PublishCommand(testProject, noBuild: true); publishCommand.Execute().Should().Pass(); }
public void TestDotnetPublish() { var publishCommand = new PublishCommand(TestProject, output: OutputDirectory); publishCommand.Execute().Should().Pass(); TestOutputExecutable(OutputDirectory, publishCommand.GetOutputExecutable()); }
public void LibraryPublishTest() { TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine("TestAppWithLibrary")) .WithLockFiles() .WithBuildArtifacts(); var testProject = _getProjectJson(instance.TestRoot, "TestLibrary"); var publishCommand = new PublishCommand(testProject); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibrary.exe"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibrary.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibrary.pdb"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("System.Runtime.dll"); }
public void RefsPublishTest() { TestInstance instance = TestAssetsManager.CreateTestInstance("PortableTests") .WithLockFiles(); var publishCommand = new PublishCommand(Path.Combine(instance.TestRoot, "PortableAppCompilationContext")); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory(true).Should().HaveFile("PortableAppCompilationContext.dll"); var refsDirectory = new DirectoryInfo(Path.Combine(publishCommand.GetOutputDirectory(true).FullName, "refs")); // Should have compilation time assemblies refsDirectory.Should().HaveFile("System.IO.dll"); // Libraries in which lib==ref should be deduped refsDirectory.Should().NotHaveFile("PortableAppCompilationContext.dll"); }
public void PublishAppWithOutputAssemblyName() { TestInstance instance = TestAssetsManager .CreateTestInstance("AppWithOutputAssemblyName") .WithLockFiles() .WithBuildArtifacts(); var testRoot = _getProjectJson(instance.TestRoot, "AppWithOutputAssemblyName"); var publishCommand = new PublishCommand(testRoot, output: testRoot); publishCommand.Execute().Should().Pass(); var publishedDir = publishCommand.GetOutputDirectory(); var extension = publishCommand.GetExecutableExtension(); var outputExe = "MyApp" + extension; publishedDir.Should().HaveFiles(new[] { "MyApp.dll", outputExe }); publishedDir.Should().NotHaveFile("AppWithOutputAssemblyName" + extension); publishedDir.Should().NotHaveFile("AppWithOutputAssemblyName.dll"); var command = new TestCommand(Path.Combine(publishedDir.FullName, outputExe)); command.Execute("").Should().ExitWith(0); }
public void TestLibraryBindingRedirectGeneration() { // Set up Test Staging in Temporary Directory var root = Temp.CreateDirectory(); root.CopyDirectory(Path.Combine(_testProjectsRoot, "TestBindingRedirectGeneration")); var testProjectsRootDir = Path.Combine(root.Path, "TestBindingRedirectGeneration"); var greaterTestLibDir = Path.Combine(testProjectsRootDir, "TestLibraryGreater"); var lesserTestLibDir = Path.Combine(testProjectsRootDir, "TestLibraryLesser"); var lesserTestProject = Path.Combine(lesserTestLibDir, "project.json"); var publishCommand = new PublishCommand(lesserTestProject, "net451"); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.pdb"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll.config"); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibraryLesser.deps"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); publishCommand.GetOutputDirectory().Delete(true); publishCommand = new PublishCommand(lesserTestProject, "dnxcore50", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier()); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.pdb"); publishCommand.GetOutputDirectory().Should().NotHaveFile("TestLibraryLesser.dll.config"); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.deps"); // dependencies should also be copied publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); }