[msbuild] Make the CompileAppManifest task work on Windows.

Make the CompileAppManifest task work on Windows by:

* Not requiring the default SDK version (impossible to calculate without Xcode)
  as an input property (we still require it when it's needed).
* Not requiring the SDK version (also impossible to calculate without Xcode).
* Using the minimum OS version we support as the as minimum OS version the app
  supports if building on Windows and an SDK version has not been provided.
* Not adding any of the app manifest values we get from Xcode.
This commit is contained in:
Rolf Bjarne Kvinge 2023-04-12 12:56:34 +02:00
Родитель 2d1d4b1ea1
Коммит 2431e3aeb7
3 изменённых файлов: 29 добавлений и 9 удалений

Просмотреть файл

@ -1492,4 +1492,9 @@
<data name="E7113" xml:space="preserve"> <data name="E7113" xml:space="preserve">
<value>Can't process the zip file '{0}' on this platform: the file '{1}' is a symlink.</value> <value>Can't process the zip file '{0}' on this platform: the file '{1}' is a symlink.</value>
</data> </data>
<data name="E7114" xml:space="preserve">
<value>The "{0}" task was not given a value for the parameter "{1}", which is required when building on this platform.</value>
</data>
</root> </root>

Просмотреть файл

@ -45,7 +45,6 @@ namespace Xamarin.MacDev.Tasks {
public string DebugIPAddresses { get; set; } = String.Empty; public string DebugIPAddresses { get; set; } = String.Empty;
[Required]
public string DefaultSdkVersion { get; set; } = String.Empty; public string DefaultSdkVersion { get; set; } = String.Empty;
public ITaskItem [] FontFilesToRegister { get; set; } = Array.Empty<ITaskItem> (); public ITaskItem [] FontFilesToRegister { get; set; } = Array.Empty<ITaskItem> ();
@ -75,7 +74,6 @@ namespace Xamarin.MacDev.Tasks {
[Required] [Required]
public bool SdkIsSimulator { get; set; } public bool SdkIsSimulator { get; set; }
[Required]
public string SdkVersion { get; set; } = String.Empty; public string SdkVersion { get; set; } = String.Empty;
public string SupportedOSPlatformVersion { get; set; } = String.Empty; public string SupportedOSPlatformVersion { get; set; } = String.Empty;
@ -95,6 +93,10 @@ namespace Xamarin.MacDev.Tasks {
} }
} }
bool OnWindows {
get => Environment.OSVersion.Platform == PlatformID.Win32NT;
}
public override bool Execute () public override bool Execute ()
{ {
PDictionary plist; PDictionary plist;
@ -276,6 +278,9 @@ namespace Xamarin.MacDev.Tasks {
// Nothing is specified in the Info.plist - use SupportedOSPlatformVersion, and if that's not set, then use the sdkVersion // Nothing is specified in the Info.plist - use SupportedOSPlatformVersion, and if that's not set, then use the sdkVersion
if (!string.IsNullOrEmpty (convertedSupportedOSPlatformVersion)) { if (!string.IsNullOrEmpty (convertedSupportedOSPlatformVersion)) {
minimumOSVersion = convertedSupportedOSPlatformVersion; minimumOSVersion = convertedSupportedOSPlatformVersion;
} else if (OnWindows && string.IsNullOrEmpty (SdkVersion)) {
// When building on Windows (Hot Restart), we're not using any Xcode version, so there's no SdkVersion either, so use the min OS version we support if the project doesn't specify anything.
minimumOSVersion = Xamarin.SdkVersions.GetMinVersion (Platform).ToString ();
} else { } else {
minimumOSVersion = SdkVersion; minimumOSVersion = SdkVersion;
} }
@ -305,14 +310,21 @@ namespace Xamarin.MacDev.Tasks {
bool Compile (PDictionary plist) bool Compile (PDictionary plist)
{ {
var currentSDK = Sdks.GetAppleSdk (Platform); if (!OnWindows) {
if (string.IsNullOrEmpty (DefaultSdkVersion)) {
Log.LogError (MSBStrings.E7114 /* The "{0}" task was not given a value for the parameter "{1}", which is required when building on this platform. */, GetType ().Name, "DefaultSdkVersion");
return false;
}
sdkVersion = AppleSdkVersion.Parse (DefaultSdkVersion); var currentSDK = Sdks.GetAppleSdk (Platform);
if (!currentSDK.SdkIsInstalled (sdkVersion, SdkIsSimulator)) {
Log.LogError (null, null, null, null, 0, 0, 0, 0, MSBStrings.E0013, Platform, sdkVersion); sdkVersion = AppleSdkVersion.Parse (DefaultSdkVersion);
return false; if (!currentSDK.SdkIsInstalled (sdkVersion, SdkIsSimulator)) {
Log.LogError (null, null, null, null, 0, 0, 0, 0, MSBStrings.E0013, Platform, sdkVersion);
return false;
}
SetXcodeValues (plist, currentSDK);
} }
SetXcodeValues (plist, currentSDK);
switch (Platform) { switch (Platform) {
case ApplePlatform.iOS: case ApplePlatform.iOS:
@ -408,7 +420,7 @@ namespace Xamarin.MacDev.Tasks {
var supportedDevices = plist.GetUIDeviceFamily (); var supportedDevices = plist.GetUIDeviceFamily ();
var macCatalystOptimizedForMac = (supportedDevices & IPhoneDeviceType.MacCatalystOptimizedForMac) == IPhoneDeviceType.MacCatalystOptimizedForMac; var macCatalystOptimizedForMac = (supportedDevices & IPhoneDeviceType.MacCatalystOptimizedForMac) == IPhoneDeviceType.MacCatalystOptimizedForMac;
if (macCatalystOptimizedForMac) { if (macCatalystOptimizedForMac && !OnWindows) {
if (Platform != ApplePlatform.MacCatalyst) { if (Platform != ApplePlatform.MacCatalyst) {
LogAppManifestError (MSBStrings.E7098 /* The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst. */); LogAppManifestError (MSBStrings.E7098 /* The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst. */);
return; // no need to look for more errors, they will probably not make much sense. return; // no need to look for more errors, they will probably not make much sense.

Просмотреть файл

@ -69,6 +69,9 @@
<Link>Versions.dotnet.g.cs</Link> <Link>Versions.dotnet.g.cs</Link>
</Compile> </Compile>
<Compile Remove="Errors.designer.cs" /> <!-- The 'CoreResGen' target will add it again from the EmbeddedResource item, this avoids a warning about the file being compiled twice --> <Compile Remove="Errors.designer.cs" /> <!-- The 'CoreResGen' target will add it again from the EmbeddedResource item, this avoids a warning about the file being compiled twice -->
<Compile Include="..\..\tools\common\SdkVersions.cs">
<Link>external\SdkVersions.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>