Exemple #1
0
        public void BuildingAPortableProjectProducesDepsFile()
        {
            var testInstance = TestAssetsManager.CreateTestInstance("BuildTestPortableProject")
                .WithLockFiles();

            var result = new BuildCommand(
                projectPath: testInstance.TestRoot,
                forcePortable: true)
                .ExecuteWithCapturedOutput();

            result.Should().Pass();

            var outputBase = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "bin", "Debug"));

            var netstandardappOutput = outputBase.Sub("netstandardapp1.5");

            netstandardappOutput.Should()
                .Exist().And
                .HaveFiles(new[]
                {
                    "BuildTestPortableProject.deps",
                    "BuildTestPortableProject.deps.json",
                    "BuildTestPortableProject.dll",
                    "BuildTestPortableProject.pdb"
                });
        }
        private static void BuildAndTest(string testRoot)
        {
            string appName = Path.GetFileName(testRoot);


            var result = new BuildCommand(
                projectPath: testRoot)
                .ExecuteWithCapturedOutput();

            result.Should().Pass();

            var outputBase = new DirectoryInfo(Path.Combine(testRoot, "bin", "Debug"));

            var netcoreAppOutput = outputBase.Sub("netcoreapp1.0");

            netcoreAppOutput.Should()
                .Exist().And
                .OnlyHaveFiles(new[]
                {
                    $"{appName}.deps.json",
                    $"{appName}.dll",
                    $"{appName}.pdb",
                    $"{appName}.runtimeconfig.json",
                    $"{appName}.runtimeconfig.dev.json"
                });
        }
        private DirectoryInfo Build(TestInstance testInstance)
        {
            var result = new BuildCommand(
                projectPath: Path.Combine(testInstance.TestRoot, "PortableApp"))
                .ExecuteWithCapturedOutput();

            result.Should().Pass();

            var outputBase = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "PortableApp", "bin", "Debug"));

            return outputBase.Sub("netstandard1.5");
        }
Exemple #4
0
        public DirectoryInfo Build(TestInstance testInstance)
        {
            var projectPath = Path.Combine(testInstance.TestRoot, "StandaloneApp");

            var result = new BuildCommand(
                projectPath: projectPath)
                .ExecuteWithCapturedOutput();

            var contexts = ProjectContext.CreateContextForEachFramework(
                projectPath,
                null,
                PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());

            var runtime = contexts.FirstOrDefault(c => !string.IsNullOrEmpty(c.RuntimeIdentifier))?.RuntimeIdentifier;

            result.Should().Pass();

            var outputBase = new DirectoryInfo(
                Path.Combine(testInstance.TestRoot, "StandaloneApp", "bin", "Debug", "netstandardapp1.5"));

            return outputBase.Sub(runtime);
        }
        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");
                }
            }
        }