Exemple #1
0
        public void PublishFailureTest(ApplePlatform platform, string runtimeIdentifiers)
        {
            var project = "MySimpleApp";

            Configuration.IgnoreIfIgnoredPlatform(platform);

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

            Clean(project_path);

            string packageExtension;
            string pathVariable;

            switch (platform)
            {
            case ApplePlatform.iOS:
            case ApplePlatform.TVOS:
                packageExtension = "ipa";
                pathVariable     = "IpaPackagePath";
                break;

            case ApplePlatform.MacCatalyst:
            case ApplePlatform.MacOSX:
                packageExtension = "pkg";
                pathVariable     = "PkgPackagePath";
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown platform: {platform}");
            }
            var tmpdir  = Cache.CreateTemporaryDirectory();
            var pkgPath = Path.Combine(tmpdir, $"MyPackage.{packageExtension}");

            var properties = GetDefaultProperties(runtimeIdentifiers);

            properties [pathVariable] = pkgPath;

            var rv     = DotNet.AssertPublishFailure(project_path, properties);
            var errors = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray();

            Assert.AreEqual(1, errors.Length, "Error Count");
            string expectedErrorMessage;

            if (string.IsNullOrEmpty(runtimeIdentifiers))
            {
                expectedErrorMessage = $"A runtime identifier must be specified in order to publish this project.";
            }
            else if (runtimeIdentifiers.IndexOf(';') >= 0)
            {
                expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' are simulator architectures.";
            }
            else
            {
                expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' is a simulator architecture.";
            }
            Assert.AreEqual(expectedErrorMessage, errors [0].Message, "Error Message");

            Assert.That(pkgPath, Does.Not.Exist, "ipa/pkg creation");
        }