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

Enable .NET 7 <MauiVersion> to work in .NET 8 SDK projects #17409

Merged
merged 2 commits into from
Sep 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public class BaseBuildTest
public const string DotNetCurrent = "net8.0";
public const string DotNetPrevious = "net7.0";

public const string MauiVersionCurrent = "8.0.0-rc.1.9171"; // this should not be the same as the last release
Copy link
Member

Choose a reason for hiding this comment

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

This comment is confusing. Do you mean it should not be the same as MauiVersionPrevious?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was confusing. I'll fix.

public const string MauiVersionPrevious = "7.0.86"; // this should not be the same version as the default. aka: MicrosoftMauiPreviousDotNetReleasedVersion in eng/Versions.props

char[] invalidChars = { '{', '}', '(', ')', '$', ':', ';', '\"', '\'', ',', '=', '.', '-', };

public string TestName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,46 @@ public void Build(string id, string framework, string config, bool shouldPack)
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");
}

[Test]
// Parameters: short name, target framework, build config, use pack target
[TestCase("maui", DotNetPrevious, "Debug", false)]
[TestCase("maui", DotNetPrevious, "Release", false)]
[TestCase("maui", DotNetCurrent, "Debug", false)]
[TestCase("maui", DotNetCurrent, "Release", false)]
[TestCase("maui-blazor", DotNetPrevious, "Debug", false)]
[TestCase("maui-blazor", DotNetPrevious, "Release", false)]
[TestCase("maui-blazor", DotNetCurrent, "Debug", false)]
[TestCase("maui-blazor", DotNetCurrent, "Release", false)]
[TestCase("mauilib", DotNetPrevious, "Debug", true)]
[TestCase("mauilib", DotNetPrevious, "Release", true)]
[TestCase("mauilib", DotNetCurrent, "Debug", true)]
[TestCase("mauilib", DotNetCurrent, "Release", true)]
public void BuildWithMauiVersion(string id, string framework, string config, bool shouldPack)
{
var projectDir = TestDirectory;
var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj");

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework),
$"Unable to create template {id}. Check test output for errors.");

EnableTizen(projectFile);

if (shouldPack)
FileUtilities.ReplaceInFile(projectFile,
"</Project>",
"<PropertyGroup><Version>1.0.0-preview.1</Version></PropertyGroup></Project>");

// set <MauiVersion> in the csproj as that is the reccommended place
var mv = framework == DotNetPrevious ? MauiVersionPrevious : MauiVersionCurrent;
FileUtilities.ReplaceInFile(projectFile,
"</Project>",
$"<PropertyGroup><MauiVersion>{mv}</MauiVersion></PropertyGroup></Project>");

string target = shouldPack ? "Pack" : "";
Assert.IsTrue(DotnetInternal.Build(projectFile, config, target: target, properties: BuildProps),
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");
}

[Test]
[TestCase("maui", DotNetPrevious, "Debug")]
[TestCase("maui", DotNetPrevious, "Release")]
Expand Down
20 changes: 10 additions & 10 deletions src/Workload/Microsoft.NET.Sdk.Maui/WorkloadManifest.in.targets
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@
<ItemGroup Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '@MAUI_PREVIOUS_DOTNET_VERSION@')) and ('$(SkipMauiWorkloadManifest)' != 'true') ">
<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@"
DefaultRuntimeFrameworkVersion="$(MauiVersion)"
LatestRuntimeFrameworkVersion="$(MauiVersion)"
TargetingPackVersion="$(MauiVersion)"
/>
mattleibow marked this conversation as resolved.
Show resolved Hide resolved
<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@"
DefaultRuntimeFrameworkVersion="$(MauiVersion)"
LatestRuntimeFrameworkVersion="$(MauiVersion)"
TargetingPackVersion="$(MauiVersion)"
/>
<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@"
DefaultRuntimeFrameworkVersion="$(MauiVersion)"
LatestRuntimeFrameworkVersion="$(MauiVersion)"
TargetingPackVersion="$(MauiVersion)"
/>
</ItemGroup>

</Project>
</Project>
Loading