[msbuild] Unify _RequireCodeSigning and EnableCodeSigning into _RequireCodeSigning. (#8743)

This commit is contained in:
Rolf Bjarne Kvinge 2020-06-04 15:17:32 +02:00 коммит произвёл GitHub
Родитель f7e95a0fd5
Коммит 7369b5edfb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 37 добавлений и 19 удалений

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

@ -34,8 +34,6 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
<Target Name="_EnabledLocalSigning" DependsOnTargets="_DetectSigningIdentity">
<PropertyGroup>
<EnableCodeSigning Condition="'$(EnableCodeSigning)' != 'true'">true</EnableCodeSigning>
<_CodeSigningKey Condition="'$(_CodeSigningKey)' == ''">-</_CodeSigningKey>
<CodeSignEntitlements Condition="'$(CodeSignEntitlements)' == ''">Entitlements.plist</CodeSignEntitlements>
</PropertyGroup>
</Target>

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

@ -60,7 +60,6 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
</PropertyGroup>
<PropertyGroup>
<EnableCodeSigning Condition="'$(EnableCodeSigning)' == ''">false</EnableCodeSigning>
<CodeSigningKey Condition="'$(CodeSigningKey)' == ''"></CodeSigningKey>
<CodeSignProvision Condition="'$(CodeSignProvision)' == ''"></CodeSignProvision>
<CodeSignEntitlements Condition="'$(CodeSignEntitlements)' == ''"></CodeSignEntitlements>

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

@ -175,7 +175,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
</_CollectBundleResourcesDependsOn>
</PropertyGroup>
<Target Name="_CodesignNativeLibraries" Condition="'$(EnableCodeSigning)'" DependsOnTargets="_DetectSigningIdentity">
<Target Name="_CodesignNativeLibraries" Condition="'$(_RequireCodeSigning)'" DependsOnTargets="_DetectSigningIdentity">
<Codesign
SessionId="$(BuildSessionId)"
ToolExe="$(CodesignExe)"
@ -203,7 +203,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
</EmbedProvisionProfile>
</Target>
<Target Name="_CompileEntitlements" Condition="'$(EnableCodeSigning)'" DependsOnTargets="_GenerateBundleName"
<Target Name="_CompileEntitlements" Condition="'$(_RequireCodeSigning)'" DependsOnTargets="_GenerateBundleName"
Outputs="$(IntermediateOutputPath)Entitlements.xcent">
<CompileEntitlements
Condition="'$(IsMacEnabled)' == 'true'"
@ -223,7 +223,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
</CompileEntitlements>
</Target>
<Target Name="_CodesignAppBundle" Condition="'$(EnableCodeSigning)'" DependsOnTargets="$(_CodesignAppBundleDependsOn)">
<Target Name="_CodesignAppBundle" Condition="'$(_RequireCodeSigning)'" DependsOnTargets="$(_CodesignAppBundleDependsOn)">
<Codesign
Condition="'$(IsMacEnabled)' == 'true'"
SessionId="$(BuildSessionId)"
@ -242,7 +242,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
</Codesign>
</Target>
<Target Name="_CodesignVerify" Condition="'$(EnableCodeSigning)'" DependsOnTargets="_CodesignAppBundle">
<Target Name="_CodesignVerify" Condition="'$(_RequireCodeSigning)'" DependsOnTargets="_CodesignAppBundle">
<CodesignVerify
Condition="'$(IsMacEnabled)' == 'true'"
SessionId="$(BuildSessionId)"
@ -419,11 +419,12 @@ Copyright (C) 2014 Xamarin. All rights reserved.
AppBundleName="$(_AppBundleName)"
AppManifest="$(_AppManifest)"
Keychain="$(CodesignKeychain)"
RequireCodeSigning="$(EnableCodeSigning)"
RequireCodeSigning="$(_RequireCodeSigning)"
RequireProvisioningProfile="$(_RequireProvisioningProfile)"
SdkPlatform="MacOSX"
ProvisioningProfile="$(CodeSignProvision)"
SigningKey="$(CodeSigningKey)"
DetectedCodeSigningKey="$(_CodeSigningKey)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
<Output TaskParameter="DetectedAppId" PropertyName="_AppIdentifier" />

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

@ -66,6 +66,7 @@ namespace Xamarin.MacDev.Tasks
[Output]
public string DetectedBundleVersion { get; set; }
// This is input too
[Output]
public string DetectedCodeSigningKey { get; set; }
@ -456,7 +457,7 @@ namespace Xamarin.MacDev.Tasks
}
if (Platform == ApplePlatform.MacOSX) {
if (!RequireCodeSigning) {
if (!RequireCodeSigning || !string.IsNullOrEmpty (DetectedCodeSigningKey)) {
DetectedBundleId = identity.BundleId;
DetectedAppId = DetectedBundleId;

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

@ -27,6 +27,20 @@ Copyright (C) 2020 Microsoft. All rights reserved.
<_PlatformName Condition="'$(_PlatformName)' == ''">macOS</_PlatformName> <!-- detecting Xamarin.Mac is a bit more complicated, so just fall back to macOS if none of the others match -->
</PropertyGroup>
<PropertyGroup>
<!--
We don't want to use the Platform variable for conditional logic.
Switching to a new property allows us to potentially switch from
device to simulator builds dynamically based on the user's
selection when starting the project. This allows us to eventually
even (optionally) switch back to AnyCPU platform in the IDE,
therefore fixing a key pain point in managing solution
configurations.
-->
<ComputedPlatform Condition="'$(ComputedPlatform)' == ''">$(Platform)</ComputedPlatform>
<ComputedPlatform Condition="'$(_PlatformName)' != 'macOS' And '$(ComputedPlatform)' == 'AnyCPU'">iPhone</ComputedPlatform>
</PropertyGroup>
<!-- Sometimes we've used different variable names for the same thing for Xamarin.iOS and Xamarin.Mac projects. Here we try to unify those variables -->
<PropertyGroup>
<!-- ResourcePrefix -->
@ -40,6 +54,21 @@ Copyright (C) 2020 Microsoft. All rights reserved.
<!-- SdkVersion -->
<_SdkVersion Condition="'$(_PlatformName)' == 'macOS'">$(MacOSXSdkVersion)</_SdkVersion>
<_SdkVersion Condition="'$(_PlatformName)' != 'macOS'">$(MtouchSdkVersion)</_SdkVersion>
<!-- RequireCodeSigning -->
<!-- iOS/watchOS/tvOS is simple: device builds require code signing, simulator builds do not. This is a big lie, for some simulator builds need to be signed, but the _DetectCodeSigning task handles those cases. -->
<_RequireCodeSigning Condition="'$(_PlatformName)' != 'macOS' And '$(_RequireCodeSigning)' == ''">false</_RequireCodeSigning> <!-- Xamarin.iOS builds are not signed by default -->
<_RequireCodeSigning Condition="'$(_PlatformName)' != 'macOS' And '$(ComputedPlatform)' == 'iPhone'">true</_RequireCodeSigning> <!-- except that device builds must be signed -->
<!-- macOS is a bit more complicated:
* 'EnableCodeSigning' specifies whether the app is signed or not, and this defaults to false if it's not set.
* Extensions are special, because they must be signed. However, due to historical reasons, extension projects will have set EnableCodeSigning=false. So we do the following:
* If we're an extension, and code signing is disabled: enable code signing, set the code signing key (_CodeSigningKey) to '-', and pass this value to the _DetectCodeSigning task.
-->
<_RequireCodeSigning Condition="'$(_PlatformName)' == 'macOS' And '$(_RequireCodeSigning)' == ''">$(EnableCodeSigning)</_RequireCodeSigning> <!-- Xamarin.Mac projects use the 'EnableCodeSigning' variable to enable code signing -->
<_RequireCodeSigning Condition="'$(_PlatformName)' == 'macOS' And '$(_RequireCodeSigning)' == ''">false</_RequireCodeSigning> <!-- Xamarin.Mac projects: disable by default -->
<_CodeSigningKey Condition="'$(_PlatformName)' == 'macOS' And '$(IsAppExtension)' == 'true' And '$(_CodeSigningKey)' == '' And '$(_RequireCodeSigning)' == 'false'">-</_CodeSigningKey> <!-- Set _CodeSigningKey to '-' if we're an extension where code signing is not requested -->
<_RequireCodeSigning Condition="'$(_PlatformName)' == 'macOS' And '$(IsAppExtension)' == 'true'">true</_RequireCodeSigning> <!-- But extensions must be signed, so make sure they are -->
</PropertyGroup>
<Target Name="_ComputeTargetFrameworkMoniker" Condition="'$(_ComputedTargetFrameworkMoniker)' == ''">

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

@ -106,13 +106,6 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Shared.targets" />
<PropertyGroup>
<!-- Switching to a new property allows us to potentially switch from iPhone to simulator builds
dynamically based on the user's selection when starting the project. This allows us to
eventually even (optionally) switch back to AnyCPU platform in the IDE, therefore
fixing a key pain point in managing solution configurations. -->
<ComputedPlatform Condition="'$(ComputedPlatform)' == ''">$(Platform)</ComputedPlatform>
<ComputedPlatform Condition="'$(ComputedPlatform)' == 'AnyCPU'">iPhone</ComputedPlatform>
<_CanOutputAppBundle>False</_CanOutputAppBundle>
<_CanOutputAppBundle Condition="'$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true' Or '$(IsWatchApp)' == 'true'">True</_CanOutputAppBundle>
@ -122,9 +115,6 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<_CanDeployToDeviceOrSimulator>False</_CanDeployToDeviceOrSimulator>
<_CanDeployToDeviceOrSimulator Condition="('$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true') And '$(IsWatchApp)' == 'false'">True</_CanDeployToDeviceOrSimulator>
<_RequireCodeSigning>False</_RequireCodeSigning>
<_RequireCodeSigning Condition="'$(ComputedPlatform)' == 'iPhone'">True</_RequireCodeSigning>
<_RequireProvisioningProfile>False</_RequireProvisioningProfile>
<_RequireProvisioningProfile Condition="'$(ComputedPlatform)' == 'iPhone' Or '$(CodesignEntitlements)' != ''">True</_RequireProvisioningProfile>