Skip to content

Commit

Permalink
Clean up .NET 5 references and update to WinAppSDK projection for tes…
Browse files Browse the repository at this point in the history
…ting (#1261)

* Remove .NET 5 TFM now that we don't support it.

* Update sample to .NET 6

* Fix WinUIDesktopSample

* Move object lifetime tests to WinAppSDK projection

* Fix build

* Move embedded tests off NET5 and remove unused projection.

* Remove project from sln.

* Move couple more packages

* Move to Variable for WinAppSDK version.

* Add comment

* Dropping signing as it doesn't seem to be needed anymore with the new MSTest packages.

* Cleanup a couple more .NET 5 references.

* Fix launching WinUIDesktopSample
  • Loading branch information
manodasanW authored Oct 25, 2022
1 parent 18ab8b8 commit 2a4876a
Show file tree
Hide file tree
Showing 53 changed files with 219 additions and 611 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ C#/WinRT currently requires the following packages, or newer, to build:
- [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1)
- [nuget.exe 5.8.0-preview.3](https://www.nuget.org/downloads)
- Microsoft.WinUI 3.0.0-preview4.210210.4
- Microsoft.WindowsAppSDK 1.1.5

The [`build.cmd`](src/build.cmd) script takes care of all related configuration steps and is the simplest way to get started building C#/WinRT. It installs prerequisites such as `nuget.exe` and the .NET 6 SDK, configures the environment to use .NET 6 (creating a `global.json` if necessary), builds the compiler, and builds and executes the unit tests. To build C#/WinRT, follow these steps:

Expand Down
21 changes: 1 addition & 20 deletions build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ steps:
displayName: Stage Unit Test
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64')))
inputs:
SourceFolder: $(Build.SourcesDirectory)\src\Tests\UnitTest\bin\$(BuildPlatform)\$(BuildConfiguration)\net5.0
SourceFolder: $(Build.SourcesDirectory)\src\Tests\UnitTest\bin\$(BuildPlatform)\$(BuildConfiguration)\net6.0
Contents: |
unittest.dll
unittest.pdb
Expand Down Expand Up @@ -287,17 +287,6 @@ steps:
PathtoPublish: $(Build.ArtifactStagingDirectory)\release_netstandard2.0
ArtifactName: netstandard2.0

# Stage Net5.0
- task: CopyFiles@2
displayName: Stage Net5.0
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release'))
inputs:
SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime\bin\$(BuildConfiguration)\net5.0
Contents: |
WinRT.Runtime.dll
WinRT.Runtime.pdb
TargetFolder: $(Build.ArtifactStagingDirectory)\release_net5.0

# Stage Net6.0
- task: CopyFiles@2
displayName: Stage Net6.0
Expand Down Expand Up @@ -397,14 +386,6 @@ steps:
PathtoPublish: $(Build.ArtifactStagingDirectory)\resx
ArtifactName: ResX

# Publish Net5.0
- task: PublishBuildArtifacts@1
displayName: Publish Net5.0
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release'))
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)\release_net5.0
ArtifactName: net5.0

# Publish Net6.0
- task: PublishBuildArtifacts@1
displayName: Publish Net6.0
Expand Down
12 changes: 1 addition & 11 deletions build/AzurePipelineTemplates/CsWinRT-PublishToNuget-Stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ stages:
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download Net5.0
- task: DownloadBuildArtifacts@0
displayName: 'Download Net5.0 '
inputs:
artifactName: net5.0
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download Net6.0
- task: DownloadBuildArtifacts@0
Expand Down Expand Up @@ -96,7 +87,6 @@ stages:
netstandard2.0\WinRT.Runtime.dll
netstandard2.0\WinRT.Host.Shim.dll
netstandard2.0\WinRT.SourceGenerator.dll
net5.0\WinRT.Runtime.dll
net6.0\WinRT.Host.Shim.dll
net6.0\WinRT.Runtime.dll
release_x64\WinRT.Host.dll
Expand Down Expand Up @@ -222,7 +212,7 @@ stages:
command: pack
searchPatternPack: nuget/Microsoft.Windows.CsWinRT.nuspec
configurationToPack: Release
buildProperties: cswinrt_nuget_version=$(NugetVersion);cswinrt_exe=$(Build.SourcesDirectory)\cswinrt.exe;interop_winmd=$(Build.SourcesDirectory)\WinRT.Interop.winmd;netstandard2_runtime=$(Build.SourcesDirectory)\netstandard2.0\WinRT.Runtime.dll;net5_runtime=$(Build.SourcesDirectory)\net5.0\WinRT.Runtime.dll;net6_runtime=$(Build.SourcesDirectory)\net6.0\WinRT.Runtime.dll;source_generator=$(Build.SourcesDirectory)\netstandard2.0\WinRT.SourceGenerator.dll;winrt_shim=$(Build.SourcesDirectory)\net6.0\WinRT.Host.Shim.dll;winrt_host_x86=$(Build.SourcesDirectory)\release_x86\WinRT.Host.dll;winrt_host_x64=$(Build.SourcesDirectory)\release_x64\WinRT.Host.dll;winrt_host_arm64=$(Build.SourcesDirectory)\release_arm64\WinRT.Host.dll;winrt_host_resource_x86=$(Build.SourcesDirectory)\release_x86\WinRT.Host.dll.mui;winrt_host_resource_x64=$(Build.SourcesDirectory)\release_x64\WinRT.Host.dll.mui;winrt_host_resource_arm64=$(Build.SourcesDirectory)\release_arm64\WinRT.Host.dll.mui;guid_patch=$(Build.SourcesDirectory)\net6.0\IIDOptimizer\*.*
buildProperties: cswinrt_nuget_version=$(NugetVersion);cswinrt_exe=$(Build.SourcesDirectory)\cswinrt.exe;interop_winmd=$(Build.SourcesDirectory)\WinRT.Interop.winmd;netstandard2_runtime=$(Build.SourcesDirectory)\netstandard2.0\WinRT.Runtime.dll;net6_runtime=$(Build.SourcesDirectory)\net6.0\WinRT.Runtime.dll;source_generator=$(Build.SourcesDirectory)\netstandard2.0\WinRT.SourceGenerator.dll;winrt_shim=$(Build.SourcesDirectory)\net6.0\WinRT.Host.Shim.dll;winrt_host_x86=$(Build.SourcesDirectory)\release_x86\WinRT.Host.dll;winrt_host_x64=$(Build.SourcesDirectory)\release_x64\WinRT.Host.dll;winrt_host_arm64=$(Build.SourcesDirectory)\release_arm64\WinRT.Host.dll;winrt_host_resource_x86=$(Build.SourcesDirectory)\release_x86\WinRT.Host.dll.mui;winrt_host_resource_x64=$(Build.SourcesDirectory)\release_x64\WinRT.Host.dll.mui;winrt_host_resource_arm64=$(Build.SourcesDirectory)\release_arm64\WinRT.Host.dll.mui;guid_patch=$(Build.SourcesDirectory)\net6.0\IIDOptimizer\*.*

- task: NuGetCommand@2
displayName: NuGet pack
Expand Down
16 changes: 9 additions & 7 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<CsWinRTVerbosity>high</CsWinRTVerbosity>
<!--Note: unlisted at https://www.nuget.org/packages/Microsoft.WinUI/-->
<MicrosoftWinUIVersion>3.0.0-preview4.210210.4</MicrosoftWinUIVersion>
<MicrosoftWinAppSDKVersion>1.1.5</MicrosoftWinAppSDKVersion>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<LangVersion>preview</LangVersion>
Expand All @@ -23,15 +24,16 @@
<AssetTargetFallback>netcoreapp5.0</AssetTargetFallback>
<IsTargetFrameworkNet5OrGreater>false</IsTargetFrameworkNet5OrGreater>
<IsTargetFrameworkNet5OrGreater Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 5">true</IsTargetFrameworkNet5OrGreater>
<AppBuildTFMs>netcoreapp3.1;net5.0;net6.0</AppBuildTFMs>
<AppBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">netcoreapp3.1;net5.0;net6.0;net7.0</AppBuildTFMs>
<LibBuildTFMs>netstandard2.0;net5.0;net6.0</LibBuildTFMs>
<LibBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">netstandard2.0;net5.0;net6.0;net7.0</LibBuildTFMs>
<TestsBuildTFMs>net5.0-windows10.0.19041.0;net6.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TestsBuildTFMs>
<TestsBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">net5.0-windows10.0.19041.0;net6.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TestsBuildTFMs>
<AppBuildTFMs>netcoreapp3.1;net6.0</AppBuildTFMs>
<AppBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">netcoreapp3.1;net6.0;net7.0</AppBuildTFMs>
<LibBuildTFMs>netstandard2.0;net6.0</LibBuildTFMs>
<LibBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">netstandard2.0;net6.0;net7.0</LibBuildTFMs>
<TestsBuildTFMs>net6.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TestsBuildTFMs>
<TestsBuildTFMs Condition="'$(CIBuildReason)' == 'CI'">net6.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TestsBuildTFMs>
<WindowsAppSDKVerifyWinrtRuntimeVersion>false</WindowsAppSDKVerifyWinrtRuntimeVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PropertyGroup Condition="!$(IsTargetFrameworkNet5OrGreater)">
<DefineConstants>$(DefineConstants);MANUAL_IUNKNOWN</DefineConstants>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
<Target Name="CleanIntermediateDirs" Condition="'$(CleanIntermediateDirs)'=='true'" AfterTargets="Build">
<RemoveDir Directories="$(IntDir)" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/Perf/ResultsComparer/ResultsComparer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>$(PERFLAB_TARGET_FRAMEWORKS)</TargetFrameworks>
<TargetFramework Condition="'$(TargetFrameworks)' == ''">net5.0</TargetFramework>
<TargetFramework Condition="'$(TargetFrameworks)' == ''">net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
61 changes: 0 additions & 61 deletions src/Projections/Reunion/Reunion.csproj

This file was deleted.

Binary file removed src/Projections/Reunion/key.snk
Binary file not shown.
10 changes: 5 additions & 5 deletions src/Projections/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
<ProjectReference Include="..\Windows\Windows.csproj" />
<ProjectReference Include="..\WinUI\WinUI.csproj" />
<ProjectReference Include="..\WinAppSDK\WinAppSDK.csproj" />
<InternalsVisibleTo Include="UnitTest" />
</ItemGroup>

<PropertyGroup>
<CsWinRTExcludes>TestComponentCSharp.AnotherAssembly;</CsWinRTExcludes>
<CsWinRTIncludes>TestComponent;TestComponentCSharp;test_component_base;test_component_derived;test_component_fast;</CsWinRTIncludes>
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
<!--PkgMicrosoft_WindowsAppSDK is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WindowsAppSDK>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.windowsappsdk', '$(MicrosoftWinAppSDKVersion)'))</PkgMicrosoft_WindowsAppSDK>
</PropertyGroup>
<ItemGroup>
<!--Explicitly reference WinUI winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WinUI)/**/*.winmd" />
<!--Explicitly reference WinAppSDK winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WindowsAppSDK)/**/*.winmd" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
<ProjectReference Include="..\Windows\Windows.csproj" />
<ProjectReference Include="..\WinUI\WinUI.csproj" />
<ProjectReference Include="..\WinAppSDK\WinAppSDK.csproj" />
<InternalsVisibleTo Include="UnitTest" />
</ItemGroup>

<PropertyGroup>
<CsWinRTIncludes>TestComponent;TestComponentCSharp</CsWinRTIncludes>
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
<!--PkgMicrosoft_WindowsAppSDK is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WindowsAppSDK>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.windowsappsdk', '$(MicrosoftWinAppSDKVersion)'))</PkgMicrosoft_WindowsAppSDK>
</PropertyGroup>
<ItemGroup>
<!--Explicitly reference WinUI winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WinUI)/**/*.winmd" />
<!--Explicitly reference WinAppSDK winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WindowsAppSDK)/**/*.winmd" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Projections/TestSubset/TestSubset.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
<ProjectReference Include="..\Windows\Windows.csproj" />
<ProjectReference Include="..\WinUI\WinUI.csproj" />
<ProjectReference Include="..\WinAppSDK\WinAppSDK.csproj" />
<ProjectReference Include="..\Test\Test.csproj" />
<InternalsVisibleTo Include="UnitTest" />
</ItemGroup>

<PropertyGroup>
<CsWinRTIncludes>TestComponentCSharp.AnotherAssembly;</CsWinRTIncludes>
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
<!--PkgMicrosoft_WindowsAppSDK is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WindowsAppSDK>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.windowsappsdk', '$(MicrosoftWinAppSDKVersion)'))</PkgMicrosoft_WindowsAppSDK>
</PropertyGroup>
<ItemGroup>
<!--Explicitly reference WinUI winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WinUI)/**/*.winmd" />
<!--Explicitly reference WinAppSDK winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WindowsAppSDK)/**/*.winmd" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Threading;
using Microsoft.System;
using Microsoft.UI.Dispatching;

namespace Microsoft.System
namespace Microsoft.UI.Dispatching
{
/// <summary>
/// DispatcherQueueSyncContext allows developers to await calls and get back onto the
Expand Down
49 changes: 49 additions & 0 deletions src/Projections/WinAppSDK/WinAppSDK.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(LibBuildTFMs)</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<AssemblyName>Microsoft.WinUI</AssemblyName>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
<ProjectReference Include="..\Windows\Windows.csproj" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="$(MicrosoftWinAppSDKVersion)" GeneratePathProperty="true">
<ExcludeAssets>build; buildtransitive; compile; runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<CsWinRTFilters>
-exclude Windows
-include Microsoft
# The current WinUI nuget incorrectly references several Windows.* types that should be
# Microsoft.* types instead. Temporarily include these to enable the build
-include Windows.UI.Xaml.Interop.Type
-include Windows.UI.Xaml.Interop.NotifyCollectionChangedAction
-include Windows.UI.Xaml.Markup.ContentPropertyAttribute
-include Windows.UI.Xaml.StyleTypedPropertyAttribute
-include Windows.UI.Xaml.TemplatePartAttribute
-include Windows.UI.Xaml.TemplateVisualStateAttribute
-include Windows.UI.Xaml.Data.BindableAttribute
-include Windows.UI.Xaml.Markup.ContentPropertyAttribute
-include Windows.UI.Xaml.Markup.FullXamlMetadataProviderAttribute
-include Windows.UI.Xaml.Markup.MarkupExtensionReturnTypeAttribute
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
-include Windows.UI.Xaml.Media.Animation.IndependentlyAnimatableAttribute
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
</CsWinRTFilters>
<!--PkgMicrosoft_WindowsAppSDK is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WindowsAppSDK>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.windowsappsdk', '$(MicrosoftWinAppSDKVersion)'))</PkgMicrosoft_WindowsAppSDK>
</PropertyGroup>
<ItemGroup>
<!--Explicitly reference WinAppSDK winmds from TFM uap10.0-->
<CsWinRTInputs Include="$(PkgMicrosoft_WindowsAppSDK)/**/*.winmd" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/Projections/WinUI/WinUI.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
Used to test generating the older WinUI projection, but not used as part of tests.
The WinAppSDK projection is used for tests instead.
-->
<PropertyGroup>
<TargetFrameworks>$(LibBuildTFMs)</TargetFrameworks>
<Platforms>x64;x86</Platforms>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Platforms>x64;x86</Platforms>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Gamma;
using Windows.Media;

namespace Net5App.Bootstrap
namespace Net6App.Bootstrap
{
class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<Platforms>x64;x86</Platforms>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<SimulateCsWinRTNugetReference>true</SimulateCsWinRTNugetReference>
<CsWinRTWindowsMetadata>sdk</CsWinRTWindowsMetadata>
</PropertyGroup>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"Net5App": {
"Net6App": {
"commandName": "Project",
"nativeDebugging": true
}
Expand Down
Loading

0 comments on commit 2a4876a

Please sign in to comment.