Example #1
0
        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);

            RunRestore(testLibDir.Path);

            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");
        }
Example #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");
                }
            }
        }
Example #3
0
        public void TestLibraryPublishTest()
        {
            // create unique directories in the 'temp' folder
            var root       = Temp.CreateDirectory();
            var testLibDir = root.CreateDirectory("TestLibraryWithRunner");

            //copy projects to the temp dir
            CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibraryWithRunner"), testLibDir);

            RunRestore(testLibDir.Path);

            var testProject    = GetProjectPath(testLibDir);
            var publishCommand = new PublishCommand(testProject);

            publishCommand.Execute().Should().Pass();

            publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryWithRunner.dll");
            publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryWithRunner.pdb");
            publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryWithRunner.deps");
            publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryWithRunner.dll.config");
            // dependencies should also be copied
            publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll");
        }
Example #4
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);
                }
            }
        }
Example #5
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");
        }