Skip to content

Commit 3f8b5e3

Browse files
committed
tweaks
1 parent b6f165a commit 3f8b5e3

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,4 +1633,24 @@
16331633
<data name="E7164" xml:space="preserve">
16341634
<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>
16351635
</data>
1636+
1637+
<data name="W7165" xml:space="preserve">
1638+
<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>
1639+
</data>
1640+
1641+
<data name="W7166" xml:space="preserve">
1642+
<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>
1643+
</data>
1644+
1645+
<data name="W7167" xml:space="preserve">
1646+
<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>
1647+
</data>
1648+
1649+
<data name="W7168" xml:space="preserve">
1650+
<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>
1651+
</data>
1652+
1653+
<data name="E7169" xml:space="preserve">
1654+
<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>
1655+
</data>
16361656
</root>

msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSdkLocation.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,29 @@ bool ExecuteImpl ()
152152
return ExecuteRemotely ();
153153
}
154154

155-
appleSdkSettings = GetXcodeLocator (initialDiscovery: true);
155+
var isNet11OrNewer = TargetFramework.Version.Major >= 11;
156+
appleSdkSettings = GetXcodeLocator (initialDiscovery: true, (locator) => {
157+
locator.SupportEnvironmentVariableLookup = !isNet11OrNewer;
158+
locator.SupportSettingsFileLookup = !isNet11OrNewer;
159+
});
156160
SdkDevPath = appleSdkSettings.DeveloperRoot;
157161
XcodeVersion = appleSdkSettings.XcodeVersion.ToString ();
162+
163+
if (appleSdkSettings.SystemHasEnvironmentVariable) {
164+
if (isNet11OrNewer) {
165+
Log.LogError (MSBStrings.W7166 /* 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. */, XcodeLocator.EnvironmentVariableName);
166+
} else {
167+
Log.LogError (MSBStrings.W7165 /* 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. */, XcodeLocator.EnvironmentVariableName);
168+
}
169+
}
170+
foreach (var file in appleSdkSettings.SystemExistingSettingsFiles) {
171+
if (isNet11OrNewer) {
172+
Log.LogError (MSBStrings.W7168 /* 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. */, file);
173+
} else {
174+
Log.LogWarning (MSBStrings.W7167 /* 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. */, file);
175+
}
176+
}
177+
158178
if (Log.HasLoggedErrors)
159179
return false;
160180

msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public abstract class XamarinTask : Task, IHasSessionId, ICustomLogger {
2626
public string SdkDevPath { get; set; } = string.Empty;
2727

2828
XcodeLocator? xcodeLocator = null;
29-
public XcodeLocator GetXcodeLocator (bool initialDiscovery = false)
29+
public XcodeLocator GetXcodeLocator (bool initialDiscovery = false, Action<XcodeLocator>? preprocess = null)
3030
{
3131
if (xcodeLocator is null) {
3232
if (!initialDiscovery && string.IsNullOrEmpty (SdkDevPath)) {
33-
// Log.LogError (MSBStrings.E7164 /* 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. */, task.GetType ().Name);
34-
Log.LogError ("The task '{0}' requires SdkDevPath to be set.\n{1}", GetType ().Name, Environment.StackTrace);
33+
Log.LogError (MSBStrings.E7169, /* The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose. */ GetType ().Name, "SdkDevPath");
3534
}
3635

3736
var xcodeLocator = new XcodeLocator (this);
37+
preprocess?.Invoke (xcodeLocator);
3838
if (!xcodeLocator.TryLocatingXcode (SdkDevPath))
3939
Log.LogError (MSBStrings.E0086 /* Could not find a valid Xcode developer path */);
4040
this.xcodeLocator = xcodeLocator;
@@ -46,7 +46,7 @@ void VerifyTargetFrameworkMoniker ()
4646
{
4747
if (!string.IsNullOrEmpty (TargetFrameworkMoniker))
4848
return;
49-
Log.LogError ($"The task {GetType ().Name} requires TargetFrameworkMoniker to be set.");
49+
Log.LogError (MSBStrings.E7169, /* The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose. */ GetType ().Name, "TargetFrameworkMoniker");
5050
}
5151

5252
public string Product {

0 commit comments

Comments
 (0)