[msbuild] Fixes archiving and copying files to Windows (#11277)

* [msbuild] Fixes Windows task namespace

* [msbuild] Fixes unzipping files from Windows

This is the same approach we're using on the Xamarin.iOS.Tasks project, we need to replace the System.Text.Encoding.CodePages reference assembly by it's runtime implementation before ilmerging it, otherwise when trying to unzip files from Windows we'll get a null ref exception because that's what the ref assembly implemented.

* [msbuild] Try to copy output to Windows before ending the XMA connection

When relying on BuildDependsOn we can end up running the targets after _SayGoodBye, which ends the XMA connection. `CopyDSYMFromMac` and `CopyAppBundleFromMac` need an active connection, since both copy files from the Mac to Windows.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
This commit is contained in:
Emanuel Fernandez Dell'Oca 2021-04-22 07:02:38 -03:00 коммит произвёл GitHub
Родитель 94ca4e7a03
Коммит 965ab98b84
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 22 добавлений и 8 удалений

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

@ -5,7 +5,7 @@ using System;
using System.IO;
using Xamarin.iOS.Tasks.Windows.Properties;
namespace Xamarin.iOS.Tasks.Windows.Tasks {
namespace Xamarin.iOS.Tasks.Windows {
public class LocalUnzip : Task {
[Required]
public string ZipFilePath { get; set; }

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

@ -53,11 +53,6 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
</Target>
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
CopyAppBundleFromMac;
CopyDSYMFromMac
</BuildDependsOn>
<CreateIpaDependsOn>
$(CreateIpaDependsOn);
CopyIpaFromMac
@ -73,7 +68,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
</ArchiveDependsOn>
</PropertyGroup>
<Target Name="CopyAppBundleFromMac" Condition="'$(OutputType)' == 'Exe' And '$(IsMacEnabled)' == 'true' And '$(CopyAppBundle)' == 'true'">
<Target Name="CopyAppBundleFromMac" Condition="'$(OutputType)' == 'Exe' And '$(IsMacEnabled)' == 'true' And '$(CopyAppBundle)' == 'true'" BeforeTargets="BeforeDisconnect">
<!-- Creates AppBundle dir on the output path -->
<MakeDir Condition="'$(MtouchTargetsEnabled)' And '$(IsMacEnabled)' == 'true'" SessionId="$(BuildSessionId)" Directories="$(DeviceSpecificOutputPath)AppBundle" />
<!--Zip AppBundle-->
@ -157,7 +152,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
</CopyLongPaths>
</Target>
<Target Name="CopyDSYMFromMac" DependsOnTargets="_SayHello" Condition="'$(IsMacEnabled)' == 'true' And '$(IsAppExtension)' == 'false' And '$(ComputedPlatform)' == 'iPhone' And '$(CopyDSYM)' == 'true' And ('$(BuildIpa)' == 'true' Or '$(CopyAppBundle)' == 'true')">
<Target Name="CopyDSYMFromMac" DependsOnTargets="_SayHello" Condition="'$(IsMacEnabled)' == 'true' And '$(IsAppExtension)' == 'false' And '$(ComputedPlatform)' == 'iPhone' And '$(CopyDSYM)' == 'true' And ('$(BuildIpa)' == 'true' Or '$(CopyAppBundle)' == 'true')" BeforeTargets="BeforeDisconnect">
<!--Copy watchOS Dsym folders from Mac-->
<MSBuild Projects="@(_WatchAppReferenceWithConfigurationExistent)" Targets="CopyDSYMFromMac" Properties="%(_WatchAppReferenceWithConfigurationExistent.SetConfiguration); %(_WatchAppReferenceWithConfigurationExistent.SetPlatform); BuildIpa=true" Condition="'$(IsWatchApp)' == 'false' And '@(_WatchAppReferenceWithConfigurationExistent)' != '' And '$(_BuildReferencedExtensionProjects)' != 'true'"></MSBuild>
<!--Look for all *.dsym folders int the output path of the main app -->

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

@ -42,4 +42,23 @@
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)..\ILMerge.targets" />
<!-- Replaces the reference assemblies by the runtime implementation -->
<Target Name="CopyRuntimeAssemblies" BeforeTargets="ILRepack">
<ItemGroup>
<ReferenceCopyLocalToRemove Include="@(ReferenceCopyLocalPaths)" Condition="'%(FileName)' == 'System.Text.Encoding.CodePages'" />
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalToRemove)" />
<ReferencePathToRemove Include="@(ReferencePath)" Condition="'%(FileName)' == 'System.Text.Encoding.CodePages'" />
<ReferencePath Remove="@(ReferencePathToRemove)" />
<ReferencePathToAdd Include="@(RuntimeTargetsCopyLocalItems)" Condition="'%(RuntimeIdentifier)' == 'win' And '%(FileName)' == 'System.Text.Encoding.CodePages'" />
<ReferencePath Include="@(ReferencePathToAdd)">
<DestinationSubDirectory />
</ReferencePath>
</ItemGroup>
</Target>
</Project>