Skip to content
Merged
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
24 changes: 24 additions & 0 deletions docs/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,18 @@ $ dotnet run -p:StandardInputPath=stdin.txt

Note: this can also be accomplished by passing `--stdin ...` using the [OpenArguments](#openarguments) property.

## SdkIsDesktop

This property is a read-only property (setting it will have no effect) that
specifies whether we're building for a desktop platform (macOS or Mac Catalyst).

This property is `true` when the target platform is macOS or Mac Catalyst,
and is not set for iOS or tvOS builds.

Like `SdkIsSimulator`, this property is only set after [imports and
properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties)
have been evaluated.

## SdkIsDevice

This property is a read-only property (setting it will have no effect) that
Expand All @@ -1247,6 +1259,18 @@ Like `SdkIsSimulator`, this property is only set after [imports and
properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties)
have been evaluated.

## SdkIsMobile

This property is a read-only property (setting it will have no effect) that
specifies whether we're building for a mobile platform (iOS or tvOS).

This property is `true` when the target platform is iOS or tvOS, and is not
set for macOS or Mac Catalyst builds.

Like `SdkIsSimulator`, this property is only set after [imports and
properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties)
have been evaluated.

## SdkIsSimulator

This property is a read-only property (setting it will have no effect) that
Expand Down
2 changes: 1 addition & 1 deletion dotnet/targets/Microsoft.Sdk.Desktop.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Name="_PrepareRunDesktop"
BeforeTargets="ComputeRunArguments"
DependsOnTargets="_ValidateHotReloadConfiguration"
Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">
Condition="'$(SdkIsDesktop)' == 'true'">

<!--
If we're running under 'dotnet watch', change a few defaults to:
Expand Down
6 changes: 3 additions & 3 deletions dotnet/targets/Microsoft.Sdk.Mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<Exec SessionId="$(BuildSessionId)" Command="'$(MlaunchPath)' $(MlaunchInstallArguments)" />
</Target>

<Target Name="ComputeMlaunchRunArguments" DependsOnTargets="_DetectSdkLocations;_GenerateBundleName;_DetectAppManifest;ComputeAvailableDevices;_ShowRunHelpConditioned;_ComputeMlaunchRunArguments" Condition="'$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'" />
<Target Name="ComputeMlaunchRunArguments" DependsOnTargets="_DetectSdkLocations;_GenerateBundleName;_DetectAppManifest;ComputeAvailableDevices;_ShowRunHelpConditioned;_ComputeMlaunchRunArguments" Condition="'$(SdkIsDesktop)' != 'true'" />

<Target Name="_ComputeMlaunchRunArguments" Condition="'$(Help)' != 'true'">
<!-- Launching from the command line on windows hasn't been implemented: https://github.com/dotnet/macios/issues/16609 -->
Expand Down Expand Up @@ -145,7 +145,7 @@
Name="_PrepareRunMobile"
BeforeTargets="ComputeRunArguments"
DependsOnTargets="_ValidateHotReloadConfiguration;_InstallMobile;ComputeMlaunchRunArguments"
Condition="'$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">
Condition="'$(SdkIsDesktop)' != 'true'">
</Target>

<!--
Expand All @@ -162,7 +162,7 @@
-->
<Target Name="ComputeAvailableDevices"
DependsOnTargets="_DetectSdkLocations;_GenerateBundleName;"
Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'"
Condition="'$(SdkIsMobile)' == 'true'"
Returns="@(Devices)">
<PropertyGroup>
<_FilterDevicesToRuntimeIdentifier Condition="'$(_XamarinUsingDefaultRuntimeIdentifier)' != 'true'">$(RuntimeIdentifier)</_FilterDevicesToRuntimeIdentifier>
Expand Down
8 changes: 4 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_PrePublish">
<PropertyGroup>
<BuildIpa Condition="'$(BuildIpa)' == '' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')">true</BuildIpa>
<CreatePackage Condition="'$(CreatePackage)' == '' And ('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst')">true</CreatePackage>
<BuildIpa Condition="'$(BuildIpa)' == '' And '$(SdkIsMobile)' == 'true'">true</BuildIpa>
<CreatePackage Condition="'$(CreatePackage)' == '' And '$(SdkIsDesktop)' == 'true'">true</CreatePackage>

<!-- Put packages in the publish directory unless asked to do otherwise -->
<IpaPackageDir Condition="'$(IpaPackageDir)' == '' And '$(IpaPackagePath)' == ''">$(PublishDir)</IpaPackageDir>
Expand All @@ -21,7 +21,7 @@
/>
</Target>
<Target Name="Publish" DependsOnTargets="_PrePublish;Build">
<Message Importance="high" Text="Created the package: $(IpaPackagePath)" Condition="'$(BuildIpa)' == 'true' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')" />
<Message Importance="high" Text="Created the package: $(PkgPackagePath)" Condition="'$(CreatePackage)' == 'true' And ('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst')" />
<Message Importance="high" Text="Created the package: $(IpaPackagePath)" Condition="'$(BuildIpa)' == 'true' And '$(SdkIsMobile)' == 'true'" />
<Message Importance="high" Text="Created the package: $(PkgPackagePath)" Condition="'$(CreatePackage)' == 'true' And '$(SdkIsDesktop)' == 'true'" />
</Target>
</Project>
10 changes: 8 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,14 @@
<!-- Set a public property that specifies if we're building for the simulator. -->
<SdkIsSimulator>$(_SdkIsSimulator)</SdkIsSimulator>

<!-- SdkIsMobile is true when building for a mobile platform (iOS or tvOS). -->
<SdkIsMobile Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">true</SdkIsMobile>

<!-- SdkIsDevice is true when building for device (which can only happen on iOS and tvOS). -->
<SdkIsDevice Condition="'$(SdkIsSimulator)' != 'true' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')">true</SdkIsDevice>
<SdkIsDevice Condition="'$(SdkIsSimulator)' != 'true' And '$(SdkIsMobile)' == 'true'">true</SdkIsDevice>

<!-- SdkIsDesktop is true when building for macOS or Mac Catalyst. -->
<SdkIsDesktop Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">true</SdkIsDesktop>

<!-- We don't use the 'ComputedPlatform' property anymore, but it seems like there's code out there that depends on it (according to a search on GitHub at least), so define it like we did when we used the property. -->
<ComputedPlatform Condition="'$(ComputedPlatform)' == '' And '$(SdkIsSimulator)' == 'true'">iPhoneSimulator</ComputedPlatform>
Expand Down Expand Up @@ -199,7 +205,7 @@
but the MtouchUseLlvm value is ignored when using the simulator, so it doesn't matter
if we set it in all cases.
-->
<PropertyGroup Condition="'$(MtouchUseLlvm)' == '' And '$(Configuration)' == 'Release' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')">
<PropertyGroup Condition="'$(MtouchUseLlvm)' == '' And '$(Configuration)' == 'Release' And '$(SdkIsMobile)' == 'true'">
<MtouchUseLlvm>true</MtouchUseLlvm>
</PropertyGroup>

Expand Down
46 changes: 23 additions & 23 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
<Import Project="Xamarin.Shared.Sdk.DefaultItems.targets" />

<!-- Include mobile-specific targets only if targeting a mobile platform -->
<Import Project="Microsoft.Sdk.Mobile.targets" Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'" />
<Import Project="Microsoft.Sdk.Desktop.targets" Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'" />
<Import Project="Microsoft.Sdk.Mobile.targets" Condition="'$(SdkIsMobile)' == 'true'" />
<Import Project="Microsoft.Sdk.Desktop.targets" Condition="'$(SdkIsDesktop)' == 'true'" />

<PropertyGroup>
<!-- Add a property that specifies the name of the platform assembly for each platform -->
Expand Down Expand Up @@ -531,8 +531,8 @@
- Otherwise set 'dynamic'
-->
<Registrar Condition="'$(Registrar)' == '' And '$(_UseNativeAot)' == 'true'">managed-static</Registrar>
<Registrar Condition="'$(Registrar)' == '' And '$(_SdkIsSimulator)' != 'true' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS')">managed-static</Registrar>
<Registrar Condition="'$(Registrar)' == '' And '$(_BundlerDebug)' != 'true' And ('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst')">managed-static</Registrar>
<Registrar Condition="'$(Registrar)' == '' And '$(_SdkIsSimulator)' != 'true' And '$(SdkIsMobile)' == 'true'">managed-static</Registrar>
<Registrar Condition="'$(Registrar)' == '' And '$(_BundlerDebug)' != 'true' And '$(SdkIsDesktop)' == 'true'">managed-static</Registrar>
<Registrar Condition="'$(Registrar)' == '' And '$(_AreAnyAssembliesTrimmed)' != 'true' And ('$(MarshalManagedExceptionMode)' == '' Or '$(MarshalManagedExceptionMode)' == 'default')">partial-static</Registrar>
<Registrar Condition="'$(Registrar)' == ''">dynamic</Registrar>
</PropertyGroup>
Expand Down Expand Up @@ -597,7 +597,7 @@
<_LinkerCacheDirectory Condition="'$(BuildSessionId)' != ''">$(IntermediateOutputPath)linker-cache</_LinkerCacheDirectory>

<!-- Set linker feature flags for device/simulator builds -->
<_IsSimulatorFeature Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS') And '$(_SdkIsSimulator)' == 'true'">true</_IsSimulatorFeature>
<_IsSimulatorFeature Condition="'$(SdkIsMobile)' == 'true' And '$(_SdkIsSimulator)' == 'true'">true</_IsSimulatorFeature>
<_IsSimulatorFeature Condition="'$(_IsSimulatorFeature)' == ''">false</_IsSimulatorFeature>

<!-- Set managed static registrar value -->
Expand Down Expand Up @@ -1249,7 +1249,7 @@
<!-- We don't run Mono's AOT compiler if we're not using Mono (aka if we're using NativeAOT or CoreCLR) -->
<PropertyGroup Condition="'$(UseMonoRuntime)' == 'true'" >
<!-- We need it for device builds for mobile platforms -->
<_RunAotCompiler Condition="'$(_SdkIsSimulator)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">true</_RunAotCompiler>
<_RunAotCompiler Condition="'$(_SdkIsSimulator)' != 'true' And '$(SdkIsDesktop)' != 'true'">true</_RunAotCompiler>
<!-- We need it if the interpreter is enabled, no matter where -->
<_RunAotCompiler Condition="'$(MtouchInterpreter)' != '' And '$(_PlatformName)' != 'macOS'">true</_RunAotCompiler>
<!-- We need it for Mac Catalyst on arm64 -->
Expand All @@ -1272,10 +1272,10 @@
<_IntermediateNativeLibraryDir>$(IntermediateOutputPath)nativelibraries/</_IntermediateNativeLibraryDir>
<_IntermediateFrameworksDir>$(DeviceSpecificIntermediateOutputPath)frameworks</_IntermediateFrameworksDir>
<_IntermediateDecompressionDir>$([MSBuild]::EnsureTrailingSlash('$(DeviceSpecificIntermediateOutputPath)decompressed'))</_IntermediateDecompressionDir>
<_NativeExecutablePublishDir Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">$(_RelativeAppBundlePath)\</_NativeExecutablePublishDir>
<_NativeExecutablePublishDir Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">$(_RelativeAppBundlePath)\Contents\MacOS\</_NativeExecutablePublishDir>
<_AppBundleFrameworksDir Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">$(_RelativeAppBundlePath)\Frameworks\</_AppBundleFrameworksDir>
<_AppBundleFrameworksDir Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">$(_RelativeAppBundlePath)\Contents\Frameworks\</_AppBundleFrameworksDir>
<_NativeExecutablePublishDir Condition="'$(SdkIsMobile)' == 'true'">$(_RelativeAppBundlePath)\</_NativeExecutablePublishDir>
<_NativeExecutablePublishDir Condition="'$(SdkIsDesktop)' == 'true'">$(_RelativeAppBundlePath)\Contents\MacOS\</_NativeExecutablePublishDir>
<_AppBundleFrameworksDir Condition="'$(SdkIsMobile)' == 'true'">$(_RelativeAppBundlePath)\Frameworks\</_AppBundleFrameworksDir>
<_AppBundleFrameworksDir Condition="'$(SdkIsDesktop)' == 'true'">$(_RelativeAppBundlePath)\Contents\Frameworks\</_AppBundleFrameworksDir>

<_AOTInputDirectory>$(_IntermediateNativeLibraryDir)aot-input/</_AOTInputDirectory>
<_AOTOutputDirectory>$(_IntermediateNativeLibraryDir)aot-output/</_AOTOutputDirectory>
Expand Down Expand Up @@ -1308,20 +1308,20 @@
<_LibXamarinDebug Condition="'$(_BundlerDebug)' == 'true'">-debug</_LibXamarinDebug>
<_LibXamarinName Condition="'$(_LibXamarinName)' == ''">libxamarin-dotnet$(_LibXamarinRuntime)$(_LibXamarinDebug).$(_LibXamarinExtension)</_LibXamarinName>

<_DylibRPath Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">@executable_path</_DylibRPath>
<_DylibRPath Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">@executable_path/../$(_CustomBundleName)/</_DylibRPath>
<_DylibRPath Condition="'$(SdkIsMobile)' == 'true'">@executable_path</_DylibRPath>
<_DylibRPath Condition="'$(SdkIsDesktop)' == 'true'">@executable_path/../$(_CustomBundleName)/</_DylibRPath>

<_EmbeddedFrameworksRPath Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">@executable_path/Frameworks</_EmbeddedFrameworksRPath>
<_EmbeddedFrameworksRPath Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">@executable_path/../Frameworks/</_EmbeddedFrameworksRPath>
<_EmbeddedFrameworksRPath Condition="'$(SdkIsMobile)' == 'true'">@executable_path/Frameworks</_EmbeddedFrameworksRPath>
<_EmbeddedFrameworksRPath Condition="'$(SdkIsDesktop)' == 'true'">@executable_path/../Frameworks/</_EmbeddedFrameworksRPath>

<_RuntimeConfigurationFile>runtimeconfig.bin</_RuntimeConfigurationFile>
</PropertyGroup>

<!-- Not sure about how to handle nested app extensions here, but if it ever becomes a problem we can look into it (I believe only watch extensions can have embedded extensions at this point, and we don't support watchOS on .NET anyways) -->
<ItemGroup Condition="'$(IsAppExtension)' == 'true'">
<_CustomLinkFlags Include="-rpath" />
<_CustomLinkFlags Include="@executable_path/../../Frameworks" Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'" />
<_CustomLinkFlags Include="@executable_path/../../../../Frameworks" Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'" />
<_CustomLinkFlags Include="@executable_path/../../Frameworks" Condition="'$(SdkIsMobile)' == 'true'" />
<_CustomLinkFlags Include="@executable_path/../../../../Frameworks" Condition="'$(SdkIsDesktop)' == 'true'" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -1903,8 +1903,8 @@

<Target Name="_ComputeDynamicLibrariesToReidentify">
<PropertyGroup>
<_ExecutablePathPrefix Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">@executable_path/</_ExecutablePathPrefix>
<_ExecutablePathPrefix Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">@executable_path/../../</_ExecutablePathPrefix>
<_ExecutablePathPrefix Condition="'$(SdkIsMobile)' == 'true'">@executable_path/</_ExecutablePathPrefix>
<_ExecutablePathPrefix Condition="'$(SdkIsDesktop)' == 'true'">@executable_path/../../</_ExecutablePathPrefix>
</PropertyGroup>
<ItemGroup>
<!-- Create the ComputedRelativePath metadata from RelativePath -->
Expand Down Expand Up @@ -2072,10 +2072,10 @@
Condition="'$(_CanOutputAppBundle)' == 'true'"
>
<PropertyGroup>
<_AssemblyPublishDir Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">$(_RelativeAppBundlePath)\</_AssemblyPublishDir>
<_AssemblyPublishDir Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">$(_RelativeAppBundlePath)\Contents\$(_CustomBundleName)\</_AssemblyPublishDir>
<_DylibPublishDir Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS'">$(_RelativeAppBundlePath)\</_DylibPublishDir>
<_DylibPublishDir Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">$(_RelativeAppBundlePath)\Contents\$(_CustomBundleName)\</_DylibPublishDir>
<_AssemblyPublishDir Condition="'$(SdkIsMobile)' == 'true'">$(_RelativeAppBundlePath)\</_AssemblyPublishDir>
<_AssemblyPublishDir Condition="'$(SdkIsDesktop)' == 'true'">$(_RelativeAppBundlePath)\Contents\$(_CustomBundleName)\</_AssemblyPublishDir>
<_DylibPublishDir Condition="'$(SdkIsMobile)' == 'true'">$(_RelativeAppBundlePath)\</_DylibPublishDir>
<_DylibPublishDir Condition="'$(SdkIsDesktop)' == 'true'">$(_RelativeAppBundlePath)\Contents\$(_CustomBundleName)\</_DylibPublishDir>
<_ParsedRuntimeConfigFilePath Condition="'$(_ParsedRuntimeConfigFilePath)' == ''">$(DeviceSpecificIntermediateOutputPath)$(_RuntimeConfigurationFile)</_ParsedRuntimeConfigFilePath>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -2105,7 +2105,7 @@
<ResolvedFileToPublish
Update="@(ResolvedFileToPublish)"
RelativePath="$(_DylibPublishDir)\%(Filename)%(Extension)"
Condition="('$(_SdkIsSimulator)' != 'false' Or '$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And ('%(Extension)' == '.dylib' Or '%(Extension)' == '.so') " />
Condition="('$(_SdkIsSimulator)' != 'false' Or '$(SdkIsDesktop)' == 'true') And ('%(Extension)' == '.dylib' Or '%(Extension)' == '.so') " />

<!-- Don't publish any icu*dat file (by setting PublishFolderType = None) -->
<ResolvedFileToPublish
Expand Down
Loading
Loading