Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ComputeRemoteGeneratorProperties : XamarinTask, ITaskCallback, ICan

public string TargetFrameworkIdentifier { get; set; } = string.Empty;

public string UseFloatingTargetPlatformVersion { get; set; } = string.Empty;

// Outputs
[Output]
public string BaseLibDllPath { get; set; } = string.Empty;
Expand Down Expand Up @@ -88,6 +90,8 @@ void ComputeProperties ()
arguments.Add ("/t:_WriteRemoteGeneratorProperties");
if (!string.IsNullOrEmpty (TargetFrameworkIdentifier))
arguments.Add ($"/p:TargetFrameworkIdentifier={TargetFrameworkIdentifier}");
if (!string.IsNullOrEmpty (UseFloatingTargetPlatformVersion))
arguments.Add ($"/p:UseFloatingTargetPlatformVersion={UseFloatingTargetPlatformVersion}");
arguments.Add ($"/p:_PlatformName={PlatformName}");
arguments.Add ($"/bl:{binlog}");

Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true' And '$(BindingProjectBuildSessionId)' != ''"
IntermediateOutputPath="$(IntermediateOutputPath)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
UseFloatingTargetPlatformVersion="$(UseFloatingTargetPlatformVersion)"
>
<Output TaskParameter="BaseLibDllPath" PropertyName="BaseLibDllPath" />
<Output TaskParameter="BGenToolExe" PropertyName="BGenToolExe" />
Expand Down
3 changes: 3 additions & 0 deletions tests/common/shared-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<NoWarn Condition="'$(IncludeCS1416Warnigs)' != 'true'">CA1416;$(NoWarn)</NoWarn>

<CustomBeforeMicrosoftCommonTargets>$(CustomBeforeMicrosoftCommonTargets);$(MSBuildThisFileDirectory)SupportedOSPlatformVersions.targets</CustomBeforeMicrosoftCommonTargets>

<!-- We must set 'UseFloatingTargetPlatformVersion=true' for our test projects, to avoid building them with other workloads than the current workload. -->
<UseFloatingTargetPlatformVersion Condition="'$(UseFloatingTargetPlatformVersion)' == ''">true</UseFloatingTargetPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void BuildMyClassLibrary (ApplePlatform platform)
var project_path = GetProjectPath (project, platform: platform);
Clean (project_path);
var properties = GetDefaultProperties ();
properties.Remove ("UseFloatingTargetPlatformVersion"); // This test verifies that we use the correct workload to build library projects, so we can't use a floating TPF version.
var result = DotNet.AssertBuild (project_path, properties);
Assert.That (result.StandardOutput.ToString (), Does.Not.Contain ("Task \"ILLink\""), "Linker executed unexpectedly.");

Expand Down
10 changes: 6 additions & 4 deletions tests/dotnet/UnitTests/TemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public void CreateAndBuildProjectTemplate (TemplateInfo info)
var outputDir = Path.Combine (tmpDir, info.Template);
DotNet.AssertNew (outputDir, info.Template, language: language.AsLanguageIdentifier ());
var proj = Path.Combine (outputDir, $"{info.Template}.{language.AsFileExtension ()}");
var rv = DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuild (proj, properties);
var warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).Select (v => v.Message);
Assert.That (warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}");

Expand All @@ -232,7 +233,7 @@ public void CreateAndBuildProjectTemplate (TemplateInfo info)
InsertCodeToExitAppAfterLaunch (language, outputDir);

// Build the sample
rv = DotNet.AssertBuild (proj);
rv = DotNet.AssertBuild (proj, properties);

// There should still not be any warnings
warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).Select (v => v.Message);
Expand Down Expand Up @@ -277,7 +278,8 @@ bool IsMatching (TemplateLanguage lang, TemplateLanguage? value)
DotNet.AssertNew (outputDir, item.Template, "item_" + item.Template, language: language.AsLanguageIdentifier ());

var proj = Path.Combine (outputDir, $"{info.Template}.{language.AsFileExtension ()}");
var rv = DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuild (proj, properties);
var warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).Select (v => v.Message);
Assert.That (warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}");

Expand All @@ -290,7 +292,7 @@ bool IsMatching (TemplateLanguage lang, TemplateLanguage? value)
InsertCodeToExitAppAfterLaunch (language, outputDir);

// Build the sample
rv = DotNet.AssertBuild (proj);
rv = DotNet.AssertBuild (proj, properties);

// There should still not be any warnings
warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).Select (v => v.Message);
Expand Down
3 changes: 3 additions & 0 deletions tests/dotnet/UnitTests/TestBaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ protected static Dictionary<string, string> GetDefaultProperties (string? runtim
if (includeRemoteProperties == true)
AddRemoteProperties (rv);

// We must set 'UseFloatingTargetPlatformVersion=true' for our test projects, to avoid building them with other workloads than the current workload.
rv ["UseFloatingTargetPlatformVersion"] = "true";

return rv;
}

Expand Down
39 changes: 22 additions & 17 deletions tests/dotnet/UnitTests/XcodeProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ public void BuildAppiOS (string projConfig, string rid)
{ "SchemeName", xcodeProjName },
});

var projProps = new Dictionary<string, string> {
{ "Configuration", projConfig },
{ "RuntimeIdentifier", rid },
};
var projProps = GetDefaultProperties (runtimeIdentifiers: rid);
projProps ["Configuration"] = projConfig;
DotNet.AssertBuild (proj, properties: projProps);
var appDir = Path.Combine (testDir, "bin", projConfig, platform.ToFramework (), rid, $"{TestName}.app");
Assert.That (appDir, Does.Exist, $"Expected app dir '{appDir}' did not exist.");
Expand Down Expand Up @@ -96,9 +94,8 @@ public void BuildBindingiOS (string projConfig, string fxConfig, bool createNati
{ "SchemeName", xcodeProjName },
});

var projProps = new Dictionary<string, string> {
{ "Configuration", projConfig },
};
var projProps = GetDefaultProperties ();
projProps ["Configuration"] = projConfig;
DotNet.AssertBuild (proj, properties: projProps);
string expectedXcodeFxOutput;
if (UsesCompressedBindingResourcePackage (platform)) {
Expand Down Expand Up @@ -151,7 +148,8 @@ public class Binding
";
File.WriteAllText (Path.Combine (testDir, "Binding.cs"), classContent);

var rv = DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuild (proj, properties);
var warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).Select (v => v.Message);
Assert.That (warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}");
AssertXcFrameworkOutput (platform, testDir, xcodeProjName);
Expand Down Expand Up @@ -179,7 +177,8 @@ public void PackBinding (ApplePlatform platform)
{ "SchemeName", xcodeProjName },
});

DotNet.AssertPack (proj);
var properties = GetDefaultProperties ();
DotNet.AssertPack (proj, properties);
var expectedNupkgOutput = Path.Combine (testDir, "bin", "Release", $"{TestName}.1.0.0.nupkg");
Assert.That (expectedNupkgOutput, Does.Exist, $"Expected pack output '{expectedNupkgOutput}' did not exist.");

Expand Down Expand Up @@ -217,7 +216,8 @@ public void BuildIncremental (ApplePlatform platform)
});

// Build the first time
var rv = DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuild (proj, properties);
var allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetExecuted (allTargets, "_BuildXcodeProjects", "First _BuildXcodeProjects");
var expectedXcodeFxOutput = Path.Combine (testDir, "bin", "Debug", platform.ToFramework (), $"{TestName}.resources", $"{xcodeProjName}{platform.AsString ().ToLower ()}.xcframework");
Expand All @@ -227,7 +227,7 @@ public void BuildIncremental (ApplePlatform platform)
var outputFxFirstWriteTime = File.GetLastWriteTime (expectedXcodeFxOutput);

// Build again, _BuildXcodeProjects should be skipped and outputs should not be updated
rv = DotNet.AssertBuild (proj);
rv = DotNet.AssertBuild (proj, properties);
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetNotExecuted (allTargets, "_BuildXcodeProjects", "Second _BuildXcodeProjects");
Assert.That (expectedXcodeFxOutput, Does.Exist, $"Expected xcframework output '{expectedXcodeFxOutput}' did not exist.");
Expand All @@ -236,7 +236,7 @@ public void BuildIncremental (ApplePlatform platform)

// Update xcode project, _BuildXcodeProjects should run and outputs should be updated
File.SetLastWriteTime (Path.Combine (xcodeProjPath, "project.pbxproj"), DateTime.Now);
rv = DotNet.AssertBuild (proj);
rv = DotNet.AssertBuild (proj, properties);
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetExecuted (allTargets, "_BuildXcodeProjects", "Third _BuildXcodeProjects");
Assert.That (expectedXcodeFxOutput, Does.Exist, $"Expected xcframework output '{expectedXcodeFxOutput}' did not exist.");
Expand Down Expand Up @@ -269,7 +269,8 @@ public void BuildMultipleSchemesiOS ()
{ "SchemeName", secondSchemeName },
});

DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
DotNet.AssertBuild (proj, properties);
AssertXcFrameworkOutput (platform, testDir, xcodeProjName);
AssertXcFrameworkOutput (platform, testDir, secondSchemeName);
}
Expand Down Expand Up @@ -302,7 +303,8 @@ public void BuildMultipleProjectsiOS ()
{ "SchemeName", xcodeProjName2 },
});

DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
DotNet.AssertBuild (proj, properties);
AssertXcFrameworkOutput (platform, testDir, xcodeProjName);
AssertXcFrameworkOutput (platform, testDir, xcodeProjName2);
}
Expand Down Expand Up @@ -332,7 +334,8 @@ public void BuildMultiTargeting ()
{ "SchemeName", xcodeProjName },
});

DotNet.AssertBuild (proj);
var properties = GetDefaultProperties ();
DotNet.AssertBuild (proj, properties);
foreach (var platform in enabledPlatforms) {
AssertXcFrameworkOutput (platform, testDir, xcodeProjName);
}
Expand All @@ -355,7 +358,8 @@ public void InvalidItemErroriOS ()
{ "SchemeName", xcodeProjName },
});

var rv = DotNet.AssertBuildFailure (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuildFailure (proj, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
var expectedError = $"The Xcode project item: '{invalidXcodeProjPath}' could not be found. Please update the 'Include' value to a path containing a valid '.xcodeproj' file.";
AssertErrorMessages (errors, expectedError);
Expand All @@ -382,7 +386,8 @@ public void InvalidSchemeErroriOS ()
{ "SchemeName", invaldSchemeName },
});

var rv = DotNet.AssertBuildFailure (proj);
var properties = GetDefaultProperties ();
var rv = DotNet.AssertBuildFailure (proj, properties);
var expectedErrorContent = $"xcodebuild: error: The project named \"{xcodeProjName}\" does not contain a scheme named \"{invaldSchemeName}\".";
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
AssertErrorMessages (errors,
Expand Down
Loading