Skip to content

Commit

Permalink
[net7] include net6 templates (#8203)
Browse files Browse the repository at this point in the history
* Previous template pack version - Make this the released nuget package version as defined in version.props by a new variable.
* Make --framework and -f work!
* Support older SDKs

Co-authored-by: Matthew Leibowitz <[email protected]>
  • Loading branch information
Redth and mattleibow authored Jul 7, 2022
1 parent 2d1b9f4 commit 724e795
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 61 deletions.
11 changes: 9 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<_MauiDotNetVersionMinor Condition="'$(_MauiDotNetVersionMinor)' == ''">0</_MauiDotNetVersionMinor>
<_MauiDotNetVersion Condition="'$(_MauiDotNetVersion)' == ''">$(_MauiDotNetVersionMajor).$(_MauiDotNetVersionMinor)</_MauiDotNetVersion>
<_MauiDotNetTfm Condition="'$(_MauiDotNetTfm)' == ''">net$(_MauiDotNetVersion)</_MauiDotNetTfm>

<_MauiPreviousDotNetVersionMajor Condition="'$(_MauiPreviousDotNetVersionMajor)' == ''">6</_MauiPreviousDotNetVersionMajor>
<_MauiPreviousDotNetVersionMinor Condition="'$(_MauiPreviousDotNetVersionMinor)' == ''">0</_MauiPreviousDotNetVersionMinor>
<_MauiPreviousDotNetVersion Condition="'$(_MauiPreviousDotNetVersion)' == ''">$(_MauiPreviousDotNetVersionMajor).$(_MauiPreviousDotNetVersionMinor)</_MauiPreviousDotNetVersion>
<_MauiPreviousDotNetVersionNoDot Condition="'$(_MauiPreviousDotNetVersionNoDot)' == ''">$(_MauiPreviousDotNetVersionMajor)$(_MauiPreviousDotNetVersionMinor)</_MauiPreviousDotNetVersionNoDot>
<_MauiPreviousDotNetTfm Condition="'$(_MauiPreviousDotNetTfm)' == ''">net$(_MauiPreviousDotNetVersion)</_MauiPreviousDotNetTfm>

<_MauiTargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</_MauiTargetPlatformIdentifier>
<_MauiNoTargetPlatform Condition="'$(_MauiTargetPlatformIdentifier)' == ''">True</_MauiNoTargetPlatform>
<_MauiTargetPlatformIsAndroid Condition="'$(_MauiTargetPlatformIdentifier)' == 'android'">True</_MauiTargetPlatformIsAndroid>
Expand All @@ -18,8 +25,8 @@

<IncludeWindowsTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) or '$(Packing)' == 'true'">true</IncludeWindowsTargetFrameworks>
<IncludeTizenTargetFrameworks Condition="'$(CI)' == 'true' or '$(TF_BUILD)' == 'true' or
Exists('$(DOTNET_ROOT)\sdk-manifests\$(DotNetVersionBand)\samsung.net.sdk.tizen\WorkloadManifest.json') or
Exists('$(ProgramFiles)\dotnet\sdk-manifests\$(DotNetVersionBand)\samsung.net.sdk.tizen\WorkloadManifest.json')">true</IncludeTizenTargetFrameworks>
Exists('$(DOTNET_ROOT)\sdk-manifests\$(DotNetSdkManifestsFolder)\samsung.net.sdk.tizen\WorkloadManifest.json') or
Exists('$(ProgramFiles)\dotnet\sdk-manifests\$(DotNetSdkManifestsFolder)\samsung.net.sdk.tizen\WorkloadManifest.json')">true</IncludeTizenTargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<!-- Current previous .NET SDK major version's stable release of MAUI packages -->
<MicrosoftMauiPreviousDotNetReleasedVersion>6.0.405</MicrosoftMauiPreviousDotNetReleasedVersion>
<!-- dotnet/installer -->
<MicrosoftDotnetSdkInternalPackageVersion>7.0.100-preview.6.22316.8</MicrosoftDotnetSdkInternalPackageVersion>
<!-- dotnet/runtime -->
Expand Down
15 changes: 15 additions & 0 deletions eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ Task("dotnet-templates")
"</TargetFrameworks> -->",
"</TargetFrameworks>");

// TODO: remove this once issues are fixed
if (TestTFM.StartsWith("net6"))
{
// Mac Catalyst/iOS does not yet support net6 from the net7 SDK.
ReplaceTextInFiles($"{projectName}/*.csproj",
";net6.0-ios;net6.0-maccatalyst",
"");

// Android does not yet support net6 from the net7 SDK in Release builds
if (configuration == "Release")
ReplaceTextInFiles($"{projectName}/*.csproj",
"net6.0-android",
"");
}

// Build
RunMSBuildWithDotNet(projectName, properties, warningsAsError: true, forceDotNetBuild: forceDotNetBuild);

Expand Down
6 changes: 4 additions & 2 deletions eng/pipelines/handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ parameters:
default:
- name: default
tfm: default
# - name: net6
# tfm: net6.0
- name: net6
tfm: net6.0
- name: net7
tfm: net7.0

resources:
repositories:
Expand Down
43 changes: 18 additions & 25 deletions src/Workload/Microsoft.Maui.Sdk/Microsoft.Maui.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,35 @@
<ProjectReference Include="$(MauiRootDirectory)src/Controls/src/SourceGen/Controls.SourceGen.csproj" />
</ItemGroup>

<ItemGroup>
<_ValuesToReplace Include="VERSION" PropertyName="PackageReferenceVersion" />
<_ValuesToReplace Include="TFM" PropertyName="_MauiDotNetTfm" />
<_ValuesToReplace Include="PREVIOUS_TFM" PropertyName="_MauiPreviousDotNetTfm" />
<_ValuesToReplace Include="MAUI_DOTNET_VERSION" PropertyName="_MauiDotNetVersion" />
<_ValuesToReplace Include="MAUI_PREVIOUS_DOTNET_VERSION" PropertyName="_MauiPreviousDotNetVersion" />
<_ValuesToReplace Include="MAUI_PREVIOUS_DOTNET_VERSION_NO_DOT" PropertyName="_MauiPreviousDotNetVersionNoDot" />
<_ValuesToReplace Include="MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION" PropertyName="MicrosoftMauiPreviousDotNetReleasedVersion" />
<_ValuesToReplace Include="MicrosoftWindowsSDKBuildToolsPackageVersion" PropertyName="MicrosoftWindowsSDKBuildToolsPackageVersion" />
<_ValuesToReplace Include="MicrosoftExtensionsPackageVersion" PropertyName="MicrosoftExtensionsPackageVersion" />
<_ValuesToReplace Include="MicrosoftExtensionsServicingPackageVersion" PropertyName="MicrosoftExtensionsServicingPackageVersion" />
</ItemGroup>

<Import Project="$(MauiRootDirectory)eng/ReplaceText.targets" />

<Target Name="_GenerateBundledVersions"
BeforeTargets="Build;AssignTargetPaths"
DependsOnTargets="SetVersions"
Inputs="$(MSBuildProjectFile);$(MauiRootDirectory)eng/Versions.props;Sdk/BundledVersions.in.targets"
Outputs="$(IntermediateOutputPath)BundledVersions.targets">
<ReplaceText
Input="Sdk/BundledVersions.in.targets"
Output="$(IntermediateOutputPath)BundledVersions.targets"
OldValue="@VERSION@"
NewValue="$(PackageReferenceVersion)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)BundledVersions.targets"
Output="$(IntermediateOutputPath)BundledVersions.targets"
OldValue="@TFM@"
NewValue="$(_MauiDotNetTfm)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)BundledVersions.targets"
Output="$(IntermediateOutputPath)BundledVersions.targets"
OldValue="@MicrosoftWindowsSDKBuildToolsPackageVersion@"
NewValue="$(MicrosoftWindowsSDKBuildToolsPackageVersion)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)BundledVersions.targets"
Output="$(IntermediateOutputPath)BundledVersions.targets"
OldValue="@MicrosoftExtensionsPackageVersion@"
NewValue="$(MicrosoftExtensionsPackageVersion)"
<Copy
SourceFiles="Sdk/BundledVersions.in.targets"
DestinationFiles="$(IntermediateOutputPath)BundledVersions.targets"
/>
<ReplaceText
Input="$(IntermediateOutputPath)BundledVersions.targets"
Output="$(IntermediateOutputPath)BundledVersions.targets"
OldValue="@MicrosoftExtensionsServicingPackageVersion@"
NewValue="$(MicrosoftExtensionsServicingPackageVersion)"
OldValue="@%(_ValuesToReplace.Identity)@"
NewValue="$(%(_ValuesToReplace.PropertyName))"
/>
<ItemGroup>
<None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>

<PropertyGroup>
<_MauiRuntimePackVersion>$(MauiVersion)</_MauiRuntimePackVersion>
<_MauiRuntimePackVersion Condition=" '$(_MauiRuntimePackVersion)' == '' ">**FromWorkload**</_MauiRuntimePackVersion>
Expand All @@ -14,7 +15,6 @@

<!-- Framework references -->
<ItemGroup>
<_MauiRuntimeIdentifiers Include="android;ios;maccatalyst;win;tizen" />
<KnownFrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' "
Include="Microsoft.Maui.Core"
Expand Down
27 changes: 10 additions & 17 deletions src/Workload/Microsoft.NET.Sdk.Maui/Microsoft.NET.Sdk.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ItemGroup>
<_JsonInputFile Include="WorkloadManifest.in.json" OutputPath="$(IntermediateOutputPath)WorkloadManifest.json" Pack="true" />
<_JsonInputFile Include="WorkloadManifest.in.targets" OutputPath="$(IntermediateOutputPath)WorkloadManifest.targets" Pack="true" />
<_JsonInputFile Include="Rollback.in.json" OutputPath="$(IntermediateOutputPath)Rollback.json" Pack="false" />
<_JsonInputFile Include="SdkInstaller.in.json" OutputPath="$(IntermediateOutputPath)SdkInstaller.json" Pack="false" />
</ItemGroup>
Expand Down Expand Up @@ -54,6 +55,12 @@
<_VersionsToReplace Include="MicrosoftMauiGraphicsVersion" />
<_VersionsToReplace Update="@(_VersionsToReplace)" PropertyName="%(Identity)" />
<_VersionsToReplace Include="MicrosoftMauiGraphicsWin2DWinUIDesktopPackageVersion" PropertyName="MicrosoftMauiGraphicsVersion" />
<_VersionsToReplace Include="MAUI_GRAPHICS_VERSION" PropertyName="MicrosoftMauiGraphicsVersion" />
<_VersionsToReplace Include="VERSION" PropertyName="PackageReferenceVersion" />
<_VersionsToReplace Include="MAUI_DOTNET_VERSION" PropertyName="_MauiDotNetVersion" />
<_VersionsToReplace Include="MAUI_PREVIOUS_DOTNET_VERSION" PropertyName="_MauiPreviousDotNetVersion" />
<_VersionsToReplace Include="MAUI_PREVIOUS_DOTNET_VERSION_NO_DOT" PropertyName="_MauiPreviousDotNetVersionNoDot" />
<_VersionsToReplace Include="MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION" PropertyName="MicrosoftMauiPreviousDotNetReleasedVersion" />
</ItemGroup>
<CreateItem
Include="@(_JsonInputFile)"
Expand All @@ -62,23 +69,9 @@
TaskParameter="Include"
ItemName="_JsonVariableMatrix"/>
</CreateItem>
<ReplaceText
Input="%(_JsonInputFile.Identity)"
Output="%(_JsonInputFile.OutputPath)"
OldValue="@VERSION@"
NewValue="$(PackageReferenceVersion)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)WorkloadManifest.json"
Output="$(IntermediateOutputPath)WorkloadManifest.json"
OldValue="@MAUI_GRAPHICS_VERSION@"
NewValue="$(MicrosoftMauiGraphicsVersion)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)WorkloadManifest.json"
Output="$(IntermediateOutputPath)WorkloadManifest.json"
OldValue="@MAUI_DOTNET_VERSION@"
NewValue="$(_MauiDotNetVersion)"
<Copy
SourceFiles="%(_JsonInputFile.Identity)"
DestinationFiles="%(_JsonInputFile.OutputPath)"
/>
<ReplaceText
Input="%(_JsonVariableMatrix.OutputPath)"
Expand Down
13 changes: 13 additions & 0 deletions src/Workload/Microsoft.NET.Sdk.Maui/WorkloadManifest.in.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
"packs": [
"Microsoft.Maui.Dependencies",
"Microsoft.Maui.Sdk",
"Microsoft.Maui.Sdk-@MAUI_PREVIOUS_DOTNET_VERSION@",
"Microsoft.Maui.Graphics",
"Microsoft.Maui.Resizetizer.Sdk",
"Microsoft.Maui.Templates-@MAUI_PREVIOUS_DOTNET_VERSION@",
"Microsoft.Maui.Templates-@MAUI_DOTNET_VERSION@",
"Microsoft.Maui.Core.Ref.any",
"Microsoft.Maui.Core.Runtime.any",
Expand Down Expand Up @@ -286,13 +288,24 @@
"kind": "sdk",
"version": "@VERSION@"
},
"Microsoft.Maui.Sdk-@MAUI_PREVIOUS_DOTNET_VERSION@": {
"kind": "sdk",
"version": "@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@",
"alias-to": {
"any": "Microsoft.Maui.Sdk"
}
},
"Microsoft.Maui.Resizetizer.Sdk": {
"kind": "sdk",
"version": "@VERSION@"
},
"Microsoft.Maui.Templates-@MAUI_DOTNET_VERSION@": {
"kind": "template",
"version": "@VERSION@"
},
"Microsoft.Maui.Templates-@MAUI_PREVIOUS_DOTNET_VERSION@": {
"kind": "template",
"version": "@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
}
}
}
47 changes: 47 additions & 0 deletions src/Workload/Microsoft.NET.Sdk.Maui/WorkloadManifest.in.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<Project>

<ItemGroup Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' ">
<ProjectCapability Include="UseMauiCore" />
<ProjectCapability Condition=" '$(UseMaui)' == 'true' " Include="UseMaui" />
</ItemGroup>

<Import
Condition=" ('$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' or '$(UseMauiEssentials)' == 'true' or '$(UseMauiAssets)' == 'true') and ($([MSBuild]::VersionEquals($(TargetFrameworkVersion), '@MAUI_DOTNET_VERSION@'))) "
Project="Sdk.targets" Sdk="Microsoft.Maui.Sdk"
/>
<Import
Condition=" ('$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' or '$(UseMauiEssentials)' == 'true' or '$(UseMauiAssets)' == 'true') and ($([MSBuild]::VersionEquals($(TargetFrameworkVersion), '@MAUI_PREVIOUS_DOTNET_VERSION@'))) "
Project="Sdk.targets" Sdk="Microsoft.Maui.Sdk-@MAUI_PREVIOUS_DOTNET_VERSION@"
/>

<Import
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiAssets)' == 'true' "
Project="Sdk.targets" Sdk="Microsoft.Maui.Resizetizer.Sdk"
/>

<!--
Previous versions of the .NET MAUI SDK used **FromWorkload**, so replace with explicit versions.
The BundledVersions.targets that is imported is from the previous SDK, so all the other values are correct.
-->
<ItemGroup Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '@MAUI_PREVIOUS_DOTNET_VERSION@')) ">
<KnownFrameworkReference
Update="Microsoft.Maui.Core"
DefaultRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
LatestRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
TargetingPackVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
/>
<KnownFrameworkReference
Update="Microsoft.Maui.Controls"
DefaultRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
LatestRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
TargetingPackVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
/>
<KnownFrameworkReference
Update="Microsoft.Maui.Essentials"
DefaultRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
LatestRuntimeFrameworkVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
TargetingPackVersion="@MAUI_PREVIOUS_DOTNET_RELEASED_NUGET_VERSION@"
/>
</ItemGroup>

</Project>
14 changes: 0 additions & 14 deletions src/Workload/Microsoft.NET.Sdk.Maui/WorkloadManifest.targets

This file was deleted.

0 comments on commit 724e795

Please sign in to comment.