Tooling-Windows-Submodule icon indicating copy to clipboard operation
Tooling-Windows-Submodule copied to clipboard

Bump MSTest + VSTest and use MSTest.Sdk

Open Evangelink opened this issue 1 year ago • 14 comments

This is an alternative to #202 where I am using MSTest.Sdk feature we have developed.

This is our preferred way but decide what is the most comfortable for you.

More info:

  • blogpost: https://devblogs.microsoft.com/dotnet/introducing-mstest-sdk/
  • doc: https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-sdk

Evangelink avatar Aug 02 '24 13:08 Evangelink

To enable logs:

We have a flag for that here: https://github.com/CommunityToolkit/Tooling-Windows-Submodule/blob/fda081e11081ec7b0c034cdacbb817d906128b24/.github/workflows/build.yml#L20 - though we're trying to get it tied to the option within GitHub https://github.com/CommunityToolkit/Windows/pull/453, but have been unsuccessful. Though we have an issue with slngen as well, so you need to modify lines 133 and 203 as well to remove ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}

I also saw there was an issue building with multiple entry points in the other steps:

 "D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\WinAppSdk\ProjectTemplate.WinAppSdk.csproj" (default target) (9:6) ->

[5795](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5796)(PrepareForPublish target) ->

[5796](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5797)  C:\Program Files\dotnet\sdk\8.0.303\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(204,5): warning NETSDK1198: A publish profile with the name 'win-x64.pubxml' was not found in the project. Set the PublishProfile property to a valid file name. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\WinAppSdk\ProjectTemplate.WinAppSdk.csproj]

[5797](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5798)

[5798](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5799)

[5799](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5800)"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\ProjectTemplate.sln" (default target) (1:2) ->

[5800](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5801)"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj" (default target) (6:6) ->

[5801](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5802)(XamlPreCompile target) ->

[5802](https://github.com/CommunityToolkit/Tooling-Windows-Submodule/actions/runs/10216147871/job/28277401688#step:10:5803)  C:\Users\runneradmin\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs(4,41): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj]

michael-hawker avatar Aug 02 '24 19:08 michael-hawker

FYI @Arlodotexe we should probably remove the broken slngen diagnostic flag inclusion from our workflows...

michael-hawker avatar Aug 02 '24 19:08 michael-hawker

FYI @Arlodotexe we should probably remove the broken slngen diagnostic flag inclusion from our workflows...

PR submitted https://github.com/CommunityToolkit/Tooling-Windows-Submodule/pull/204/

Arlodotexe avatar Aug 02 '24 21:08 Arlodotexe

Looks like this PR is having the same error as #202:

"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\ProjectTemplate.sln" (default target) (1:2) ->
"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj" (default target) (6:6) ->
(XamlPreCompile target) -> 
  C:\Users\runneradmin\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs(4,41): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj]

Arlodotexe avatar Aug 19 '24 21:08 Arlodotexe

@Evangelink Do you have any insights on the error being thrown in CI? Did this build and run locally for you?

Arlodotexe avatar Aug 20 '24 17:08 Arlodotexe

dotnet test locally is giving me:

image

and the failures on CommunityToolkit.Tooling.SampleGen.Tests.dll are:

failed PaneOption_GeneratesWithoutDiagnostics 2s 760ms
Assert.IsTrue failed. Expected no generated compilation errors. Got: 
[CS1069: The type name 'INotifyPropertyChanged' could not be found in the namespace 'System.ComponentModel'. This type has been forwarded to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.]
[CS1069: The type name 'PropertyChangedEventHandler' could not be found in the namespace 'System.ComponentModel'. This type has been forwarded to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.]
[CS1069: The type name 'PropertyChangedEventArgs' could not be found in the namespace 'System.ComponentModel'. This type has been forwarded to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.]
[CS0066: 'Sample.PropertyChanged': event must be of a delegate type]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS1061: 'IGeneratedToolkitSampleOptionViewModel' does not contain a definition for 'PropertyChanged' and no accessible extension method 'PropertyChanged' accepting a first argument of type 'IGeneratedToolkitSampleOptionViewModel' could be found (are you missing a using directive or an assembly reference?)]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS1061: 'IGeneratedToolkitSampleOptionViewModel' does not contain a definition for 'PropertyChanged' and no accessible extension method 'PropertyChanged' accepting a first argument of type 'IGeneratedToolkitSampleOptionViewModel' could be found (are you missing a using directive or an assembly reference?)]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS1069: The type name 'PropertyChangedEventArgs' could not be found in the namespace 'System.ComponentModel'. This type has been forwarded to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS0012: The type 'INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]
[CS1069: The type name 'PropertyChangedEventArgs' could not be found in the namespace 'System.ComponentModel'. This type has been forwarded to assembly 'System.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.]
Stack Trace:
   at CommunityToolkit.Tooling.SampleGen.Tests.Helpers.TestHelpers.AssertNoCompilationErrors(Compilation outputCompilation) in C:\src\Tooling-Windows-Submodule\CommunityToolkit.Tooling.SampleGen.Tests\Helpers\TestHelpers.cs:line 48
   at CommunityToolkit.Tooling.SampleGen.Tests.Helpers.TestHelpers.AssertNoCompilationErrors(SourceGeneratorRunResult result) in C:\src\Tooling-Windows-Submodule\CommunityToolkit.Tooling.SampleGen.Tests\Helpers\TestHelpers.cs:line 65
   at CommunityToolkit.Tooling.SampleGen.Tests.ToolkitSampleGeneratedPaneTests.PaneOption_GeneratesWithoutDiagnostics() in C:\src\Tooling-Windows-Submodule\CommunityToolkit.Tooling.SampleGen.Tests\ToolkitSampleGeneratedPaneTests.cs:line 50

Evangelink avatar Aug 20 '24 19:08 Evangelink

@Arlodotexe This is now running tests successfully locally so I expect this to be good on CI, let's see. image

Evangelink avatar Aug 20 '24 20:08 Evangelink

Looks like similar errors in the two jobs:

"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\ProjectTemplate.sln" (default target) (1:2) ->
"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\WinAppSdk\ProjectTemplate.WinAppSdk.csproj" (default target) (9:6) ->
(PrepareForPublish target) -> 
  C:\Program Files\dotnet\sdk\8.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(204,5): warning NETSDK1198: A publish profile with the name 'win-x64.pubxml' was not found in the project. Set the PublishProfile property to a valid file name. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\WinAppSdk\ProjectTemplate.WinAppSdk.csproj]


"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\ProjectTemplate.sln" (default target) (1:2) ->
"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj" (default target) (6:6) ->
(XamlPreCompile target) -> 
  C:\Users\runneradmin\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs(4,41): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj]

And in the new_experiment also:

"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\components\CiTestExp\CiTestExp.sln" (default target) (1:2) ->
"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\components\CiTestExp\heads\Uwp\CiTestExp.Uwp.csproj" (default target) (4:6) ->
(BuildNativePackage target) -> 
  C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\Microsoft.NetNative.targets(809,5): error : Internal compiler error: Failed to parse 'S' [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\components\CiTestExp\heads\Uwp\CiTestExp.Uwp.csproj]

michael-hawker avatar Aug 20 '24 21:08 michael-hawker

error : Internal compiler error: Failed to parse 'S' [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\components\CiTestExp\heads\Uwp\CiTestExp.Uwp.csproj]

This is a transient error with .NET native, should pass with a rerun.

Arlodotexe avatar Aug 21 '24 22:08 Arlodotexe

Still seeing this error produced in CI:

"D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj" (default target) (6:6) ->
(XamlPreCompile target) -> 
  C:\Users\runneradmin\.nuget\packages\microsoft.net.test.sdk\17.10.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.cs(4,41): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [D:\a\Tooling-Windows-Submodule\Tooling-Windows-Submodule\tooling\ProjectTemplate\heads\Tests.WinAppSdk\ProjectTemplate.Tests.WinAppSdk.csproj]

Arlodotexe avatar Aug 21 '24 22:08 Arlodotexe

Sorry I will investigate later today. It makes no sense why it's working locally.

Evangelink avatar Aug 22 '24 07:08 Evangelink

@Evangelink Any update on what happened?

Arlodotexe avatar Feb 05 '25 00:02 Arlodotexe

Sorry I totally missed this PR. I'll resume work on it tomorrow CET

Evangelink avatar Feb 10 '25 15:02 Evangelink

With parallelization, running locally, before/after:

image

Evangelink avatar Feb 10 '25 19:02 Evangelink