コード例 #1
0
ファイル: DnuPackTests.cs プロジェクト: rajeevkb/dnx
        public void DnuPack_ClientProfile(DnxSdk sdk)
        {
            const string ProjectName = "ClientProfileProject";
            var projectStructure = new Dir
            {
                [ProjectName] = new Dir
                {
                    ["project.json"] = new JObject
                    {
                        ["frameworks"] = new JObject
                        {
                            ["net40-client"] = new JObject(),
                            ["net35-client"] = new JObject()
                        }
                    }
                },
                ["Output"] = new Dir()
            };

            var baseDir = TestUtils.GetTestFolder<DnuPackTests>(sdk);
            var projectDir = Path.Combine(baseDir, ProjectName);
            var outputDir = Path.Combine(baseDir, "Output");
            projectStructure.Save(baseDir);

            sdk.Dnu.Restore(projectDir).EnsureSuccess();
            var result = sdk.Dnu.Pack(projectDir, outputDir);

            Assert.Equal(0, result.ExitCode);
        }
コード例 #2
0
ファイル: Dir.cs プロジェクト: rajeevkb/dnx
        public void Load(string path)
        {
            var directory = new DirectoryInfo(path);

            foreach (var subDirectoryInfo in directory.EnumerateDirectories())
            {
                Dir subDirectory = new Dir(this);
                this[subDirectoryInfo.Name] = subDirectory;
                subDirectory.Load(Path.Combine(path, subDirectoryInfo.Name));
            }

            foreach (var file in directory.EnumerateFiles())
            {
                this[file.Name] = _readFile(file);
            }
        }
コード例 #3
0
ファイル: Dir.cs プロジェクト: rajeevkb/dnx
 public Dir(Dir parent)
 {
     _readFile = parent._readFile;
     _fileComparator = parent._fileComparator;
 }
コード例 #4
0
ファイル: Dir.cs プロジェクト: rajeevkb/dnx
        public DirDiff Diff(Dir other, bool compareContents = true)
        {
            var nodes1 = Flatten(compareContents);
            var nodes2 = other.Flatten(compareContents);

            return new DirDiff
            {
                ExtraEntries = nodes1.Keys.Except(nodes2.Keys),
                MissingEntries = nodes2.Keys.Except(nodes1.Keys),
                DifferentEntries = compareContents ? 
                    nodes1.Keys.Intersect(nodes2.Keys).Where(
                        entry => _fileComparator(nodes1[entry], nodes2[entry])) :
                        Enumerable.Empty<string>()

            };
        }
コード例 #5
0
ファイル: DnuPublishTests2.cs プロジェクト: rajeevkb/dnx
        public void GlobalJsonInProjectDir(DnxSdk sdk)
        {
            const string solutionName = "GlobalJsonInProjectDir";

            var solution = TestUtils.GetSolution<DnuPublishTests>(sdk, solutionName);
            var projectPath = Path.Combine(solution.RootPath, "Project");
            var outputPath = Path.Combine(solution.RootPath, "Output");

            var expectedOutputProjectJson = new JObject
            {
                ["dependencies"] = new JObject { },
                ["frameworks"] = new JObject
                {
                    ["dnx451"] = new JObject { },
                    ["dnxcore50"] = new JObject { }
                }
            };

            var expectedOutputGlobalJson = new JObject
            {
                ["sdk"] = new JObject
                {
                    ["version"] = "1.0.0-beta7"
                },
                ["projects"] = new JArray("src"),
                ["packages"] = "packages"
            };

            var expectedOutputLockFile = new JObject
            {
                ["locked"] = false,
                ["version"] = Constants.LockFileVersion,
                ["targets"] = new JObject
                {
                    ["DNX,Version=v4.5.1"] = new JObject { },
                    ["DNXCore,Version=v5.0"] = new JObject { },
                },
                ["libraries"] = new JObject { },
                ["projectFileDependencyGroups"] = new JObject
                {
                    [""] = new JArray(),
                    ["DNX,Version=v4.5.1"] = new JArray(),
                    ["DNXCore,Version=v5.0"] = new JArray()
                }
            };
            var expectedOutputStructure = new Dir
            {
                ["approot"] = new Dir
                {
                    [$"src/Project"] = new Dir
                    {
                        ["project.json"] = expectedOutputProjectJson,
                        ["project.lock.json"] = expectedOutputLockFile
                    },
                    [$"global.json"] = expectedOutputGlobalJson
                }
            };

            var result = sdk.Dnu.Publish(
                projectPath,
                outputPath);
            result.EnsureSuccess();

            var actualOutputStructure = new Dir(outputPath);
            DirAssert.Equal(expectedOutputStructure, actualOutputStructure);
        }