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
14 changes: 14 additions & 0 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
<_XamarinCommonPropsHasBeenImported>true</_XamarinCommonPropsHasBeenImported>
</PropertyGroup>


<!-- Story-time! MigrateToNewXMIdentifier is special because it un-does a lie we started telling from the
beginning of Full (called Xamarin.Mac 4.5 back then). Back then, we released Modern (called Mobile) and
when many customers upgraded from Classic they broke in terrible ways as none of their nugets worked.
No nugets in the wild had heard of the Xamarin.Mac TFI and thus didn't support it. To "fix" this use case,
we created Full (XM 4.5) and _lied_ with our TFI claiming to be .NETFramework. Well we were close enough
for a vast majority of packages to work. However, this made creating Full specific package flavors impossible.
Now that we're getting "real" nuget support, we need to stop lying without breaking the world. We're starting by
allowing "opt-in" MigrateToNewXMIdentifier which will swap your declared TFI to the new hotness.
-->
<PropertyGroup Condition=" '$(MigrateToNewXMIdentifier)' == 'true' And '$(TargetFrameworkIdentifier)' != 'Xamarin.Mac' And '$(UseXamMacFullFramework)' == 'true' ">
<TargetFrameworkIdentifier>Xamarin.Mac.NET</TargetFrameworkIdentifier>
</PropertyGroup>

<PropertyGroup>
<IsXBuild Condition="'$(MSBuildRuntimeVersion)' == ''">true</IsXBuild>
<IsXBuild Condition="'$(MSBuildRuntimeVersion)' != ''">false</IsXBuild>
Expand Down
1 change: 1 addition & 0 deletions tests/mmptest/mmptest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="..\..\tools\mmp\SdkVersions.cs">
<Link>SdkVersions.cs</Link>
</Compile>
<Compile Include="src\TargetFrameworkMutateTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
Expand Down
58 changes: 58 additions & 0 deletions tests/mmptest/src/TargetFrameworkMutateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Linq;
using NUnit.Framework;
using Xamarin.Utils;

namespace Xamarin.MMP.Tests
{
[TestFixture]
public class TargetFrameworkMutateTests
{
const string MigrateCSProjTag = "<MigrateToNewXMIdentifier>true</MigrateToNewXMIdentifier>";

public bool MatchesTFI (string expected, string buildOutput)
{
string tfiLine = buildOutput.SplitLines ().FirstOrDefault (x => x.StartsWith ("TargetFrameworkIdentifier =", StringComparison.Ordinal));
if (tfiLine == null)
return false;
return tfiLine.Contains (expected);
}

[TestCase (true)]
[TestCase (false)]
public void ShouldNotMutateWithoutOptInFlag (bool xm45)
{
MMPTests.RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
XM45 = xm45
};
var buildOutput = TI.TestUnifiedExecutable (test).BuildOutput;
string standardTFI = xm45 ? ".NETFramework" : "Xamarin.Mac";
Assert.True (MatchesTFI (standardTFI, buildOutput), $"Build did not have expected TFI: {TI.PrintRedirectIfLong (buildOutput)}");
});
}

[Test]
public void ShouldNotMutateModernWithOptInFlag ()
{
MMPTests.RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { CSProjConfig = MigrateCSProjTag };
var buildOutput = TI.TestUnifiedExecutable (test).BuildOutput;
Assert.True (MatchesTFI ("Xamarin.Mac", buildOutput), $"Build did not have expected TFI: {TI.PrintRedirectIfLong (buildOutput)}");
});
}

[Test]
public void ShouldMutateFullWithOptInFlag ()
{
MMPTests.RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
XM45 = true,
CSProjConfig = MigrateCSProjTag
};
var buildOutput = TI.TestUnifiedExecutable (test).BuildOutput;
Assert.True (MatchesTFI ("Xamarin.Mac.NET", buildOutput), $"Build did not have expected TFI: {TI.PrintRedirectIfLong (buildOutput)}");
});
}
}
}