|
149 | 149 | </PropertyGroup>
|
150 | 150 | <!-- Non-C# packages (i.e. metapackages, natives) -->
|
151 | 151 | <PropertyGroup Condition="'$(SilkNativePackage)' == 'true' or '$(SilkMetapackage)' == 'true'">
|
152 |
| - <IncludeBuildOutput>false</IncludeBuildOutput> |
153 |
| - <NoWarn>NU5128</NoWarn> |
| 152 | + <IncludeBuildOutput Condition="'$(SilkNativeHasAndroidJars)' != 'true'">false</IncludeBuildOutput> |
| 153 | + <NoWarn>NU5128;$(NoWarn)</NoWarn> |
154 | 154 | </PropertyGroup>
|
155 | 155 | <!-- Public API -->
|
156 | 156 | <PropertyGroup Condition="'$(SilkTrackPublicAPI)' != 'true' or '$(TargetFramework)' == ''">
|
|
191 | 191 | <PackageVersion Condition="'$(VersionSuffix)' == ''">$(SilkVersion)</PackageVersion>
|
192 | 192 | <PackageVersion Condition="'$(VersionSuffix)' != ''">$(SilkVersion)-$(VersionSuffix)</PackageVersion>
|
193 | 193 | </PropertyGroup>
|
| 194 | + <!-- Native Packaging --> |
| 195 | + <PropertyGroup> |
| 196 | + <SilkVersionTxtPath>$(MSBuildProjectDirectory)/version.txt</SilkVersionTxtPath> |
| 197 | + <PackageVersion Condition="Exists('$(SilkVersionTxtPath)')">$([System.IO.File]::ReadAllText("$(SilkVersionTxtPath)"))</PackageVersion> |
| 198 | + </PropertyGroup> |
| 199 | + <ItemGroup Condition="'$(SilkNativePackage)' == 'true'"> |
| 200 | + <None Include="$(MSBuildProjectDirectory)/runtimes/**/*" Pack="true" PackagePath="runtimes" /> |
| 201 | + <!-- bundled in the aar instead --> |
| 202 | + <None Remove="$(MSBuildProjectDirectory)/runtimes/android*/**/*" Condition="'$(SilkNativeHasAndroidJars)' == 'true'" /> |
| 203 | + </ItemGroup> |
| 204 | + <ItemGroup Condition="'$(SilkNativePackage)' == 'true' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"> |
| 205 | + <AndroidNativeLibrary Include="$(MSBuildProjectDirectory)/runtimes/android*/native/*.so" /> |
| 206 | + <ProguardConfiguration Include="$(MSBuildProjectDirectory)/android/proguard.txt" Condition="Exists('$(MSBuildProjectDirectory)/android/proguard.txt')" /> |
| 207 | + <AndroidLibrary Include="$(MSBuildProjectDirectory)/android/*.jar" Bind="true" Pack="true" /> |
| 208 | + <TransformFile Include="$(MSBuildProjectDirectory)/android/*.xml" /> |
| 209 | + </ItemGroup> |
194 | 210 | <!-- Trimming -->
|
195 | 211 | <PropertyGroup Condition="'$(SilkTrimmingExempt)' == ''">
|
196 | 212 | <IsTrimmable>true</IsTrimmable>
|
|
200 | 216 | <TrimMode>full</TrimMode>
|
201 | 217 | </PropertyGroup>
|
202 | 218 | </Target>
|
| 219 | + |
| 220 | + |
| 221 | + <!-- Closest things to documentation on what the hell this voodoo does: |
| 222 | + https://github.com/NuGet/Home/issues/10063#issuecomment-713083004 |
| 223 | + https://github.com/xamarin/xamarin-android/pull/5242 |
| 224 | + https://github.com/dotnet/sdk/issues/14042 |
| 225 | + https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets#L54 |
| 226 | + https://github.com/xamarin/xamarin-android/issues/5957 |
| 227 | + https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetEmbeddedResources.md |
| 228 | +
|
| 229 | + This is an adaptation of what we used in Silk.NET 2.X to add files to packages, which was originally focused on |
| 230 | + Android. For 3.0, we're trying to lean as much as possible on the built-in stuff for e.g. jars as this is in a |
| 231 | + much better state these days. However, some of the links above may only be relevant with that context. --> |
| 232 | + <Target Name="SilkNativePackaging" Condition="'$(SilkNativePackage)' == 'true'"> |
| 233 | + <GetNuGetShortFolderName TargetFrameworkMoniker="$(TargetFrameworkMoniker)" TargetPlatformMoniker="$(TargetPlatformMoniker)"> |
| 234 | + <Output TaskParameter="NuGetShortFolderName" PropertyName="SilkNuGetShortFolderName" /> |
| 235 | + </GetNuGetShortFolderName> |
| 236 | + <ReadLinesFromFile File="$(MSBuildThisFileDirectory)eng/native/nuget/NativeNuGetPackage.targets"> |
| 237 | + <Output TaskParameter="Lines" ItemName="SilkNativeNuGetPackageTargets" /> |
| 238 | + </ReadLinesFromFile> |
| 239 | + <WriteLinesToFile File="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets" |
| 240 | + Lines="@(SilkNativeNuGetPackageTargets->'%(Identity)'->Replace('TO_BE_REPLACED_MTOUCH_NATIVE_REFERENCE_LINKER_FLAGS', '$(SilkNativeiOSLinkerFlags)')->Replace('TO_BE_REPLACED_PROPERTY_PREFIX', '$(MSBuildProjectName.Replace('.', '_'))'))" /> |
| 241 | + <WriteLinesToFile File="$(IntermediateOutputPath)$(TargetFramework)/_._" Lines="@(SilkDummyItem)" /> |
| 242 | + <ItemGroup> |
| 243 | + <TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets" |
| 244 | + Link="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" |
| 245 | + Pack="true" |
| 246 | + PackagePath="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" /> |
| 247 | + <TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets" |
| 248 | + Link="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" |
| 249 | + Pack="true" |
| 250 | + PackagePath="buildTransitive/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" /> |
| 251 | + <TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/_._" |
| 252 | + Link="lib/$(SilkNuGetShortFolderName)/_._" |
| 253 | + Pack="true" |
| 254 | + PackagePath="lib/$(SilkNuGetShortFolderName)/_._" |
| 255 | + Condition="'$(IncludeBuildOutput)' == 'false'" /> |
| 256 | + </ItemGroup> |
| 257 | + </Target> |
203 | 258 | </Project>
|
0 commit comments