Skip to content

Commit

Permalink
feat: adding SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jan 12, 2024
1 parent 2277025 commit f7c569c
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
85 changes: 85 additions & 0 deletions src/Uno.Sdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!--
***********************************************************************************************
WARNING:
DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (C) Uno Platform Inc. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Sdk="Microsoft.NET.Sdk" Condition=" '$(UsingMicrosoftNETSdk)' != 'true' " />

<PropertyGroup>
<!-- Required for Hot Reload (See https://github.com/dotnet/sdk/issues/36666) -->
<IncludeSourceRevisionInInformationalVersion Condition="'$(Configuration)'=='Debug'">false</IncludeSourceRevisionInInformationalVersion>

<_UnoImportMicrosoftNETSdkTargets Condition=" '$(UsingMicrosoftNETSdk)' != 'true' ">true</_UnoImportMicrosoftNETSdkTargets>

<IsAndroid>false</IsAndroid>
<IsIOS>false</IsIOS>
<IsMac>false</IsMac>
<IsMacCatalyst>false</IsMacCatalyst>
<IsWinAppSdk>false</IsWinAppSdk>
<UnoVersion>DefaultUnoVersion</UnoVersion>
</PropertyGroup>

<Choose>
<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PropertyGroup>
<IsAndroid>true</IsAndroid>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">21.0</SupportedOSPlatformVersion>
<AndroidManifest Condition=" $(AndroidManifest) == '' AND '$(SingleProject)' == 'true' AND Exists('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Android', 'AndroidManifest.xml'))') ">Android\AndroidManifest.xml</AndroidManifest>
<AndroidManifest Condition=" $(AndroidManifest) == '' AND '$(SingleProject)' == 'true' AND Exists('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Platforms', 'Android', 'AndroidManifest.xml'))') ">Platforms\Android\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>

<ItemGroup>
<AndroidEnvironment Condition=" '$(SingleProject)' == 'true' AND Exists('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Android', 'environment.conf'))') " Include="Android\environment.conf" />
<AndroidEnvironment Condition=" '$(SingleProject)' == 'true' AND Exists('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Platforms', 'Android', 'environment.conf'))') " Include="Platforms\Android\environment.conf" />
</ItemGroup>
</When>
<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<PropertyGroup>
<IsIOS>true</IsIOS>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">14.2</SupportedOSPlatformVersion>
</PropertyGroup>
</When>
<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos'">
<PropertyGroup>
<IsMac>true</IsMac>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">10.14</SupportedOSPlatformVersion>
</PropertyGroup>
</When>
<When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
<PropertyGroup>
<IsMacCatalyst>true</IsMacCatalyst>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">14.0</SupportedOSPlatformVersion>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.Contains('windows10'))">
<PropertyGroup>
<IsWinAppSdk>true</IsWinAppSdk>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">10.0.18362.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition=" $(TargetPlatformMinVersion) == '' ">$(SupportedOSPlatformVersion)</TargetPlatformMinVersion>
<RuntimeIdentifiers Condition=" $(RuntimeIdentifiers) == '' ">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<EnableCoreMrtTooling Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">false</EnableCoreMrtTooling>
</PropertyGroup>
</When>
</Choose>

<!-- Taken from: https://github.com/dotnet/maui/blob/c02a6706534888ccea577d771c9edfc820bfc001/src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.After.targets#L16C3-L26C15 -->
<!-- SingleProject-specific features -->
<ItemGroup Condition=" '$(SingleProject)' == 'true' ">
<ProjectCapability Include="Msix" />
<ProjectCapability Include="MauiSingleProject" />
<ProjectCapability Include="LaunchProfiles" />
<!-- If VS is older than Dev17 -->
<ProjectCapability Include="XamarinStaticLaunchProfiles" Condition=" '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' &lt; '17.0' " />
<!-- Otherwise define LaunchProfilesGroupByPlatformFilters by default -->
<ProjectCapability Include="LaunchProfilesGroupByPlatformFilters" Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &gt;= '17.0' " />
<ProjectCapability Include="SingleTargetBuildForStartupProjects" Condition=" '$(EnableSingleTargetBuildForStartupProjects)' != 'false' " />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions src/Uno.Sdk/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
***********************************************************************************************
WARNING:
DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (C) Uno Platform Inc. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Sdk="Microsoft.NET.Sdk" Condition=" '$(_UnoImportMicrosoftNETSdkTargets)' == 'true' " />

<!-- <Import Project="Uno.CrossTargetting.targets" Condition=" '$(EnableUnoCrossTargetting)' == 'true' " /> -->

<ItemGroup>
<!-- Removes native usings to avoid Ambiguous reference -->
<Using Remove="@(Using->HasMetadata('Platform'))" />
</ItemGroup>
</Project>
57 changes: 57 additions & 0 deletions src/Uno.Sdk/Uno.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.Build.NoTargets/3.7.0">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Uno.WinUI.Sdk</PackageId>
<PackageId Condition="'$(IsUnoUI)' == 'true'">Uno.UI.Sdk</PackageId>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NoWarn>$(NoWarn);NU5128</NoWarn>
<PackageType>MSBuildSdk</PackageType>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>

<ItemGroup>
<SdkFile Include="Sdk\*" />
</ItemGroup>

<Target Name="CopySdkFiles" BeforeTargets="Pack">
<Copy SourceFiles="@(SdkFile)" DestinationFolder="$(IntermediateOutputPath)Sdk" SkipUnchangedFiles="true" />
</Target>

<Target Name="ReplacePackageVersion" AfterTargets="CopySdkFiles">
<ItemGroup>
<_IntermediateSdkFile Include="$(IntermediateOutputPath)Sdk\*.props;$(IntermediateOutputPath)Sdk\*.targets" />
</ItemGroup>

<ReplaceFileText
Filename="%(_IntermediateSdkFile.Identity)"
MatchExpression="DefaultUnoVersion"
ReplacementText="$(PackageVersion)" />

<ItemGroup>
<None Include="%(SdkFile.Identity)" Pack="true" PackagePath="Sdk\%(SdkFile.Filename)%(SdkFile.Extension)" />
</ItemGroup>
</Target>

<!-- Using Regex Replace prevents XmlPoke from replacing Tabs with Spaces -->
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
Filename,
Regex.Replace(File.ReadAllText(Filename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>

</Project>

0 comments on commit f7c569c

Please sign in to comment.