Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] Use net5.0-[ios|tvos|watchos|macos] TargetFrameworks. #9532

Merged
merged 7 commits into from
Aug 31, 2020
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
1 change: 1 addition & 0 deletions dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nupkgs
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.SupportedTargetPlatforms.props

10 changes: 10 additions & 0 deletions dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define DefineTargets
$(1)_NUGET_TARGETS = \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/Sdk/Sdk.targets \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/Sdk/Sdk.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.SupportedTargetPlatforms.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.DefaultItems.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.props \
$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.targets \
Expand Down Expand Up @@ -61,8 +62,17 @@ targets/%.props: targets/%.template.props Makefile $(TOP)/Make.config.inc $(TOP)
-e "s/@CURRENT_HASH_LONG@/$(CURRENT_HASH_LONG)/g" \
$< > $@

define SupportedTargetPlatforms
Microsoft.$(1).Sdk/targets/Microsoft.$(1).Sdk.SupportedTargetPlatforms.props: $(TOP)/Versions-ios.plist.in $(TOP)/Versions-mac.plist.in Makefile ./generate-target-platforms.csharp Makefile
$(Q) rm -f $$@.tmp
$(Q) ./generate-target-platforms.csharp $(1) $$@.tmp
$(Q) mv $$@.tmp $$@
endef
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call SupportedTargetPlatforms,$(platform))))

TEMPLATED_FILES = \
targets/Xamarin.Shared.Sdk.Versions.props \
$(foreach platform,$(DOTNET_PLATFORMS),Microsoft.$(platform).Sdk/targets/Microsoft.$(platform).Sdk.SupportedTargetPlatforms.props) \

nupkgs/$(IOS_NUGET).%.nupkg: CURRENT_VERSION_NO_METADATA=$(IOS_NUGET_VERSION_NO_METADATA)
nupkgs/$(TVOS_NUGET).%.nupkg: CURRENT_VERSION_NO_METADATA=$(TVOS_NUGET_VERSION_NO_METADATA)
Expand Down
43 changes: 43 additions & 0 deletions dotnet/generate-target-platforms.csharp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env /Library/Frameworks/Mono.framework/Commands/csharp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// arguments are: <platform> <outputPath>

using System.IO;
using System.Xml;

var args = Environment.GetCommandLineArgs ();
var expectedArgumentCount = 2;
if (args.Length != expectedArgumentCount + 2 /* 2 default arguments (executable + script) + 'expectedArgumentCount' arguments we're interested in */) {
// first arg is "/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5/csharp.exe"
// second arg the script itself
// then comes the ones we care about
Console.WriteLine ($"Need {expectedArgumentCount} arguments, got {args.Length - 2}");
Environment.Exit (1);
return;
}

var platform = args [2];
var outputPath = args [3];
var plistPath = platform == "macOS" ? "../Versions-mac.plist.in" : "../Versions-ios.plist.in";

var doc = new XmlDocument ();
doc.Load (plistPath);
var nodes = doc.SelectNodes ($"/plist/dict/key[text()='KnownVersions']/following-sibling::dict[1]/key[text()='{platform}']/following-sibling::array[1]/string");

using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ($"<!-- This file contains a generated list of the {platform} platform versions that are supported for this SDK -->");
writer.WriteLine ($"<!-- Generation script: https://github.com/xamarin/xamarin-macios/blob/main/dotnet/generate-target-platforms.csharp -->");
writer.WriteLine ("<Project>");
writer.WriteLine ("\t<ItemGroup>");

foreach (XmlNode n in nodes)
writer.WriteLine ($"\t\t<{platform}SupportedTargetPlatform Include=\"{n.InnerText}\" />");

writer.WriteLine ("\t</ItemGroup>");
writer.WriteLine ("\t<ItemGroup>");
writer.WriteLine ($"\t\t<SupportedTargetPlatform Condition=\"'$(TargetPlatformIdentifier)' == '{platform}'\" Include=\"@({platform}SupportedTargetPlatform)\" />");
writer.WriteLine ("\t</ItemGroup>");
writer.WriteLine ("</Project>");
}

Environment.Exit (0);
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@
<TargetPlatformIdentifier Condition="'$(TargetPlatformIdentifier)' == 'watchos'">watchOS</TargetPlatformIdentifier>
<TargetPlatformIdentifier Condition="'$(TargetPlatformIdentifier)' == 'macos'">macOS</TargetPlatformIdentifier>
</PropertyGroup>

<!-- Set the default TargetPlatformVersion if it wasn't specified in the TargetFramework variable. This must be set after importing Sdk.targets (in Xamarin.Shared.Sdk.targets) -->
<PropertyGroup>
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">$(_DefaultTargetPlatformVersion)</TargetPlatformVersion>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.Versions.template.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,18 @@
<_PackageVersion Condition=" '$(_PlatformName)' == 'watchOS' ">@WATCHOS_NUGET_VERSION_FULL@</_PackageVersion>
<_PackageVersion Condition=" '$(_PlatformName)' == 'macOS' ">@MACOS_NUGET_VERSION_FULL@</_PackageVersion>
</PropertyGroup>

<!-- Defines the default platform version if it's not specified in the TFM. The default should not change for a given .NET version:
* We release support for iOS 14.5 with .NET 6
* Apple releases iOS 15.0, we're still using .NET 6. This default continues to be iOS 14.5
* .NET 7 is shipped, and at this point we bump the default to iOS 15.0
Ref: https://github.com/dotnet/designs/blob/8e6394406d44f75f30ea2259a425cb9e38d75b69/accepted/2020/net5/net5.md#os-versions
-->
<PropertyGroup>
<!-- This section specifies the default platform version for .NET 5.0 -->
<_DefaultTargetPlatformVersion Condition=" '$(_PlatformName)' == 'iOS' ">13.6</_DefaultTargetPlatformVersion>
<_DefaultTargetPlatformVersion Condition=" '$(_PlatformName)' == 'tvOS' ">13.4</_DefaultTargetPlatformVersion>
<_DefaultTargetPlatformVersion Condition=" '$(_PlatformName)' == 'watchOS' ">6.2</_DefaultTargetPlatformVersion>
<_DefaultTargetPlatformVersion Condition=" '$(_PlatformName)' == 'macOS' ">10.15</_DefaultTargetPlatformVersion>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@

<!-- Default item includes (globs and implicit references) -->
<Import Project="Microsoft.$(_PlatformName).Sdk.DefaultItems.props" />

<!-- This contains the OS versions we support for target platform -->
<Import Project="Microsoft.$(_PlatformName).Sdk.SupportedTargetPlatforms.props" />
</Project>
4 changes: 4 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

<PropertyGroup>
<TargetPlatformSupported Condition=" '$(TargetPlatformIdentifier)' == '$(_PlatformName)' ">true</TargetPlatformSupported>
</PropertyGroup>

<!-- Default item includes (globs and implicit references) -->
<Import Project="Xamarin.Shared.Sdk.DefaultItems.targets" />
<Import Project="Xamarin.Shared.Sdk.TargetFrameworkInference.targets" />
Expand Down
2 changes: 1 addition & 1 deletion external/Touch.Unit
2 changes: 1 addition & 1 deletion tests/BundledResources/dotnet/iOS/BundledResources.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-ios</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-macos</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion tests/BundledResources/dotnet/tvOS/BundledResources.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-tvos</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-watchos</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
3 changes: 3 additions & 0 deletions tests/EmbeddedResources/dotnet/iOS/EmbeddedResources.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.targets" />
</Project>
3 changes: 3 additions & 0 deletions tests/EmbeddedResources/dotnet/macOS/EmbeddedResources.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.targets" />
</Project>
1 change: 0 additions & 1 deletion tests/EmbeddedResources/dotnet/shared.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<LangVersion>latest</LangVersion>

Expand Down
3 changes: 3 additions & 0 deletions tests/EmbeddedResources/dotnet/tvOS/EmbeddedResources.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-watchos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.targets" />
</Project>
1 change: 1 addition & 0 deletions tests/bindings-test/dotnet/iOS/bindings-test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-ios</TargetFramework>
<NativeLibName>ios-fat</NativeLibName>
</PropertyGroup>
<Import Project="..\shared.targets" />
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test/dotnet/macOS/bindings-test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-macos</TargetFramework>
<NativeLibName>macos</NativeLibName>
</PropertyGroup>
<Import Project="..\shared.targets" />
Expand Down
1 change: 0 additions & 1 deletion tests/bindings-test/dotnet/shared.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>bindingstest</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\product.snk</AssemblyOriginatorKeyFile>
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test/dotnet/tvOS/bindings-test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-tvos</TargetFramework>
<NativeLibName>tvos-fat</NativeLibName>
</PropertyGroup>
<Import Project="..\shared.targets" />
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test/dotnet/watchOS/bindings-test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-watchos</TargetFramework>
<NativeLibName>watchos-fat</NativeLibName>
</PropertyGroup>
<Import Project="..\shared.targets" />
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test2/dotnet/iOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-ios</TargetFramework>
<NativeLibName>ios-fat</NativeLibName>
<PlatformName>iOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test2/dotnet/macOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-macos</TargetFramework>
<NativeLibName>macos</NativeLibName>
<PlatformName>macOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
Expand Down
1 change: 0 additions & 1 deletion tests/bindings-test2/dotnet/shared.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>bindingstest2</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\product.snk</AssemblyOriginatorKeyFile>
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test2/dotnet/tvOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-tvos</TargetFramework>
<NativeLibName>tvos-fat</NativeLibName>
<PlatformName>tvOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
Expand Down
1 change: 1 addition & 0 deletions tests/bindings-test2/dotnet/watchOS/bindings-test2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-watchos</TargetFramework>
<NativeLibName>watchos-fat</NativeLibName>
<PlatformName>watchOS</PlatformName>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/MyClassLibrary/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-ios</TargetFramework>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion tests/dotnet/MyClassLibrary/iOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-ios</TargetFramework>
</PropertyGroup>
</Project>

2 changes: 1 addition & 1 deletion tests/dotnet/MyClassLibrary/macOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-macos</TargetFramework>
</PropertyGroup>
</Project>

2 changes: 1 addition & 1 deletion tests/dotnet/MyClassLibrary/tvOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-tvos</TargetFramework>
</PropertyGroup>
</Project>

2 changes: 1 addition & 1 deletion tests/dotnet/MyClassLibrary/watchOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-watchos</TargetFramework>
</PropertyGroup>
</Project>

2 changes: 1 addition & 1 deletion tests/dotnet/MyCocoaApp/MyCocoaApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.macOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-macos</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/MySingleView/MySingleView.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-ios</TargetFramework>
<RuntimeIdentifier>ios-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/MyTVApp/MyTVApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.tvOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-tvos</TargetFramework>
<RuntimeIdentifier>tvos-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/MyWatchApp/MyWatchApp/MyWatchApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-watchos</TargetFramework>
<RuntimeIdentifier>watchos-x86</RuntimeIdentifier>
<IsWatchOSApp>true</IsWatchOSApp>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.iOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-ios</TargetFramework>
<RuntimeIdentifier>ios-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.watchOS.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-watchos</TargetFramework>
<RuntimeIdentifier>watchos-x86</RuntimeIdentifier>
<IsAppExtension>true</IsAppExtension>
</PropertyGroup>
Expand Down
Loading