示例#1
0
        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());
        }
示例#2
0
        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");
                }
            }
        }
示例#3
0
        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);
                }
            }
        }
示例#4
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");
        }