[macos] System mono should resolve non-XM libraries from system (#2480)

- https://bugzilla.xamarin.com/show_bug.cgi?id=58703
- Was broken on msbuild but undetected due to https://bugzilla.xamarin.com/show_bug.cgi?id=53164
- Unified45Build_CompileToNativeOutput was broken in a recent commit bf53e6204d0950acd5f8efcce8732bd8d8
- This was not caught as the mmp tests are not run by default
- The test was bad/wrong, and checking msbuild not mmp ouput anyway, so fixing.
This commit is contained in:
Chris Hamons 2017-08-14 13:17:10 -05:00 коммит произвёл GitHub
Родитель 270910bdc1
Коммит e5d012c5b8
3 изменённых файлов: 45 добавлений и 14 удалений

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

@ -64,16 +64,50 @@ Copyright (C) 2014 Xamarin. All rights reserved.
<XamarinMacFrameworkRoot>/Library/Frameworks/Xamarin.Mac.framework/Versions/Current</XamarinMacFrameworkRoot> <XamarinMacFrameworkRoot>/Library/Frameworks/Xamarin.Mac.framework/Versions/Current</XamarinMacFrameworkRoot>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.Mac' And '$(UseXamMacFullFramework)' != 'true'"> <Choose>
<When Condition=" '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
<PropertyGroup>
<TargetFrameworkName>Modern</TargetFrameworkName>
<MacBclPath>$(XamarinMacFrameworkRoot)/lib/mono/Xamarin.Mac</MacBclPath>
</PropertyGroup>
</When>
<When Condition=" '$(TargetFrameworkIdentifier)' != 'Xamarin.Mac' And '$(UseXamMacFullFramework)' == 'true'">
<PropertyGroup>
<TargetFrameworkName>Full</TargetFrameworkName>
<MacBclPath>$(XamarinMacFrameworkRoot)/lib/mono/4.5</MacBclPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworkName>System</TargetFrameworkName>
<MacBclPath>$(XamarinMacFrameworkRoot)/lib/mono/4.5</MacBclPath>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup Condition="'$(TargetFrameworkName)' == 'Full'">
<AssemblySearchPaths>$(XamarinMacFrameworkRoot)/lib/reference/full;$(XamarinMacFrameworkRoot)/lib/mono;$(AssemblySearchPaths)</AssemblySearchPaths> <AssemblySearchPaths>$(XamarinMacFrameworkRoot)/lib/reference/full;$(XamarinMacFrameworkRoot)/lib/mono;$(AssemblySearchPaths)</AssemblySearchPaths>
</PropertyGroup> </PropertyGroup>
<!-- Do not resolve from the GAC under any circumstances in Mobile or XM45 --> <!-- Do not resolve from the GAC in Modern or Full unless allow-unsafe-gac-resolution is passed in -->
<PropertyGroup Condition="(('$(TargetFrameworkIdentifier)' != 'Xamarin.Mac' And '$(UseXamMacFullFramework)' == 'true') Or '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac') And !$(MonoBundlingExtraArgs.Contains('--allow-unsafe-gac-resolution'))" > <PropertyGroup Condition="'$(TargetFrameworkName)' != 'System' And !$(MonoBundlingExtraArgs.Contains('--allow-unsafe-gac-resolution'))" >
<AssemblySearchPaths>$([System.String]::Copy('$(AssemblySearchPaths)').Replace('{GAC}',''))</AssemblySearchPaths> <AssemblySearchPaths>$([System.String]::Copy('$(AssemblySearchPaths)').Replace('{GAC}',''))</AssemblySearchPaths>
<AssemblySearchPaths Condition="'$(MSBuildRuntimeVersion)' != ''">$(AssemblySearchPaths.Split(';'))</AssemblySearchPaths> <AssemblySearchPaths Condition="'$(MSBuildRuntimeVersion)' != ''">$(AssemblySearchPaths.Split(';'))</AssemblySearchPaths>
</PropertyGroup> </PropertyGroup>
<!-- Location of Libraries -->
<Target Name="FixTargetFrameworkDirectory" AfterTargets="GetReferenceAssemblyPaths" Condition="('$(OS)' != 'Windows_NT')">
<PropertyGroup>
<!-- For Modern / Full we overwrite TargetFrameworkDirectory to resolve non XM assemblies from our location only -->
<TargetFrameworkDirectory Condition="'$(TargetFrameworkName)' != 'System'">$(MacBclPath);@(DesignTimeFacadeDirectories)</TargetFrameworkDirectory>
<!-- For system we extend, not overwrite TargetFrameworkDirectory. -->
<!-- mscorlib, System, and other BCL libs must come from Mono System to prevent corlib mistmatches. Xamarin.Mac.dll must come from XM/lib/mono/4.5/ -->
<!-- If we find cases of other non-XM assemblies being resolved from XM paths, we can look into using CandidateAssemblyFiles but it is msbuild only. -->
<TargetFrameworkDirectory Condition="'$(TargetFrameworkName)' == 'System'">$(TargetFrameworkDirectory);$(MacBclPath)</TargetFrameworkDirectory>
</PropertyGroup>
</Target>
<PropertyGroup> <PropertyGroup>
<_CanOutputAppBundle>False</_CanOutputAppBundle> <_CanOutputAppBundle>False</_CanOutputAppBundle>
<_CanOutputAppBundle Condition="'$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true'">true</_CanOutputAppBundle> <_CanOutputAppBundle Condition="'$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true'">true</_CanOutputAppBundle>

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

@ -16,21 +16,19 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com)
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- MSBuild specific hacks - Teach msbuild where to find our BCL and facades --> <!-- MSBuild specific hacks - Teach msbuild where to find our BCL and facades -->
<!-- Location of mscorlib -->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'"> <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<MacBclPath Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.Mac'">$(XamarinMacFrameworkRoot)/lib/mono/4.5</MacBclPath> <FrameworkPathOverride Condition="'$(TargetFrameworkName)' != 'System'">$(MacBclPath)</FrameworkPathOverride>
<MacBclPath Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">$(XamarinMacFrameworkRoot)/lib/mono/Xamarin.Mac</MacBclPath>
<FrameworkPathOverride>$(MacBclPath)</FrameworkPathOverride>
</PropertyGroup> </PropertyGroup>
<Target Name="FixTargetFrameworkDirectory" AfterTargets="GetReferenceAssemblyPaths" Condition="'$(OS)' != 'Windows_NT'">
<ItemGroup> <Target Name="FixDesignTimeFacades" AfterTargets="GetReferenceAssemblyPaths" Condition="('$(OS)' != 'Windows_NT')">
<ItemGroup>
<DesignTimeFacadeDirectories Remove="@(DesignTimeFacadeDirectories)" /> <DesignTimeFacadeDirectories Remove="@(DesignTimeFacadeDirectories)" />
<DesignTimeFacadeDirectories Include="$(MacBclPath)/Facades/" /> <DesignTimeFacadeDirectories Include="$(MacBclPath)/Facades/" />
</ItemGroup> </ItemGroup>
<PropertyGroup>
<TargetFrameworkDirectory>$(MacBclPath);@(DesignTimeFacadeDirectories)</TargetFrameworkDirectory>
</PropertyGroup>
</Target> </Target>
<!-- Modern/Mobile does not get ImplicitlyExpandDesignTimeFacades as Microsoft.NETFramework.CurrentVersion.targets isn't pulled in --> <!-- Modern/Mobile does not get ImplicitlyExpandDesignTimeFacades as Microsoft.NETFramework.CurrentVersion.targets isn't pulled in -->
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Mac.Common.ImplicitFacade.msbuild.targets" Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'"/> <Import Project="$(MSBuildThisFileDirectory)Xamarin.Mac.Common.ImplicitFacade.msbuild.targets" Condition="'$(TargetFrameworkName)' == 'Modern'"/>
</Project> </Project>

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

@ -641,8 +641,7 @@ namespace Xamarin.MMP.Tests
RunMMPTest (tmpDir => { RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { XM45 = true }; TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { XM45 = true };
var output = TI.TestUnifiedExecutable (test); var output = TI.TestUnifiedExecutable (test);
Assert.That (output.BuildOutput, Contains.Substring ("TargetFrameworkIdentifier: .NETFramework")); Assert.That (output.BuildOutput, Contains.Substring ("Selected target framework: .NETFramework,Version=v4.5; API: Unified"));
Assert.That (output.BuildOutput, Contains.Substring ("TargetFrameworkVersion: v4.5"));
}); });
} }