Пример #1
0
        public void CreateAppBundleDependsOnTest(ApplePlatform platform)
        {
            Configuration.IgnoreIfIgnoredPlatform(platform);
            var magic  = Guid.NewGuid().ToString();
            var csproj = $@"<Project Sdk=""Microsoft.NET.Sdk"">
<PropertyGroup>
	<TargetFramework>{platform.ToFramework ()}</TargetFramework>
	<OutputType>Exe</OutputType>
	<CreateAppBundleDependsOn>FailTheBuild;$(CreateAppBundleDependsOn)</CreateAppBundleDependsOn>
	</PropertyGroup>
	<Target Name=""FailTheBuild"">
		<Error Text=""{magic}"" />
	</Target>
</Project>";

            var tmpdir = Cache.CreateTemporaryDirectory();

            Configuration.CopyDotNetSupportingFiles(tmpdir);
            var project_path = Path.Combine(tmpdir, "TestProject.csproj");

            File.WriteAllText(project_path, csproj);
            File.WriteAllText(Path.Combine(tmpdir, "Info.plist"), EmptyAppManifest);
            File.WriteAllText(Path.Combine(tmpdir, "Main.cs"), EmptyMainFile);

            var properties = GetDefaultProperties();
            var result     = DotNet.AssertBuildFailure(project_path, properties);
            var errors     = BinLog.GetBuildLogErrors(result.BinLogPath);

            Assert.That(errors, Has.Some.Matches <BuildLogEvent> (v => v.Message.Contains(magic)), "Expected error");
        }
Пример #2
0
        public void BindingOldStyle(ApplePlatform platform)
        {
            var project = "BindingOldStyle";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GetProjectPath(project, platform: platform);

            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;

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

            Assert.AreEqual(1, errors.Length, "Error count");
            Assert.AreEqual($"Creating a NuGet package is not supported for projects that have ObjcBindingNativeLibrary items. Migrate to use NativeReference items instead.", errors [0].Message, "Error message");
        }
Пример #3
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");
        }
Пример #4
0
        [TestCase(ApplePlatform.MacCatalyst, "osx-x64")]         // valid RID for another platform
        public void InvalidRuntimeIdentifier(ApplePlatform platform, string runtimeIdentifier)
        {
            var project = "MySimpleApp";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GetProjectPath(project, platform: platform);

            Clean(project_path);
            var properties = GetDefaultProperties(runtimeIdentifier);
            var rv         = DotNet.AssertBuildFailure(project_path, properties);
            var errors     = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray();

            Assert.AreEqual(1, errors.Length, "Error count");
            Assert.AreEqual($"The RuntimeIdentifier '{runtimeIdentifier}' is invalid.", errors [0].Message, "Error message");
        }
Пример #5
0
        public void InvalidRuntimeIdentifiers(ApplePlatform platform, string runtimeIdentifiers)
        {
            var project = "MySimpleApp";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GetProjectPath(project, platform: platform);

            Clean(project_path);
            var properties = GetDefaultProperties(runtimeIdentifiers);
            var rv         = DotNet.AssertBuildFailure(project_path, properties);
            var errors     = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray();

            Assert.AreEqual(1, errors.Length, "Error count");
            Assert.AreEqual($"Building for all the runtime identifiers '{runtimeIdentifiers}' at the same time isn't possible, because they represent different platform variations.", errors [0].Message, "Error message");
        }
Пример #6
0
        public void DisableLinker(ApplePlatform platform, string runtimeIdentifiers)
        {
            var project = "MySimpleApp";

            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GetProjectPath(project, platform: platform);

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

            properties ["PublishTrimmed"] = "false";

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

            Assert.AreEqual(1, errors.Length, "Error count");
            Assert.AreEqual($"{platform.AsString ()} projects must build with PublishTrimmed=true. Current value: false.", errors [0].Message, "Error message");
        }