Skip to content
Draft
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
1 change: 0 additions & 1 deletion Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ endif

# Tell both Xcode and our build logic which Xcode we're using.
export DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT)
export MD_APPLE_SDK_ROOT=$(abspath $(XCODE_DEVELOPER_ROOT)/../..)

# We don't need to be told there are workload updates
export DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE=true
Expand Down
10 changes: 8 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@
</Target>

<Target Name="_CopyDirectoriesToBundle"
DependsOnTargets="_CollectDecompressedPlugins;_ComputeFrameworkFilesToPublish;_CollectDecompressedXpcServices;_CreateStampLocationForCopyDirectoriesToBundle"
DependsOnTargets="_CollectDecompressedPlugins;_ComputeFrameworkFilesToPublish;_CollectDecompressedXpcServices;_CreateStampLocationForCopyDirectoriesToBundle;_DetectSdkLocations"
Inputs="@(_DirectoriesToPublish)"
Outputs="@(_DirectoriesToPublish -> '%(StampLocation)')"
>
Expand All @@ -967,6 +967,7 @@
Source="%(_DirectoriesToPublish.SourceDirectory)"
Destination="%(_DirectoriesToPublish.TargetDirectory)"
TouchDestinationFiles="true"
SdkDevPath="$(_SdkDevPath)"
StampFile="%(_DirectoriesToPublish.StampLocation)"
CreateOutputFiles="false"
/>
Expand Down Expand Up @@ -1274,7 +1275,7 @@
<Warning Condition="'$(GenerateRuntimeConfigurationFiles)' != 'true'" Text="Some features may not work correctly, because the generation of the runtime configure file (*.runtimeconfig.json) has been disabled." />
</Target>

<Target Name="_FindAotCompiler" DependsOnTargets="_ComputeVariables">
<Target Name="_FindAotCompiler" DependsOnTargets="_ComputeVariables;_DetectSdkLocations">
<PropertyGroup>
<_XamarinAOTCompilerCachePath>$(DeviceSpecificIntermediateOutputPath)aot-compiler-path-$(NETCoreSdkVersion).txt</_XamarinAOTCompilerCachePath>
</PropertyGroup>
Expand All @@ -1293,6 +1294,7 @@
KeepTemporaryOutput="$(FindAotCompilerKeepKeepTemporaryOutput)"
MonoAotCrossCompiler="@(MonoAotCrossCompiler)"
RuntimeIdentifier="$(RuntimeIdentifier)"
SdkDevPath="$(_SdkDevPath)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
<Output TaskParameter="AotCompiler" PropertyName="_XamarinAOTCompiler" />
Expand Down Expand Up @@ -1972,6 +1974,7 @@
_DetectSigningIdentity;
_PrepareResourceRules;
_AddDebugSymbolsToBundle;
_DetectSdkLocations;
</_ComputePublishLocationDependsOn>
</PropertyGroup>

Expand Down Expand Up @@ -2203,6 +2206,7 @@
FrameworksDirectory="$(_AppFrameworksRelativePath)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
NativeReferences="@(_NativeReferencesToResolve)"
SdkDevPath="$(_SdkDevPath)"
SdkIsSimulator="$(_SdkIsSimulator)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
Expand Down Expand Up @@ -2264,6 +2268,7 @@
Condition="'$(IsMacEnabled)' == 'true'"
ZipFilePath="%(_CompressedPlugIns.Identity)"
ExtractionPath="%(_CompressedPlugIns.ExtractionPath)"
SdkDevPath="$(_SdkDevPath)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Unzip>
Expand Down Expand Up @@ -2307,6 +2312,7 @@
CopyToWindows="true"
ZipFilePath="%(_CompressedXpcServices.Identity)"
ExtractionPath="%(_CompressedXpcServices.ExtractionPath)"
SdkDevPath="$(_SdkDevPath)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Unzip>
Expand Down
24 changes: 24 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1619,4 +1619,28 @@
<data name="E7163" xml:space="preserve">
<value>Unable to copy the inputs to this task to the remote build server for unknown reasons. The build log may have more information.</value>
</data>

<data name="E7164" xml:space="preserve">
<value>The task '{0}' is trying to call an external process, but a path to Xcode has not been provided. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>

<data name="W7165" xml:space="preserve">
<value>The environment variable '{0}' is deprecated, and will be ignored in .NET 11+. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7166" xml:space="preserve">
<value>The environment variable '{0}' is deprecated, and will be ignored. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7167" xml:space="preserve">
<value>The settings file '{0}' is deprecated, and will be ignored in .NET 11+. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7168" xml:space="preserve">
<value>The settings file '{0}' is deprecated, and will be ignored. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="E7169" xml:space="preserve">
<value>The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>
</root>
41 changes: 6 additions & 35 deletions msbuild/Xamarin.MacDev.Tasks/Sdks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,24 @@

namespace Xamarin.MacDev {
public static class Sdks {
public static AppleIPhoneSdk IOS { get; private set; }
public static MacOSXSdk MacOS { get; private set; }
public static AppleTVOSSdk TVOS { get; private set; }

static Sdks ()
{
IOS = new AppleIPhoneSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
TVOS = new AppleTVOSSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
MacOS = new MacOSXSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
}

public static AppleSdk GetSdk (ApplePlatform framework)
public static IAppleSdk GetAppleSdk (ApplePlatform framework, XcodeLocator appleSdk)
{
switch (framework) {
case ApplePlatform.iOS:
return IOS;
return new AppleIPhoneSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
case ApplePlatform.TVOS:
return TVOS;
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidFramework, framework));
}
}

public static AppleSdk GetSdk (string targetFrameworkMoniker)
{
return GetSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker));
}

public static IAppleSdk GetAppleSdk (ApplePlatform framework)
{
switch (framework) {
case ApplePlatform.iOS:
return IOS;
case ApplePlatform.TVOS:
return TVOS;
return new AppleTVOSSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
case ApplePlatform.MacCatalyst:
case ApplePlatform.MacOSX:
return MacOS;
return new MacOSXSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidFramework, framework));
}
}

public static IAppleSdk GetAppleSdk (string targetFrameworkMoniker)
public static IAppleSdk GetAppleSdk (string targetFrameworkMoniker, XcodeLocator appleSdk)
{
return GetAppleSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker));
return GetAppleSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker), appleSdk);
}

}
}
4 changes: 0 additions & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ACTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public class ACTool : XcodeCompilerToolTask, ICancelableTask {
HashSet<string> brandAssetsInAssets = new (); // tvOS
HashSet<string> imageStacksInAssets = new (); // tvOS

protected override string DefaultBinDir {
get { return DeveloperRootBinDir; }
}

protected override string ToolName {
get { return "actool"; }
}
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class AOTCompile : XamarinParallelTask, ITaskCallback, ICancelableTask {
[Required]
public string OutputDirectory { get; set; } = string.Empty;

[Required]
public string SdkDevPath { get; set; } = string.Empty;

#region Output
[Output]
public ITaskItem []? AssemblyFiles { get; set; }
Expand Down Expand Up @@ -341,7 +338,7 @@ public override bool Execute ()
environment [item.ItemSpec] = item.GetMetadata ("Value");

ForEach (listOfArguments, (arg) => {
ExecuteAsync (AOTCompilerPath, arg.Arguments, environment: environment, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
ExecuteAsync (AOTCompilerPath, arg.Arguments, environment: environment, showErrorIfFailure: false /* we show our own error below */)
.ContinueWith ((v) => {
if (v.Result.ExitCode != 0)
Log.LogError (MSBStrings.E7118 /* Failed to AOT compile {0}, the AOT compiler exited with code {1} */, Path.GetFileName (arg.Input), v.Result.ExitCode);
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/AlTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public abstract class ALToolTaskBase : XamarinTask, ICancelableTask {
[Required]
public string FilePath { get; set; } = string.Empty;

[Required]
public string SdkDevPath { get; set; } = string.Empty;

protected abstract string ALToolAction { get; }

public override bool Execute ()
Expand All @@ -44,7 +41,7 @@ public override bool Execute ()
return false;

cancellationTokenSource = new CancellationTokenSource ();
var rv = ExecuteAsync (Log, executable, args, sdkDevPath: SdkDevPath, cancellationToken: cancellationTokenSource.Token).Result;
var rv = ExecuteAsync (executable, args, cancellationToken: cancellationTokenSource.Token).Result;
LogErrorsFromOutput (rv.StandardOutput?.ToString ());
return !Log.HasLoggedErrors;
}
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/BGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public override bool Execute ()
return false;

cancellationTokenSource = new CancellationTokenSource ();
ExecuteAsync (Log, executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
ExecuteAsync (executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
return !Log.HasLoggedErrors;
}

Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void Sign (SignInfo info)
var environment = new Dictionary<string, string?> () {
{ "CODESIGN_ALLOCATE", GetCodesignAllocate (item) },
};
var rv = ExecuteAsync (fileName, arguments, null, environment, mergeOutput: false).Result;
var rv = ExecuteAsync (fileName, arguments, environment, mergeOutput: false).Result;
var exitCode = rv.ExitCode;
var messages = rv.StandardOutput?.ToString () ?? string.Empty;

Expand Down
15 changes: 10 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ bool SetMinimumOSVersion (PDictionary plist)
if (Platform == ApplePlatform.MacCatalyst && !string.IsNullOrEmpty (SupportedOSPlatformVersion)) {
// SupportedOSPlatformVersion is the iOS version for Mac Catalyst.
// But we need to store the macOS version in the app manifest, so convert it to the macOS version here.
if (!MacCatalystSupport.TryGetMacOSVersion (Sdks.GetAppleSdk (Platform).GetSdkPath (SdkVersion), SupportedOSPlatformVersion, out var convertedVersion, out var knowniOSVersions)) {
if (!MacCatalystSupport.TryGetMacOSVersion (GetSdk ().GetSdkPath (SdkVersion), SupportedOSPlatformVersion, out var convertedVersion, out var knowniOSVersions)) {
Log.LogError (MSBStrings.E0188, SupportedOSPlatformVersion, string.Join (", ", knowniOSVersions.OrderBy (v => v)));
return false;
}
Expand All @@ -250,7 +250,7 @@ bool SetMinimumOSVersion (PDictionary plist)
var minimumiOSVersionInManifest = plist.Get<PString> (ManifestKeys.MinimumOSVersion)?.Value;
if (!string.IsNullOrEmpty (minimumiOSVersionInManifest)) {
// Convert to the macOS version
if (!MacCatalystSupport.TryGetMacOSVersion (Sdks.GetAppleSdk (Platform).GetSdkPath (SdkVersion), minimumiOSVersionInManifest!, out var convertedVersion, out var knowniOSVersions)) {
if (!MacCatalystSupport.TryGetMacOSVersion (GetSdk ().GetSdkPath (SdkVersion), minimumiOSVersionInManifest!, out var convertedVersion, out var knowniOSVersions)) {
Log.LogError (MSBStrings.E0188, minimumiOSVersionInManifest, string.Join (", ", knowniOSVersions.OrderBy (v => v)));
return false;
}
Expand Down Expand Up @@ -309,7 +309,7 @@ bool Compile (PDictionary plist)
return false;
}

var currentSDK = Sdks.GetAppleSdk (Platform);
var currentSDK = GetSdk ();

sdkVersion = AppleSdkVersion.Parse (DefaultSdkVersion);
if (!currentSDK.SdkIsInstalled (sdkVersion, SdkIsSimulator)) {
Expand Down Expand Up @@ -408,6 +408,11 @@ protected void MergePartialPlistTemplates (PDictionary plist)
MergePartialPLists (this, plist, PartialAppManifests);
}

IAppleSdk GetSdk ()
{
return Sdks.GetAppleSdk (Platform, GetXcodeLocator ());
}

void Validation (PDictionary plist)
{
if (!Validate)
Expand All @@ -424,7 +429,7 @@ void Validation (PDictionary plist)
GetMinimumOSVersion (plist, out var minimumOSVersion);
if (minimumOSVersion < new Version (11, 0)) {
string miniOSVersion = "?";
if (MacCatalystSupport.TryGetiOSVersion (Sdks.GetAppleSdk (Platform).GetSdkPath (SdkVersion), minimumOSVersion, out var iOSVersion, out var _))
if (MacCatalystSupport.TryGetiOSVersion (GetSdk ().GetSdkPath (SdkVersion), minimumOSVersion, out var iOSVersion, out var _))
miniOSVersion = iOSVersion?.ToString () ?? "?";
LogAppManifestError (MSBStrings.E7099 /* The UIDeviceFamily value '6' requires macOS 11.0. Please set the 'SupportedOSPlatformVersion' in the project file to at least 14.0 (the Mac Catalyst version equivalent of macOS 11.0). The current value is {0} (equivalent to macOS {1}). */, miniOSVersion, minimumOSVersion);
}
Expand Down Expand Up @@ -510,7 +515,7 @@ void SetXcodeValues (PDictionary plist, IAppleSdk currentSDK)
SetValueIfNotNull (plist, "DTPlatformName", PlatformUtils.GetTargetPlatform (SdkPlatform, false));
SetValueIfNotNull (plist, "DTPlatformVersion", dtSettings.DTPlatformVersion);
SetValueIfNotNull (plist, "DTSDKName", sdkSettings.CanonicalName);
SetValueIfNotNull (plist, "DTXcode", AppleSdkSettings.DTXcode);
SetValueIfNotNull (plist, "DTXcode", GetXcodeLocator ().DTXcode);
SetValueIfNotNull (plist, "DTXcodeBuild", dtSettings.DTXcodeBuild);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ string DefaultEntitlementsPath {
return "Entitlements.plist";
}

return Path.Combine (Sdks.GetAppleSdk (TargetFrameworkMoniker).GetSdkPath (SdkVersion, false), "Entitlements.plist");
return Path.Combine (Sdks.GetAppleSdk (TargetFrameworkMoniker, GetXcodeLocator ()).GetSdkPath (SdkVersion, false), "Entitlements.plist");
}
}

Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileNativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public class CompileNativeCode : XamarinTask, ICancelableTask, ITaskCallback {
[Required]
public string MinimumOSVersion { get; set; } = "";

[Required]
public string SdkDevPath { get; set; } = "";

[Required]
public string SdkRoot { get; set; } = "";

Expand Down Expand Up @@ -142,7 +139,7 @@ public override bool Execute ()
arguments.Add ("-c");
arguments.Add (src);

processes [i] = ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath);
processes [i] = ExecuteAsync ("xcrun", arguments);
}

System.Threading.Tasks.Task.WaitAll (processes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class CompileSceneKitAssets : XamarinTask, ICancelableTask, IHasProjectDi
[Required]
public ITaskItem [] SceneKitAssets { get; set; } = Array.Empty<ITaskItem> ();

[Required]
public string SdkDevPath { get; set; } = "";

[Required]
public string SdkPlatform { get; set; } = "";

Expand Down Expand Up @@ -86,8 +83,7 @@ Task CopySceneKitAssets (string scnassets, string output, string intermediate)
args.Add ($"--resources-folder-path={AppBundleName}");

var executable = GetExecutable (args, ToolName, CopySceneKitAssetsPath);

return ExecuteAsync (executable, args, sdkDevPath: SdkDevPath, environment: environment, showErrorIfFailure: true);
return ExecuteAsync (executable, args, environment: environment, showErrorIfFailure: true);
}

static bool TryGetScnAssetsPath (string file, out string scnassets)
Expand Down
7 changes: 1 addition & 6 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CoreMLCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public class CoreMLCompiler : XamarinTask, ICancelableTask, IHasProjectDir, IHas
[Required]
public string ResourcePrefix { get; set; } = "";

string sdkDevPath = "";
public string SdkDevPath {
get { return string.IsNullOrEmpty (sdkDevPath) ? "/" : sdkDevPath; }
set { sdkDevPath = value; }
}
#endregion

#region Outputs
Expand All @@ -60,7 +55,7 @@ int Compile (ITaskItem item, string outputDir, string log, string partialPlist)
args.Add (partialPlist);

var executable = GetExecutable (args, ToolName, CoreMlcPath);
var rv = ExecuteAsync (executable, args, sdkDevPath, mergeOutput: false).Result;
var rv = ExecuteAsync (executable, args, mergeOutput: false).Result;
var exitCode = rv.ExitCode;
var output = rv.StandardOutput!.ToString ();
File.WriteAllText (log, output);
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/CreateAssetPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public override bool Execute ()
var args = GenerateCommandLineCommands ();
var executable = GetExecutable (args, "zip", ZipPath);
cancellationTokenSource = new CancellationTokenSource ();
ExecuteAsync (Log, executable, args, workingDirectory: GetWorkingDirectory (), cancellationToken: cancellationTokenSource.Token).Wait ();
ExecuteAsync (executable, args, workingDirectory: GetWorkingDirectory (), cancellationToken: cancellationTokenSource.Token).Wait ();
return !Log.HasLoggedErrors;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override bool Execute ()
var args = GenerateCommandLineCommands ();
var executable = GetExecutable (args, "productbuild", ProductBuildPath);
cancellationTokenSource = new CancellationTokenSource ();
ExecuteAsync (Log, executable, args, workingDirectory: OutputDirectory, cancellationToken: cancellationTokenSource.Token).Wait ();
ExecuteAsync (executable, args, workingDirectory: OutputDirectory, cancellationToken: cancellationTokenSource.Token).Wait ();
return !Log.HasLoggedErrors;
}

Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/DSymUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class DSymUtil : XamarinTask, ITaskCallback {
[Required]
public ITaskItem [] Executable { get; set; } = Array.Empty<ITaskItem> ();

[Required]
public string SdkDevPath { get; set; } = string.Empty;

#endregion

#region Outputs
Expand Down Expand Up @@ -65,7 +62,7 @@ void ExecuteDSymUtil (ITaskItem item, List<ITaskItem> contentFiles)
args.Add (dSymDir);

args.Add (Path.GetFullPath (item.ItemSpec));
ExecuteAsync ("xcrun", args, sdkDevPath: SdkDevPath).Wait ();
ExecuteAsync ("xcrun", args).Wait ();

var contentsDir = Path.Combine (dSymDir, "Contents");
if (Directory.Exists (contentsDir))
Expand Down
Loading
Loading