コード例 #1
0
ファイル: PackTests.cs プロジェクト: ericstj/cli
        public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed()
        {
            var root = Temp.CreateDirectory();

            var testLibDir = root.CreateDirectory("TestLibrary");
            var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");

            CopyProjectToTempDir(sourceTestLibDir, testLibDir);

            var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin2"));
            var testProject = GetProjectPath(testLibDir);
            var buildCommand = new PackCommand(testProject, output: outputDir.FullName);
            var result = buildCommand.Execute();
            result.Should().Pass();

            outputDir.Should().Exist();
            outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
        }
コード例 #2
0
ファイル: PublishTests.cs プロジェクト: akrisiun/dotnet-cli
        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");
        }
コード例 #3
0
        public void RefsPublishTest()
        {
            // create unique directories in the 'temp' folder
            var root = Temp.CreateDirectory();

            var testAppDir = root.CreateDirectory("TestAppCompilationContext");
            var testLibDir = root.CreateDirectory("TestLibrary");

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

            var testProject = GetProjectPath(testAppDir);
            var publishCommand = new PublishCommand(testProject);
            publishCommand.Execute().Should().Pass();

            publishCommand.GetOutputDirectory().Should().HaveFile("TestAppCompilationContext.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");
        }
コード例 #4
0
ファイル: PublishPortableTests.cs プロジェクト: krwq/cli
        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");
        }
コード例 #5
0
        public void PackageReferenceWithResourcesTest()
        {
            var testInstance = TestAssetsManager.CreateTestInstance("ResourcesTests")
                                                .WithLockFiles();

            var projectRoot = Path.Combine(testInstance.TestRoot, "TestApp");

            var cmd = new BuildCommand(projectRoot);
            var result = cmd.Execute();
            result.Should().Pass();

            var outputDir = new DirectoryInfo(Path.Combine(projectRoot, "bin", "Debug", "netcoreapp1.0"));

            outputDir.Should().HaveFile("TestLibraryWithResources.dll");
            outputDir.Sub("fr").Should().HaveFile("TestLibraryWithResources.resources.dll");

            var depsJson = JObject.Parse(File.ReadAllText(Path.Combine(outputDir.FullName, $"{Path.GetFileNameWithoutExtension(cmd.GetOutputExecutableName())}.deps.json")));

            foreach (var library in new[] { Tuple.Create("Microsoft.Data.OData", "5.6.4"), Tuple.Create("TestLibraryWithResources", "1.0.0") })
            {
                var resources = depsJson["targets"][".NETCoreApp,Version=v1.0"][library.Item1 + "/" + library.Item2]["resources"];

                resources.Should().NotBeNull();

                foreach (var item in resources.Children<JProperty>())
                {
                    var locale = item.Value["locale"];
                    locale.Should().NotBeNull();

                    item.Name.Should().EndWith($"{locale}/{library.Item1}.resources.dll");
                }
            }
        }
コード例 #6
0
ファイル: PackTests.cs プロジェクト: akrisiun/dotnet-cli
        public void HasServiceableFlagWhenArgumentPassed()
        {
            var root = Temp.CreateDirectory();

            var testLibDir = root.CreateDirectory("TestLibrary");
            var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");

            CopyProjectToTempDir(sourceTestLibDir, testLibDir);

            var testProject = GetProjectPath(testLibDir);
            var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: true);
            var result = packCommand.Execute();
            result.Should().Pass();

            var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Debug"));
            outputDir.Should().Exist();
            outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });

            var outputPackage = Path.Combine(outputDir.FullName, "TestLibrary.1.0.0.nupkg");
            var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
            zip.Entries.Should().Contain(e => e.FullName == "TestLibrary.nuspec");

            var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibrary.nuspec").Open());
            var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
            var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable");
            Assert.Equal("true", node.Value);
        }
コード例 #7
0
ファイル: CompilerTests.cs プロジェクト: akrisiun/dotnet-cli
        public void CopyToOutputFilesAreCopied()
        {
            var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp")
                                                .WithLockFiles()
                                                .WithBuildArtifacts();

            var root = testInstance.TestRoot;

            // run compile
            var outputDir = Path.Combine(root, "bin");
            var testProject = ProjectUtils.GetProjectJson(root, "EndToEndTestApp");
            var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
            var result = buildCommand.ExecuteWithCapturedOutput();
            result.Should().Pass();

            var outputDirInfo = new DirectoryInfo(Path.Combine(outputDir, "copy"));
            outputDirInfo.Should().HaveFile("file.txt");
            outputDirInfo.Should().NotHaveFile("fileex.txt");
        }
コード例 #8
0
ファイル: CompilerTests.cs プロジェクト: akrisiun/dotnet-cli
        public void EmbeddedResourcesAreCopied()
        {
            var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp")
                                                .WithLockFiles()
                                                .WithBuildArtifacts();

            var root = testInstance.TestRoot;

            // run compile
            var outputDir = Path.Combine(root, "bin");
            var testProject = ProjectUtils.GetProjectJson(root, "EndToEndTestApp");
            var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
            var result = buildCommand.ExecuteWithCapturedOutput();
            result.Should().Pass();

            var objDirInfo = new DirectoryInfo(Path.Combine(root, "obj", "Debug", DefaultFramework));
            objDirInfo.Should().HaveFile("EndToEndTestApp.resource1.resources");
            objDirInfo.Should().HaveFile("myresource.resources");
            objDirInfo.Should().HaveFile("EndToEndTestApp.defaultresource.resources");
        }
コード例 #9
0
        public void It_builds_projects_with_xmlDoc_and_spaces_in_the_path()
        {
            var testInstance = TestAssetsManager
                .CreateTestInstance("TestLibraryWithXmlDoc", identifier: "With Space")
                .WithLockFiles();

            testInstance.TestRoot.Should().Contain(" ");

            var output = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "output"));

            new BuildCommand("", output: output.FullName, framework: DefaultLibraryFramework)
                .WithWorkingDirectory(testInstance.TestRoot)
                .ExecuteWithCapturedOutput()
                .Should()
                .Pass();

            output.Should().HaveFiles(new[]
            {
                "TestLibraryWithXmlDoc.dll",
                "TestLibraryWithXmlDoc.xml"
            });
        }