Пример #1
0
        public void LibraryProject(ApplePlatform platform)
        {
            var project = "MyClassLibrary";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GetProjectPath(project, runtimeIdentifiers: string.Empty, platform: platform, out var appPath);

            Clean(project_path);
            var properties = GetDefaultProperties();

            DotNet.AssertPack(project_path, properties);

            var nupkg = Path.Combine(Path.GetDirectoryName(project_path) !, "bin", "Debug", project + ".1.0.0.nupkg");

            Assert.That(nupkg, Does.Exist, "nupkg existence");

            var archive = ZipFile.OpenRead(nupkg);
            var files   = archive.Entries.Select(v => v.FullName).ToHashSet();

            Assert.That(archive.Entries.Count, Is.EqualTo(5), "nupkg file count");
            Assert.That(files, Does.Contain(project + ".nuspec"), "nuspec");
            Assert.That(files, Does.Contain("_rels/.rels"), ".rels");
            Assert.That(files, Does.Contain("[Content_Types].xml"), "[Content_Types].xml");
            Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.dll"), $"{project}.dll");
            Assert.That(files, Has.Some.Matches <string> (v => v.StartsWith("package/services/metadata/core-properties/", StringComparison.Ordinal) && v.EndsWith(".psmdcp", StringComparison.Ordinal)), "psmdcp");
        }
Пример #2
0
        public void BindingFrameworksProject(ApplePlatform platform, bool noBindingEmbedding)
        {
            var project = "bindings-framework-test";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = Path.Combine(Configuration.RootPath, "tests", project, "dotnet", platform.AsString(), $"{project}.csproj");

            Clean(project_path);
            Configuration.CopyDotNetSupportingFiles(Path.GetDirectoryName(project_path));

            var tmpdir                 = Cache.CreateTemporaryDirectory();
            var outputPath             = Path.Combine(tmpdir, "OutputPath");
            var intermediateOutputPath = Path.Combine(tmpdir, "IntermediateOutputPath");
            var properties             = GetDefaultProperties();

            properties ["OutputPath"]             = outputPath + Path.DirectorySeparatorChar;
            properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar;
            properties ["NoBindingEmbedding"]     = noBindingEmbedding ? "true" : "false";

            DotNet.AssertPack(project_path, properties);

            var nupkg = Path.Combine(outputPath, project + ".1.0.0.nupkg");

            Assert.That(nupkg, Does.Exist, "nupkg existence");

            var archive     = ZipFile.OpenRead(nupkg);
            var files       = archive.Entries.Select(v => v.FullName).ToHashSet();
            var hasSymlinks = noBindingEmbedding && (platform == ApplePlatform.MacCatalyst || platform == ApplePlatform.MacOSX);

            if (noBindingEmbedding)
            {
                Assert.That(archive.Entries.Count, Is.EqualTo(hasSymlinks ? 6 : 10), $"nupkg file count - {nupkg}");
            }
            else
            {
                Assert.That(archive.Entries.Count, Is.EqualTo(5), $"nupkg file count - {nupkg}");
            }
            Assert.That(files, Does.Contain(project + ".nuspec"), "nuspec");
            Assert.That(files, Does.Contain("_rels/.rels"), ".rels");
            Assert.That(files, Does.Contain("[Content_Types].xml"), "[Content_Types].xml");
            Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.dll"), $"{project}.dll");
            Assert.That(files, Has.Some.Matches <string> (v => v.StartsWith("package/services/metadata/core-properties/", StringComparison.Ordinal) && v.EndsWith(".psmdcp", StringComparison.Ordinal)), "psmdcp");
            if (noBindingEmbedding)
            {
                if (hasSymlinks)
                {
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources.zip"), $"{project}.resources.zip");
                }
                else
                {
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources/XStaticArTest.framework/XStaticArTest"), $"XStaticArTest.framework/XStaticArTest");
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources/XStaticObjectTest.framework/XStaticObjectTest"), $"XStaticObjectTest.framework/XStaticObjectTest");
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources/XTest.framework/XTest"), $"XTest.framework/XTest");
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources/XTest.framework/Info.plist"), $"XTest.framework/Info.plist");
                    Assert.That(files, Does.Contain($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources/manifest"), $"manifest");
                }
            }
        }