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

Add UWP .NET 9 support for MSTest extensions #3848

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
<!-- The TFMs to build and test against. -->
<PropertyGroup>
<NetFrameworkMinimum>net462</NetFrameworkMinimum>
<NetCurrent>net9.0</NetCurrent>

<!-- The windows SDK version of UWP, Modern UWP and WinUI could be aligned -->
<UwpMinimum>uap10.0.16299</UwpMinimum>
<ModernUwpMinimum>net9.0-windows10.0.17763.0</ModernUwpMinimum>
<WinUiMinimum>net6.0-windows10.0.18362.0</WinUiMinimum>
<NetCurrent>net8.0</NetCurrent>

<SupportedNetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0</SupportedNetFrameworks>
<MicrosoftTestingTargetFrameworks>net6.0;net7.0;net8.0</MicrosoftTestingTargetFrameworks>
<MicrosoftTestingTargetFrameworks>net6.0;net7.0;net8.0;net9.0</MicrosoftTestingTargetFrameworks>
<SupportedNetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</SupportedNetFrameworks>
</PropertyGroup>

<!-- Build config -->
Expand Down
4 changes: 2 additions & 2 deletions eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function Confirm-NugetPackages {
$expectedNumOfFiles = @{
"MSTest.Sdk" = 15;
"MSTest.Internal.TestFx.Documentation" = 10;
"MSTest.TestFramework" = 130;
"MSTest.TestAdapter" = 76;
"MSTest.TestFramework" = 150;
"MSTest.TestAdapter" = 84;
"MSTest" = 6;
"MSTest.Analyzers" = 10;
}
Expand Down
5 changes: 5 additions & 0 deletions samples/public/BlankUwpNet9App/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Application
x:Class="BlankUwpNet9App.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BlankUwpNet9App" />
103 changes: 103 additions & 0 deletions samples/public/BlankUwpNet9App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;

using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace BlankUwpNet9App
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
InitializeComponent();

Suspending += OnSuspending;
}

/// <inheritdoc/>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active.
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

//if (e.PrelaunchActivated == false)
//{
// if (rootFrame.Content == null)
// {
// // When the navigation stack isn't restored navigate to the first page, configuring
// // the new page by passing required information as a navigation parameter.
// rootFrame.Navigate(typeof(MainPage), e.Arguments);
// }

// Ensure the current window is active
Window.Current.Activate();
//}

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
}

/// <summary>
/// Invoked when Navigation to a certain page fails.
/// </summary>
/// <param name="sender">The Frame which failed navigation.</param>
/// <param name="e">Details about the navigation failure.</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception($"Failed to load page '{e.SourcePageType.FullName}'.");
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();

// TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions samples/public/BlankUwpNet9App/BlankUwpNet9App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<DefaultLanguage>en-US</DefaultLanguage>
<PublishAot>true</PublishAot>
<UseUwp>true</UseUwp>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
<EnableMsixTooling>true</EnableMsixTooling>
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">$(VisualStudioVersion)</UnitTestPlatformVersion>

<!-- Set this property to override the version of the MSIX package to use -->
<MicrosoftWindowsSDKBuildToolsMSIXPackageVersion>1.0.20241009.2</MicrosoftWindowsSDKBuildToolsMSIXPackageVersion>
</PropertyGroup>

<ItemGroup>
<ProjectCapability Include="TestContainer" />
<PackageReference Include="Microsoft.Windows.SDK.CPP" Version="10.0.26100.2454" />

<!-- Do not use MSTest metapackage as we don't want to use Microsoft.NET.Test.Sdk -->
<PackageReference Include="MSTest.TestFramework" Version="3.7.0-dev" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0-dev" />
<PackageReference Include="MSTest.Analyzers" Version="3.7.0-dev" />
<!-- Instead we want to rely on Microsoft.TestPlatform.TestHost to support msix -->
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.12.0" />


<!--<PackageReference Include="Microsoft.TestPlatform.ObjectModel" IncludeAssets="None" Version="17.12.0" />-->
<!--<SDKReference Include="TestPlatform.Universal, Version=$(UnitTestPlatformVersion)" />-->
</ItemGroup>
</Project>
40 changes: 40 additions & 0 deletions samples/public/BlankUwpNet9App/BlankUwpNet9App.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35521.163 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlankUwpNet9App", "BlankUwpNet9App.csproj", "{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|arm64 = Debug|arm64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|arm64 = Release|arm64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.ActiveCfg = Debug|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.Build.0 = Debug|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.Deploy.0 = Debug|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.ActiveCfg = Debug|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.Build.0 = Debug|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.Deploy.0 = Debug|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.ActiveCfg = Debug|x86
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.Build.0 = Debug|x86
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.Deploy.0 = Debug|x86
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|arm64.ActiveCfg = Release|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|arm64.Build.0 = Release|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.Deploy.0 = Release|arm64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x64.ActiveCfg = Release|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x64.Build.0 = Release|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.Deploy.0 = Release|x64
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x86.ActiveCfg = Release|x86
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x86.Build.0 = Release|x86
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions samples/public/BlankUwpNet9App/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page
x:Class="BlankUwpNet9App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:BlankUwpNet9App"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<Grid>
<TextBlock Text="Hello world" />
</Grid>
</Page>
30 changes: 30 additions & 0 deletions samples/public/BlankUwpNet9App/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace BlankUwpNet9App
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
}
}
}
49 changes: 49 additions & 0 deletions samples/public/BlankUwpNet9App/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">

<Identity
Name="3a1115e9-2ece-44ab-944f-5b6240a08ea6"
Publisher="CN=sergiopedri"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="3a1115e9-2ece-44ab-944f-5b6240a08ea6" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>BlankUwpNet9App</DisplayName>
<PublisherDisplayName>sergiopedri</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="BlankUwpNet9App.App">
<uap:VisualElements
DisplayName="BlankUwpNet9App"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="BlankUwpNet9App"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>ARM64</Platform>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions samples/public/BlankUwpNet9App/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"BlankUwpNet9App": {
"commandName": "MsixPackage"
}
}
}
Loading