Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

InvokeTestingPlatformTask should utilize RunCommand MSBuild property to determine how to run the test #5091

Open
Youssef1313 opened this issue Feb 20, 2025 · 1 comment
Assignees

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Feb 20, 2025

Logic around that in SDK:

https://github.com/dotnet/sdk/blob/ec0d0d91c119157eb27a3248fe35b43f2583e2ec/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L1130-L1168

We are broken at least in this case:

https://github.com/dotnet/sdk/blob/ec0d0d91c119157eb27a3248fe35b43f2583e2ec/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L1152-L1155

That's the root cause of the current failure of microsoft/PowerToys#37001

For some reason, doing dotnet exec path/to/dll fails with:

failed NameOfNewImageSizesIsIncrementedCorrectly (1ms)
  Test method ViewModelTests.ImageResizer.NameOfNewImageSizesIsIncrementedCorrectly threw exception:
  System.TypeInitializationException: The type initializer for 'Microsoft.PowerToys.Settings.UI.ViewModels.ImageResizerViewModel' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.PowerToys.Settings.UI.Helpers.ResourceLoaderInstance' threw an exception. ---> System.IO.FileNotFoundException: The system cannot find the file specified.

  The system cannot find the file specified.

        at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
    at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
    at Microsoft.Windows.ApplicationModel.Resources.ResourceLoader._IResourceLoaderFactoryMethods.CreateInstance(IObjectReference _obj, String fileName)
    at Microsoft.Windows.ApplicationModel.Resources.ResourceLoader..ctor(String fileName)
    at Microsoft.PowerToys.Settings.UI.Helpers.ResourceLoaderInstance..cctor() in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI\Helpers\ResourceLoaderInstance.cs:14
    --- End of inner exception stack trace ---
        at Microsoft.PowerToys.Settings.UI.Helpers.ResourceLoaderInstance.get_ResourceLoader() in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI\Helpers\ResourceLoaderInstance.cs:line 10
    at Microsoft.PowerToys.Settings.UI.ViewModels.ImageResizerViewModel..cctor() in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI\ViewModels\ImageResizerViewModel.cs:23
    --- End of inner exception stack trace ---
        at Microsoft.PowerToys.Settings.UI.ViewModels.ImageResizerViewModel.GetEncoderIndex(String encoderGuid) in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI\ViewModels\ImageResizerViewModel.cs:line 304
    at Microsoft.PowerToys.Settings.UI.ViewModels.ImageResizerViewModel..ctor(ISettingsUtils settingsUtils, ISettingsRepository`1 settingsRepository, Func`2 ipcMSGCallBackFunc, Func`2 resourceLoader) in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI\ViewModels\ImageResizerViewModel.cs:95
    at ViewModelTests.ImageResizer.NameOfNewImageSizesIsIncrementedCorrectly() in C:\Users\ygerges\Desktop\PowerToys\src\settings-ui\Settings.UI.UnitTests\ViewModelTests\ImageResizer.cs:268
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

while running the Exe directly works.

RunCommand MSBuild property correctly has the path to the executable.
Currently, we use TargetPath which is pointing out to the dll.

@Youssef1313
Copy link
Member Author

Few notes:

  1. If we go this approach, our target should have DependsOnTargets="ComputeRunArguments"
  2. We should respect RunWorkingDirectory
  3. We should respect RunArguments
  4. There is a ProjectCapability named SupportsComputeRunCommand that we could use to decide if we can use those properties, I think.
  5. This will handle complex cases that are currently not supported. See https://github.com/dotnet/android/blob/27feb809cde06489c800aad06305fe33f6a2f1c7/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets#L33-L49, https://github.com/dotnet/macios/blob/d4baff4c6847a413e6a9c60089edfff50611ea9b/dotnet/Microsoft.iOS.Sdk/targets/Microsoft.iOS.Sdk.targets#L11-L14, and https://github.com/dotnet/aspnetcore/blob/d035f4ea39c649120f6ea873cd2366e4649aaf06/src/Components/WebAssembly/DevServer/src/build/Microsoft.AspNetCore.Components.WebAssembly.DevServer.targets for examples.
  6. Maybe we can even have the logic as simply calling the Run target directly

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant